Refactor code to increase code quality and type coverage #11834
Workflow file for this run
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
# This workflow is especially helpful for pull requests to quickly see if the other tests will definitely fail. | |
# In order to get even quicker feedback, we also ping our Continuous Integration server to get a status check | |
# as soon as we know the outcome, as the GitHub Actions Pull Request UI takes a little bit to update. | |
name: 🔥 Smoke Tests | |
on: | |
pull_request: | |
jobs: | |
run-smoke-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Validate composer.json and composer.lock | |
run: composer validate --strict --no-check-all | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v4 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
- name: Install Composer Dependencies | |
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | |
- name: Run smoke tests | |
id: smoke-tests | |
run: vendor/bin/pest --stop-on-failure --log-junit report.xml | |
- name: Ping continuous integration server with test status | |
if: always() && github.event.repository.full_name == 'hydephp/develop' | |
run: | | |
bearerToken="${{ secrets.CI_SERVER_TOKEN }}" | |
commit="${{ github.event.pull_request.head.sha }}" | |
url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
# If bearerToken is not set, we we exit early as we are probably running on a fork | |
if [ -z "$bearerToken" ]; then | |
echo "Exiting early as bearerToken is not set" | |
exit 0 | |
fi | |
if [ ${{ steps.smoke-tests.outcome }} == "failure" ]; then | |
status=false | |
else | |
status=true | |
fi | |
curl -X POST --fail-with-body \ | |
-H "Authorization: Bearer $bearerToken" \ | |
-H "Content-Type: application/json" \ | |
-H "Accept: application/json" \ | |
-d '{"commit":"'"$commit"'", "status":'$status', "url":"'"$url"'"}' \ | |
https://ci.hydephp.com/api/test-run-reports | |
- name: Ping statistics server with test results | |
run: | | |
curl https://raw.githubusercontent.com/hydephp/develop/6e9d17f31879f4ccda13a3fec4029c9663bccec0/monorepo/scripts/ping-openanalytics-testrunner.php -o ping.php | |
php ping.php "Monorepo Smoke Tests" ${{ secrets.OPENANALYTICS_TOKEN }} ${{ github.ref_name }} | |
test-coverage: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: shivammathur/setup-php@v2 | |
with: | |
php-version: "8.1" | |
coverage: xdebug | |
extensions: fileinfo | |
- uses: actions/checkout@v4 | |
- name: Cache Composer packages | |
id: composer-cache | |
uses: actions/cache@v4 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-php- | |
- name: Install Composer Dependencies | |
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | |
- name: Set environment to testing | |
run: echo "ENV=testing" > .env | |
- name: Execute tests (Unit and Feature tests) via PHPUnit with coverage | |
run: vendor/bin/pest --coverage --coverage-clover clover.xml --log-junit report.xml | |
- name: "Publish coverage report to Codecov" | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Ping statistics server with test results | |
run: | | |
curl https://raw.githubusercontent.com/hydephp/develop/6e9d17f31879f4ccda13a3fec4029c9663bccec0/monorepo/scripts/ping-openanalytics-testrunner.php -o ping.php | |
php ping.php "Monorepo Smoke Tests - Coverage" ${{ secrets.OPENANALYTICS_TOKEN }} ${{ github.ref_name }} |