Skip to content

Commit

Permalink
Update workflows to handle running in forks
Browse files Browse the repository at this point in the history
Fixes issues when these secrets are not set, for example when running from a fork. Instead, these steps will now be skipped.
  • Loading branch information
caendesilva committed Apr 25, 2024
1 parent f275fb8 commit 73f0271
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test-pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}

0 comments on commit 73f0271

Please sign in to comment.