-
Notifications
You must be signed in to change notification settings - Fork 17
167 lines (130 loc) · 4.63 KB
/
validate-pr.yml
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
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: validate-pr
on:
pull_request:
branches: [main]
defaults:
run:
shell: bash
concurrency:
group: ${{ github.head_ref }}.${{ github.sha }}.validate-pr
cancel-in-progress: true
jobs:
checks:
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.check-changes.outputs.changes }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup environment
uses: ./.github/actions/setup-environment
- name: Check changes
id: check-changes
uses: ./.github/actions/check-changes
with:
premerge: 'true'
trunk: 'main'
- name: Validate commit messages
if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' }}
run: |
git checkout -b premerge
git fetch origin main:main
npx --no-install commitlint --from main
- name: Validation contribution size
if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' }}
uses: ./.github/actions/validate-contribution-size
lint:
needs: checks
runs-on: ubuntu-latest
outputs:
success: ${{ steps.check.outputs.success || 'true' }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup environment
uses: ./.github/actions/setup-environment
- name: Lint shell
if: fromJSON(needs.checks.outputs.changes).shelltools == 'true'
run: |
sudo apt install shellcheck
npx nx run tools:lint-shell
- name: Lint ts affected
run: npx nx affected --target lint --base origin/main
- name: Lint html affected
run: npx nx affected --target prettier-check --dryRun --base origin/main
- name: Set failure
id: check
if: failure()
run: echo "success='false'" >> $GITHUB_OUTPUT
test:
needs: checks
runs-on: ubuntu-latest
outputs:
success: ${{ steps.check.outputs.success || 'true' }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup environment
uses: ./.github/actions/setup-environment
with:
compodoc: true
- name: Compiler check affected
run: npx nx affected --target tsc-check --base origin/main
- name: Documentation coverage
run: npx nx run tools:compodoc-coverage-test
- name: Unit test affected
run: |
npx nx affected --target test --base origin/main --pass-with-no-tests --code-coverage --run-in-band --ci
npx nx run tools:coverage-stats
cat ./UNIT_COVERAGE.md >> $GITHUB_STEP_SUMMARY
- name: Set failure
id: check
if: failure()
run: echo "success='false'" >> $GITHUB_OUTPUT
build:
needs: checks
runs-on: ubuntu-latest
outputs:
success: ${{ steps.check.outputs.success || 'true' }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup environment
uses: ./.github/actions/setup-environment
- name: Build affected
run: npx nx affected --target build --base origin/main
- name: Build storybook affected
run: npx nx affected --target build-storybook --base origin/main --parallel 1
- name: Build global storybook
if: ${{ fromJSON(needs.checks.outputs.changes).dependencies == 'true' || fromJSON(needs.checks.outputs.changes).storybook == 'true' || fromJSON(needs.checks.outputs.changes).src == 'true' }}
run: npx nx run documentation:build-storybook
- name: Set failure
id: check
if: failure()
run: echo "success='false'" >> $GITHUB_OUTPUT
premerge:
needs: [lint, test, build]
if: always()
runs-on: ubuntu-latest
steps:
- name: Check result
run: |
if [[ "$LINT_RESULT" != "true" || "$TEST_RESULT" != "true" || "$BUILD_RESULT" != "true" ]]; then exit 1; fi
echo "### :rocket: Premerge checks succeeded" >> $GITHUB_STEP_SUMMARY
env:
LINT_RESULT: ${{ needs.lint.outputs.success }}
TEST_RESULT: ${{ needs.test.outputs.success }}
BUILD_RESULT: ${{ needs.build.outputs.success }}