-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (165 loc) · 4.83 KB
/
Copy pathpr.yml
File metadata and controls
176 lines (165 loc) · 4.83 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Pull Request Pipeline
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, closed]
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
concurrency:
group: pr-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
config:
name: CI Strategy
if: github.event.action != 'closed'
runs-on: ubuntu-latest
timeout-minutes: 7
outputs:
ci-matrix: ${{ steps.ci-matrix.outputs.matrix }}
runner-count: ${{ steps.ci-matrix.outputs.count }}
steps:
# Shallow checkout so GH Actions can resolve local composite actions.
# The setup action re-checks out with full history for moon's affected detection.
# TODO: Remove once composite actions are published to a shared repo.
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: ./.github/actions/setup
- id: ci-matrix
uses: ./.github/actions/moon-ci-matrix
ci:
name: Moon CI
needs: [config]
if: ${{ fromJson(needs.config.outputs.runner-count || '0') > 0 }}
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: true
matrix:
shard: ${{ fromJson(needs.config.outputs.ci-matrix) }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/setup
- uses: ./.github/actions/moon-ci
with:
access-token: ${{ secrets.GITHUB_TOKEN }}
audit:
name: Audit & SCA
needs: [ci]
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/setup
- name: Run Moon Audit Tasks (OSV, Cargo, Gitleaks)
run: moon run :audit --affected
codeql:
name: CodeQL
needs: [ci]
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
security-events: write
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
cache-cargo: "false"
cache-pnpm: "false"
- uses: github/codeql-action/init@v3
with:
languages: javascript
- uses: github/codeql-action/autobuild@v3
- uses: github/codeql-action/analyze@v3
# will evaluate when closer to a release
# semgrep:
# name: Semgrep
# needs: [ci]
# runs-on: ubuntu-latest
# permissions:
# security-events: write
# container:
# image: returntocorp/semgrep
# steps:
# - uses: actions/checkout@v4
# - name: Run Semgrep scan
# run: |
# semgrep ci \
# --sarif --output=semgrep.sarif \
# --config="p/default" \
# --config="p/security-audit" \
# --config="p/secrets"
# env:
# SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
# - name: Upload SARIF file
# uses: github/codeql-action/upload-sarif@v3
# if: always()
# with:
# sarif_file: semgrep.sarif
# category: semgrep
gate:
name: PR Gate
if: always()
needs: [ci, audit, codeql]
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- run: |
if [[ "${{ needs.ci.result }}" == "failure" || \
"${{ needs.audit.result }}" == "failure" || \
"${{ needs.codeql.result }}" == "failure" ]]; then
exit 1
fi
shell: bash
# Review App & Artifacts (RAA)
# Dispatches raa.yml when gate passes and the review-app label is present.
review-dispatch:
name: Dispatch RAA
needs: [gate]
if: >-
!failure() && !cancelled()
&& contains(github.event.pull_request.labels.*.name, 'review-app')
runs-on: ubuntu-latest
timeout-minutes: 2
permissions:
actions: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Dispatch RAA run
run: |
gh workflow run raa.yml \
--ref "$HEAD_REF" \
-f command=run \
-f pr-number="$PR_NUMBER"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEAD_REF: ${{ github.event.pull_request.head.ref }}
PR_NUMBER: ${{ github.event.pull_request.number }}
# Teardown review environment on PR close.
review-teardown:
name: Dispatch RAA Teardown
if: >-
github.event.action == 'closed'
&& contains(github.event.pull_request.labels.*.name, 'review-app')
runs-on: ubuntu-latest
timeout-minutes: 2
permissions:
actions: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Dispatch RAA teardown
run: |
gh workflow run raa.yml \
--ref main \
-f command=rm \
-f pr-number="$PR_NUMBER"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}