File tree Expand file tree Collapse file tree 4 files changed +83
-3
lines changed Expand file tree Collapse file tree 4 files changed +83
-3
lines changed Original file line number Diff line number Diff line change 1+ .github/workflows/**
2+ bin/**
3+ scripts/**
4+ src/**
5+ stubs/**
6+ tests/**
7+ tools/**
8+ .ci-pathspec
9+ .gitattributes
10+ .php-cs-fixer.dist.php
11+ .prettyphp
12+ codecov.yml
13+ composer.json
14+ composer.lock
15+ phpstan*
16+ phpunit.xml.dist
Original file line number Diff line number Diff line change 1+ /.ci-pathspec export-ignore
12/.git-blame-ignore-revs export-ignore
23/.gitattributes export-ignore
34/.github export-ignore
Original file line number Diff line number Diff line change 1+ name : Check CI runs
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ ci_workflow :
7+ description : CI workflow name
8+ type : string
9+ required : true
10+ outputs :
11+ ci_required :
12+ description : " Whether a CI workflow run is required for the current tree (0 = no, 1 = yes)"
13+ value : ${{ jobs.check-ci-runs.outputs.ci_required }}
14+
15+ jobs :
16+ check-ci-runs :
17+ name : Check CI workflow runs
18+ runs-on : ubuntu-latest
19+ outputs :
20+ ci_required : ${{ steps.get-ci-required.outputs.ci_required }}
21+
22+ steps :
23+ - name : Checkout
24+ uses : actions/checkout@v4
25+ with :
26+ fetch-depth : 0
27+
28+ - name : Check for a successful run with the same tree
29+ id : get-ci-required
30+ shell : bash
31+ run : |
32+ ci_required=1
33+ mapfile -t pathspec < <([[ -f .ci-pathspec ]] && sed -E $'/^[ \t]*(#|$)/d' .ci-pathspec)
34+ while read -r ref; do
35+ git diff-tree --quiet "$ref" HEAD -- ${pathspec+"${pathspec[@]}"} || continue
36+ printf '%s workflow already succeeded with the same tree: %s\n' "$ci_workflow" "$ref"
37+ ci_required=0
38+ break
39+ done < <(
40+ git rev-list --no-merges HEAD |
41+ grep -Fxf <(gh run list --workflow "$ci_workflow" --status success --json headSha --jq '.[].headSha')
42+ )
43+ ((!ci_required)) || printf 'No successful %s workflow runs found with the same tree\n' "$ci_workflow"
44+ printf 'ci_required=%d\n' "$ci_required" | tee -a "$GITHUB_OUTPUT"
45+ env :
46+ ci_workflow : ${{ inputs.ci_workflow }}
47+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change 77
88 pull_request :
99
10- workflow_dispatch :
10+ workflow_call :
1111
1212concurrency :
1313 group : ${{ github.workflow }}-${{ github.head_ref || github.ref }}
1414 cancel-in-progress : true
1515
1616jobs :
17+ check-ci-runs :
18+ name : Check previous runs
19+ if : ${{ github.event_name != 'workflow_call' }}
20+ uses : ./.github/workflows/check-ci-runs.yml
21+ with :
22+ ci_workflow : CI
23+
1724 check :
1825 name : Check generated files and formatting
26+ needs :
27+ - check-ci-runs
28+ if : ${{ (github.event_name == 'workflow_call' || needs.check-ci-runs.outputs.ci_required == 1) && !cancelled() && !failure() }}
1929 runs-on : ubuntu-latest
2030
2131 steps :
5464
5565 phpstan :
5666 name : PHPStan
67+ needs :
68+ - check
69+ - check-ci-runs
70+ if : ${{ (github.event_name == 'workflow_call' || needs.check-ci-runs.outputs.ci_required == 1) && !cancelled() && !failure() }}
5771 runs-on : ubuntu-latest
58- needs : check
5972
6073 strategy :
6174 fail-fast : false
@@ -101,7 +114,10 @@ jobs:
101114
102115 unit-tests :
103116 name : PHPUnit tests
104- needs : check
117+ needs :
118+ - check
119+ - check-ci-runs
120+ if : ${{ (github.event_name == 'workflow_call' || needs.check-ci-runs.outputs.ci_required == 1) && !cancelled() && !failure() }}
105121
106122 strategy :
107123 fail-fast : false
You can’t perform that action at this time.
0 commit comments