Add status command #421
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pull Request | |
on: | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref }} | |
cancel-in-progress: false | |
env: | |
minimum_supported_php_version: "8.2" | |
package_extensions: none, mbstring, curl, ctype, tokenizer, mongodb, xml, pdo, fileinfo, dom, xmlwriter, simplexml, sqlite3, pdo_sqlite, posix, redis | |
agent_extensions: none, mbstring, curl, ctype, dom, simplexml, tokenizer, xml, xmlwriter | |
client_extensions: none, mbstring, curl, ctype, dom, simplexml, tokenizer, xml, xmlwriter | |
jobs: | |
## Run coding standards and static analysis before building the agent and client | |
package_static_analysis: | |
name: Package static analysis | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup PHP ${{ env.minimum_supported_php_version }} and tooling | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.minimum_supported_php_version }} | |
extensions: ${{ env.package_extensions }} | |
ini-values: error_reporting=E_ALL | |
tools: composer:v2, composer-dependency-analyser | |
coverage: none | |
# See: https://github.com/shivammathur/setup-php#cache-composer-dependencies | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-package-composer-${{ hashFiles('**/composer.json') }} | |
restore-keys: ${{ runner.os }}-package-composer | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-interaction --no-progress | |
- name: Check platform | |
run: composer check-platform-reqs | |
- name: Check dependencies | |
run: composer-dependency-analyser | |
- name: Run PHPStan | |
run: vendor/bin/phpstan --verbose | |
agent_static_analysis: | |
name: Agent static analysis | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./agent | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup PHP ${{ env.minimum_supported_php_version }} and tooling | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.minimum_supported_php_version }} | |
extensions: ${{ env.agent_extensions }} | |
ini-values: error_reporting=E_ALL | |
tools: composer:v2, composer-dependency-analyser | |
coverage: none | |
# See: https://github.com/shivammathur/setup-php#cache-composer-dependencies | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-agent-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-agent-composer | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-interaction --no-progress | |
- name: Check platform | |
run: composer check-platform-reqs | |
- name: Check dependencies | |
run: composer-dependency-analyser | |
- name: Run PHPStan | |
run: vendor/bin/phpstan --verbose | |
client_static_analysis: | |
name: Client static analysis | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./client | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup PHP ${{ env.minimum_supported_php_version }} and tooling | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.minimum_supported_php_version }} | |
extensions: ${{ env.client_extensions }} | |
ini-values: error_reporting=E_ALL | |
tools: composer:v2, composer-dependency-analyser | |
coverage: none | |
# See: https://github.com/shivammathur/setup-php#cache-composer-dependencies | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-client-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-client-composer | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-interaction --no-progress | |
- name: Check platform | |
run: composer check-platform-reqs | |
- name: Check dependencies | |
run: composer-dependency-analyser | |
- name: Run PHPStan | |
run: vendor/bin/phpstan --verbose | |
coding_standards: | |
name: Coding standards | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ vars.NIGHTWATCH_PERMISSIONS_APP_ID }} | |
private-key: ${{ secrets.NIGHTWATCH_PERMISSIONS_APP_PRIVATE_KEY }} | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ steps.app-token.outputs.token }} | |
ref: ${{ github.head_ref }} | |
- name: Setup PHP ${{ env.minimum_supported_php_version }} and tooling | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.minimum_supported_php_version }} | |
extensions: ${{ env.package_extensions }} | |
ini-values: error_reporting=E_ALL | |
tools: composer:v2 | |
coverage: none | |
# See: https://github.com/shivammathur/setup-php#cache-composer-dependencies | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-package-composer-${{ hashFiles('**/composer.json') }} | |
restore-keys: ${{ runner.os }}-package-composer | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-interaction --no-progress | |
- name: Run Pint (CI only) | |
run: vendor/bin/pint --config=pint.ci.json | |
- name: Run Pint | |
run: vendor/bin/pint | |
- uses: EndBug/add-and-commit@v9 | |
with: | |
default_author: github_actions | |
message: "Fix code styling" | |
## Builds the agent, evaluates whether it has changed, and if so commits the result | |
build_agent: | |
name: Build agent | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
needs: | |
- package_static_analysis | |
- agent_static_analysis | |
- client_static_analysis | |
- coding_standards | |
outputs: | |
agent-committed: ${{ steps.commit-agent.outputs.committed }} | |
defaults: | |
run: | |
working-directory: ./agent | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ vars.NIGHTWATCH_PERMISSIONS_APP_ID }} | |
private-key: ${{ secrets.NIGHTWATCH_PERMISSIONS_APP_PRIVATE_KEY }} | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ steps.app-token.outputs.token }} | |
ref: ${{ github.head_ref }} | |
- name: Setup PHP ${{ env.minimum_supported_php_version }} and tooling | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.minimum_supported_php_version }} | |
extensions: ${{ env.agent_extensions }} | |
ini-values: error_reporting=E_ALL | |
tools: composer:v2, box:4.6.3 | |
coverage: none | |
# See: https://github.com/shivammathur/setup-php#cache-composer-dependencies | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-agent-composer-${{ hashFiles('**/composer.lock') }}-no-dev | |
restore-keys: ${{ runner.os }}-agent-composer | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-interaction --no-progress --no-dev | |
- name: Build agent | |
id: build-agent | |
run: | | |
box compile | |
box info:signature build/agent.phar > build/signature.txt | |
echo "version=$(cat build/signature.txt)" >> "$GITHUB_OUTPUT" | |
- id: commit-agent | |
uses: EndBug/add-and-commit@v9 | |
with: | |
default_author: github_actions | |
message: "Bump agent version to ${{ steps.build-agent.outputs.version }}" | |
## Builds the client, evaluates whether it has changed, and if so commits the result | |
build_client: | |
name: Build client | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
needs: | |
- package_static_analysis | |
- agent_static_analysis | |
- client_static_analysis | |
- coding_standards | |
outputs: | |
client-committed: ${{ steps.commit-client.outputs.committed }} | |
defaults: | |
run: | |
working-directory: ./client | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ vars.NIGHTWATCH_PERMISSIONS_APP_ID }} | |
private-key: ${{ secrets.NIGHTWATCH_PERMISSIONS_APP_PRIVATE_KEY }} | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ steps.app-token.outputs.token }} | |
ref: ${{ github.head_ref }} | |
- name: Setup PHP ${{ env.minimum_supported_php_version }} and tooling | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.minimum_supported_php_version }} | |
extensions: ${{ env.client_extensions }} | |
ini-values: error_reporting=E_ALL | |
tools: composer:v2, box:4.6.3 | |
coverage: none | |
# See: https://github.com/shivammathur/setup-php#cache-composer-dependencies | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-client-composer-${{ hashFiles('**/composer.lock') }}-no-dev | |
restore-keys: ${{ runner.os }}-client-composer | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-interaction --no-progress --no-dev | |
- name: Build client | |
id: build-client | |
run: | | |
box compile | |
box info:signature build/client.phar > build/signature.txt | |
echo "version=$(cat build/signature.txt)" >> "$GITHUB_OUTPUT" | |
- id: commit-client | |
uses: EndBug/add-and-commit@v9 | |
with: | |
default_author: github_actions | |
message: "Bump client version to ${{ steps.build-client.outputs.version }}" | |
package_tests: | |
runs-on: ubuntu-latest | |
needs: | |
- build_agent | |
- build_client | |
if: ${{ (needs.build_agent.outputs.agent-committed == 'false') && (needs.build_client.outputs.client-committed == 'false') }} | |
services: | |
redis: | |
image: redis | |
ports: | |
- 6379:6379 | |
options: --entrypoint redis-server | |
strategy: | |
matrix: | |
php: [8.2, 8.3] | |
laravel: [10, 11, 12] | |
prefer-lowest: ['0', '1'] | |
name: Test package [PHP ${{ matrix.php }}, Laravel ${{ matrix.laravel }}] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup PHP ${{ matrix.php }} and tooling | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
extensions: ${{ env.package_extensions }} | |
ini-values: error_reporting=E_ALL | |
tools: composer:v2 | |
coverage: pcov | |
# See: https://github.com/shivammathur/setup-php#cache-composer-dependencies | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-package-composer-${{ hashFiles('**/composer.json') }} | |
restore-keys: ${{ runner.os }}-package-composer | |
- name: Require Laravel Version | |
run: composer require laravel/framework:^${{ matrix.laravel }} --no-update | |
- name: Install dependencies | |
run: COMPOSER_PREFER_LOWEST=${{ matrix.prefer-lowest }} composer install --prefer-dist --no-interaction --no-progress | |
- name: Execute tests | |
run: vendor/bin/pest --coverage --min=80 | |
agent_tests: | |
runs-on: ubuntu-latest | |
needs: | |
- build_agent | |
- build_client | |
if: ${{ (needs.build_agent.outputs.agent-committed == 'false') && (needs.build_client.outputs.client-committed == 'false') }} | |
defaults: | |
run: | |
working-directory: ./agent | |
strategy: | |
matrix: | |
php: [8.2, 8.3] | |
name: Test agent [PHP ${{ matrix.php }}] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup PHP ${{ matrix.php }} and tooling | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
extensions: ${{ env.agent_extensions }} | |
ini-values: error_reporting=E_ALL | |
tools: composer:v2 | |
coverage: pcov | |
# See: https://github.com/shivammathur/setup-php#cache-composer-dependencies | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-agent-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-agent-composer | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-interaction --no-progress | |
- name: Execute tests | |
env: | |
NIGHTWATCH_TOKEN: ${{ secrets.NIGHTWATCH_TOKEN }} | |
NIGHTWATCH_BASE_URL: ${{ secrets.NIGHTWATCH_BASE_URL }} | |
run: vendor/bin/pest --coverage | |
client_tests: | |
runs-on: ubuntu-latest | |
needs: | |
- build_agent | |
- build_client | |
if: ${{ (needs.build_agent.outputs.agent-committed == 'false') && (needs.build_client.outputs.client-committed == 'false') }} | |
defaults: | |
run: | |
working-directory: ./client | |
strategy: | |
matrix: | |
php: [8.2, 8.3] | |
name: Test client [PHP ${{ matrix.php }}] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup PHP ${{ matrix.php }} and tooling | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
extensions: ${{ env.client_extensions }} | |
ini-values: error_reporting=E_ALL | |
tools: composer:v2 | |
coverage: pcov | |
# See: https://github.com/shivammathur/setup-php#cache-composer-dependencies | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-client-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-client-composer | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-interaction --no-progress | |
- name: Execute tests | |
run: vendor/bin/pest --coverage |