-
-
Notifications
You must be signed in to change notification settings - Fork 262
177 lines (169 loc) · 5.48 KB
/
ci_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
168
169
170
171
172
173
174
175
176
177
name: CI - PR
'on':
pull_request:
branches:
- main
jobs:
lint:
name: Run Linters
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- name: Setup Node.JS
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Cache node modules
uses: actions/[email protected]
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Website - Install dependencies
run: cd website && npm ci
- id: yamllint
name: Yamllint
uses: reviewdog/action-yamllint@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
yamllint_flags: '.'
fail_on_error: true
filter_mode: nofilter
continue-on-error: true
- id: eslint
name: ESLint
uses: reviewdog/[email protected]
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
eslint_flags: --ext js,jsx .
fail_on_error: true
filter_mode: nofilter
workdir: website
continue-on-error: true
- if: ${{ steps.yamllint.outcome == 'failure' }}
run: echo "yamllint" >> results.txt
- if: ${{ steps.eslint.outcome == 'failure' }}
run: echo "eslint" >> results.txt
- uses: actions/upload-artifact@v3
with:
name: lint
path: results.txt
retention-days: 5
if-no-files-found: ignore
- name: Report linters error
if: ${{ steps.yamllint.outcome == 'failure' || steps.eslint.outcome == 'failure' }}
run: exit 1
format-lint:
name: Run formatters to check code formatting
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- name: Setup Node.JS
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Cache node modules
uses: actions/[email protected]
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: npm ci
- name: Website - Install dependencies
run: cd website && npm ci
- id: prettier
name: Prettier Check
uses: creyD/[email protected]
with:
dry: true
prettier_options: --write .
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
- if: ${{ always() && steps.prettier.outcome == 'failure' }}
run: echo "prettier" >> results.txt
- if: ${{ always() && steps.prettier.outcome == 'failure' }}
uses: actions/upload-artifact@v3
with:
name: format-lint
path: results.txt
if-no-files-found: ignore
build:
name: Check website build
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- name: Setup Node.JS
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Cache node modules
uses: actions/[email protected]
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: npm ci
- name: Website - Install dependencies
run: cd website && npm ci
- name: Website - Build
run: cd website && npm run build
changes:
name: Analyze changes
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: changes
with:
list-files: json
filters: |
blueprints:
- 'blueprints/**/*.yaml'
- if: ${{ steps.changes.outputs.blueprints == 'true' }}
id: blueprints_urls
env:
FILES: ${{ steps.changes.outputs.blueprints_files }}
REPO: ${{ github.event.pull_request.head.repo.full_name }}
run: |
mapfile -t files < <( jq '.[]' < <(echo ${FILES}) )
for f in ${files[@]}; do echo "https://github.com/${REPO}/blob/${GITHUB_HEAD_REF}/$(echo $f | tr -d '"')" >> blueprints.txt; done
- env:
PR_NUM: ${{ github.event.number }}
run: echo $PR_NUM > pr_num.txt
- uses: actions/upload-artifact@v3
with:
name: changes
path: blueprints.txt
retention-days: 5
if-no-files-found: ignore
- uses: actions/upload-artifact@v3
with:
name: changes
path: pr_num.txt
retention-days: 5