@@ -17,20 +17,88 @@ jobs:
1717 jest :
1818 runs-on : ubuntu-latest
1919 steps :
20+ - name : Release commit skip check
21+ id : release-check
22+ uses : actions/github-script@v8
23+ with :
24+ script : |
25+ const { owner, repo } = context.repo;
26+ const isReleaseCommit = (message) => (message || '').includes('chore: release');
27+ let message = '';
28+
29+ if (context.payload.pull_request?.head?.sha) {
30+ const { data } = await github.rest.repos.getCommit({
31+ owner,
32+ repo,
33+ ref: context.payload.pull_request.head.sha
34+ });
35+ message = data?.commit?.message || '';
36+ } else if (context.payload.head_commit?.message) {
37+ message = context.payload.head_commit.message;
38+ } else {
39+ const { data } = await github.rest.repos.getCommit({ owner, repo, ref: context.sha });
40+ message = data?.commit?.message || '';
41+ }
42+
43+ const skipRelease = isReleaseCommit(message);
44+ core.info(`Release skip check message: ${message}`);
45+ core.setOutput('skip_release', skipRelease.toString());
46+
47+ - name : Debug last successful test code run for PR
48+ if : ${{ github.event_name == 'pull_request' }}
49+ uses : actions/github-script@v8
50+ with :
51+ script : |
52+ const { owner, repo } = context.repo;
53+ const pr = context.payload.pull_request;
54+ if (!pr) {
55+ core.info('No PR context; skipping last successful run lookup.');
56+ return;
57+ }
58+
59+ const workflowId = 'test-code.yaml';
60+ const runs = await github.rest.actions.listWorkflowRuns({
61+ owner,
62+ repo,
63+ workflow_id: workflowId,
64+ event: 'pull_request',
65+ per_page: 50
66+ });
67+
68+ const matchingRuns = runs.data.workflow_runs.filter((run) =>
69+ run.conclusion === 'success' &&
70+ run.pull_requests?.some((p) => p.number === pr.number)
71+ );
72+
73+ const last = matchingRuns[0];
74+ if (!last) {
75+ core.info(`No successful ${workflowId} runs found for PR #${pr.number}.`);
76+ return;
77+ }
78+
79+ core.info(`Last successful ${workflowId} run for PR #${pr.number}:`);
80+ core.info(`- run id: ${last.id}`);
81+ core.info(`- head sha: ${last.head_sha}`);
82+ core.info(`- updated at: ${last.updated_at}`);
83+ core.info(`- html url: ${last.html_url}`);
84+
2085 - uses : actions/checkout@v6
2186 with :
2287 # Disabling shallow clone is recommended for improving relevancy of reporting
2388 fetch-depth : 0
2489 - name : dev env setup
90+ if : ${{ !(steps.release-check.outputs.skip_release == 'true' && github.ref != 'refs/heads/main') }}
2591 uses : ./.github/actions/dev-env-setup
2692 - name : run jest tests with coverage
93+ if : ${{ !(steps.release-check.outputs.skip_release == 'true' && github.ref != 'refs/heads/main') }}
2794 uses : Wandalen/wretry.action@master
2895 with :
2996 current_path : ./app
3097 command : yarn test --coverage --silent
3198 attempt_limit : 2
3299 attempt_delay : 2000
33100 - name : SonarCloud Scan
101+ if : ${{ !(steps.release-check.outputs.skip_release == 'true' && github.ref != 'refs/heads/main') }}
34102 uses : SonarSource/sonarqube-scan-action@v7.0.0
35103 env :
36104 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments