11name : Internal - Test PHP test action
22on :
3- workflow_call : null
3+ workflow_call :
4+ inputs :
5+ scenario :
6+ description : Integration scenario to run.
7+ required : true
8+ type : string
49permissions : {}
510jobs :
611 test :
7- name : Test (${{ matrix .scenario }})
12+ name : Test (${{ inputs .scenario }})
813 runs-on : ubuntu-latest
914 permissions :
1015 contents : read
11- strategy :
12- fail-fast : false
13- matrix :
14- include :
15- - scenario : reports
16- coverage : github
17- - scenario : publication-disabled
18- coverage : " "
19- - scenario : preparation
20- coverage : " "
21- - scenario : composer-command
22- coverage : " "
23- - scenario : failing-command
24- coverage : " "
25- - scenario : failing-tests
26- coverage : github
27- - scenario : no-reports
28- coverage : " "
16+ outputs :
17+ report-artifact-id : ${{ steps.tests.outputs.report-artifact-id }}
18+ expected-reports : ${{ steps.assert.outputs.expected-reports }}
2919 steps :
3020 - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
3121 with :
3424 id : fixture
3525 uses : actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3
3626 env :
37- SCENARIO : ${{ matrix .scenario }}
27+ SCENARIO : ${{ inputs .scenario }}
3828 with :
3929 script : |-
4030 const fs = require('node:fs/promises');
@@ -72,26 +62,21 @@ jobs:
7262 composer-directories : ' ["."]'
7363 - name : Act - Run project tests without comment permission
7464 id : tests
75- continue-on-error : ${{ startsWith(matrix.scenario, 'failing-') }}
65+ # The assertion below checks the exact expected outcome for every scenario.
66+ continue-on-error : true
7667 uses : $/actions/test
7768 with :
7869 working-directory : ${{ steps.fixture.outputs.directory }}
79- coverage : ${{ matrix.coverage }}
80- - name : Assert - Download the native report artifact
81- if : steps.tests.outputs.report-artifact-id != ''
82- uses : actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
83- with :
84- artifact-ids : ${{ steps.tests.outputs.report-artifact-id }}
85- path : downloaded-reports
86- merge-multiple : true
70+ coverage : ${{ (inputs.scenario == 'reports' || inputs.scenario == 'failing-tests') && 'github' || '' }}
8771 - name : Assert - Reports and project preparation
72+ id : assert
8873 uses : actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3
8974 env :
9075 DIRECTORY : ${{ steps.fixture.outputs.directory }}
9176 OUTCOME : ${{ steps.tests.outcome }}
92- SCENARIO : ${{ matrix .scenario }}
77+ SCENARIO : ${{ inputs .scenario }}
9378 ARTIFACT_ID : ${{ steps.tests.outputs.report-artifact-id }}
94- COVERAGE : ${{ matrix.coverage }}
79+ COVERAGE : ${{ (inputs.scenario == 'reports' || inputs.scenario == 'failing-tests') && 'github' || '' }}
9580 with :
9681 script : |-
9782 const assert = require('node:assert/strict');
10590 return;
10691 }
10792 assert.match(process.env.ARTIFACT_ID, /^\d+$/);
108- const files = await (await glob.create('downloaded-reports/**/*', {matchDirectories: false})).glob( );
109- assert.deepEqual(files.map(file => path.basename(file)).sort(), process.env.COVERAGE === 'github' ? ['cobertura.xml', 'junit.xml'] : ['junit.xml']) ;
110- for (const file of files) assert.equal(fs.readFileSync(file, 'utf8'), fs.readFileSync(path.join(directory, path.basename(file)), 'utf8' ));
93+ const {createHash} = require('node:crypto' );
94+ const reportNames = process.env.COVERAGE === 'github' ? ['cobertura.xml', 'junit.xml'] : ['junit.xml'];
95+ core.setOutput('expected-reports', Object.fromEntries(reportNames.map(name => [name, createHash('sha256').update( fs.readFileSync(path.join(directory, name))).digest('hex')]) ));
11196 const junit = fs.readFileSync(path.join(directory, 'junit.xml'), 'utf8');
11297 assert.match(junit, /<testcase\b/);
11398 assert.equal(junit.includes('<failure'), scenario === 'failing-tests');
@@ -121,7 +106,16 @@ jobs:
121106 assert.equal(fs.readFileSync(path.join(directory, 'prepared.txt'), 'utf8'), 'ready');
122107 }
123108
109+ verify-reports :
110+ needs : test
111+ if : needs.test.outputs.report-artifact-id != ''
112+ uses : $/.github/workflows/__assert-report-artifact.yml
113+ with :
114+ artifact-id : ${{ needs.test.outputs.report-artifact-id }}
115+ expected-reports : ${{ needs.test.outputs.expected-reports }}
116+
124117 individual-comment :
118+ if : inputs.scenario == 'reports'
125119 runs-on : ubuntu-latest
126120 permissions :
127121 contents : read
0 commit comments