From 73f0271a07c8cc05bf9756ac29ba390be28befc7 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 25 Apr 2024 16:09:30 +0200 Subject: [PATCH] Update workflows to handle running in forks Fixes issues when these secrets are not set, for example when running from a fork. Instead, these steps will now be skipped. --- .github/workflows/smoke-tests.yml | 5 +++-- .github/workflows/static-analysis.yml | 2 +- .github/workflows/test-pull-requests.yml | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/smoke-tests.yml b/.github/workflows/smoke-tests.yml index de338347c6c..03b6617147a 100644 --- a/.github/workflows/smoke-tests.yml +++ b/.github/workflows/smoke-tests.yml @@ -31,7 +31,7 @@ jobs: 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' + if: always() && github.event.repository.full_name == 'hydephp/develop' && secrets.CI_SERVER_TOKEN run: | bearerToken="${{ secrets.CI_SERVER_TOKEN }}" commit="${{ github.event.pull_request.head.sha }}" @@ -51,6 +51,7 @@ jobs: https://ci.hydephp.com/api/test-run-reports - name: Ping statistics server with test results + if: secrets.OPENANALYTICS_TOKEN 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 }} @@ -88,9 +89,9 @@ jobs: uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: true - name: Ping statistics server with test results + if: secrets.OPENANALYTICS_TOKEN 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 }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index dba99d85384..9fb735c6a01 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -25,7 +25,7 @@ jobs: # Send the reports to the CI server to calculate type coverage and send back commit status checks - name: Ping CI server with type coverage results - if: github.event.repository.full_name == 'hydephp/develop' + if: github.event.repository.full_name == 'hydephp/develop' && secrets.CI_SERVER_TOKEN run: php monorepo/scripts/ping-ci-server-with-type-coverage.php ${{ secrets.CI_SERVER_TOKEN }} ${{ github.event.pull_request.head.sha }} ${{ github.head_ref }} ${{ github.run_id }} type-coverage: diff --git a/.github/workflows/test-pull-requests.yml b/.github/workflows/test-pull-requests.yml index f8862b49b1a..b440a178b37 100644 --- a/.github/workflows/test-pull-requests.yml +++ b/.github/workflows/test-pull-requests.yml @@ -49,6 +49,7 @@ jobs: files: ./build/coverage/clover.xml,./build/coverage/crap4j.xml,./build/coverage/report.txt,./build/junit.xml - name: Ping statistics server with test results + if: secrets.OPENANALYTICS_TOKEN run: | cp build/junit.xml report.xml curl https://raw.githubusercontent.com/hydephp/develop/6e9d17f31879f4ccda13a3fec4029c9663bccec0/monorepo/scripts/ping-openanalytics-testrunner.php -o ping.php @@ -76,6 +77,7 @@ jobs: run: vendor/bin/pest --log-junit report.xml - name: Ping statistics server with test results + if: secrets.OPENANALYTICS_TOKEN run: | curl https://raw.githubusercontent.com/hydephp/develop/6e9d17f31879f4ccda13a3fec4029c9663bccec0/monorepo/scripts/ping-openanalytics-testrunner.php -o ping.php php ping.php "Monorepo PR Matrix" ${{ secrets.OPENANALYTICS_TOKEN }} ${{ github.ref_name }}