Skip to content

[StepSecurity] ci: Harden GitHub Actions #13167

[StepSecurity] ci: Harden GitHub Actions

[StepSecurity] ci: Harden GitHub Actions #13167

# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
name: "Reflection golden test"
on:
pull_request:
paths-ignore:
- 'compiler/**'
- 'apigen/**'
- 'changelog-generator/**'
- 'issue-bot/**'
push:
branches:
- "2.1.x"
paths-ignore:
- 'compiler/**'
- 'apigen/**'
- 'changelog-generator/**'
- 'issue-bot/**'
env:
REFLECTION_GOLDEN_TEST_FILE: "/tmp/reflection-golden.test"
REFLECTION_GOLDEN_SYMBOLS_FILE: "/tmp/reflection-golden-symbols.txt"
concurrency:
group: reflection-golden-test-${{ github.head_ref || github.run_id }} # will be canceled on subsequent pushes in pull requests but not branches
cancel-in-progress: true
jobs:
dump-php-symbols:
name: "Dump PHP symbols"
runs-on: "ubuntu-latest"
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit
- name: "Checkout"
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: "Install PHP"
uses: "shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1" # v2
with:
coverage: "none"
php-version: "8.3"
# Include exotic extensions to discover more symbols
extensions: ds,mbstring,runkit7,scoutapm,seaslog,simdjson,var_representation,yac
- uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # v3
- name: "Dump phpSymbols.txt"
run: "php tests/dump-reflection-test-symbols.php"
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: phpSymbols
path: ${{ env.REFLECTION_GOLDEN_SYMBOLS_FILE }}
reflection-golden-test:
name: "Reflection golden test"
needs: dump-php-symbols
runs-on: "ubuntu-latest"
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
php-version:
- "8.2"
- "8.3"
- "8.4"
- "8.5"
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit
- uses: Wandalen/wretry.action@e68c23e6309f2871ca8ae4763e7629b9c258e1ea # v3.8.0
with:
action: actions/download-artifact@v4
with: |
name: phpSymbols
path: /tmp
attempt_limit: 5
attempt_delay: 1000
- name: "Checkout base commit"
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
ref: ${{ github.event.pull_request.base.sha || github.event.before }}
- name: "Install PHP"
uses: "shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1" # v2
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: pecl
extensions: ds,mbstring
ini-file: development
ini-values: memory_limit=2G
- uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # v3
- name: "Dump previous reflection data"
run: "php tests/generate-reflection-test.php"
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: reflection-${{ matrix.php-version }}.test
path: ${{ env.REFLECTION_GOLDEN_TEST_FILE }}
- name: "Checkout"
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # v3
- name: "Reflection golden test"
run: "make tests-golden-reflection || true"