-
Notifications
You must be signed in to change notification settings - Fork 7
106 lines (88 loc) · 3.53 KB
/
pr.yml
File metadata and controls
106 lines (88 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: PR
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
concurrency:
group: ${{ github.workflow }}-pr-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
jobs:
dependencies:
uses: ./.github/workflows/_dependencies.yml
circular:
uses: ./.github/workflows/_circular.yml
check-commit-count:
uses: ./.github/workflows/_check-commit-count.yml
permissions:
pull-requests: read
issues: write
contracts:
uses: ./.github/workflows/_contracts.yml
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
lint-internal:
if: github.event.pull_request.head.repo.full_name == github.repository
uses: ./.github/workflows/_lint-internal.yml
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
lint-external:
if: github.event.pull_request.head.repo.full_name != github.repository
uses: ./.github/workflows/_lint-external.yml
permissions:
contents: read
issues: write
prechecks-gate:
runs-on: ubuntu-latest
needs:
- dependencies
- circular
- check-commit-count
- contracts
- lint-internal
- lint-external
if: ${{ !cancelled() }}
outputs:
run_tests: ${{ steps.decide.outputs.run_tests }}
steps:
- name: Decide whether tests should run
id: decide
env:
LINT_INTERNAL_RESULT: ${{ needs.lint-internal.result }}
LINT_INTERNAL_DID_COMMIT: ${{ needs.lint-internal.outputs.did_commit }}
LINT_EXTERNAL_RESULT: ${{ needs.lint-external.result }}
DEPENDENCIES_RESULT: ${{ needs.dependencies.result }}
CIRCULAR_RESULT: ${{ needs.circular.result }}
COMMIT_COUNT_RESULT: ${{ needs.check-commit-count.result }}
CONTRACTS_RESULT: ${{ needs.contracts.result }}
run: |
lint_ok=false
if [[ "$LINT_INTERNAL_RESULT" == "success" && "$LINT_INTERNAL_DID_COMMIT" != "true" ]]; then
lint_ok=true
fi
if [[ "$LINT_EXTERNAL_RESULT" == "success" ]]; then
lint_ok=true
fi
other_checks_ok=true
for result in "$DEPENDENCIES_RESULT" "$CIRCULAR_RESULT" "$COMMIT_COUNT_RESULT" "$CONTRACTS_RESULT"; do
if [[ "$result" != "success" ]]; then
other_checks_ok=false
fi
done
# Internal autofix commit happened, so stop gracefully and let the new run take over.
if [[ "$LINT_INTERNAL_DID_COMMIT" == "true" ]]; then
echo "run_tests=false" >> "$GITHUB_OUTPUT"
exit 0
fi
# Any required precheck failed, so make the gate red.
if [[ "$lint_ok" != "true" || "$other_checks_ok" != "true" ]]; then
echo "run_tests=false" >> "$GITHUB_OUTPUT"
exit 1
fi
echo "run_tests=true" >> "$GITHUB_OUTPUT"
test:
needs: [prechecks-gate]
if: ${{ !cancelled() && needs['prechecks-gate'].outputs.run_tests == 'true' }}
uses: ./.github/workflows/_test.yml
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}