Skip to content

Commit 6554f0b

Browse files
ci: move pretty check to one job, stop the rest of the ci from running when prettier errors (#5670)
* move prettier to a separate job, write fixes * remove from assets * break formatting * fix ci * remove exit * typo * ci * permission * use a different action * Fix prettier * commit author * break formatting * Fix prettier * unnecessary ref, remove comments * commit message * split steps * break fe * break fe src * fix if * fix prettier * remove write * rename job * break fe * revert permission change * fix * rename scripts --------- Co-authored-by: Miodec <Miodec@users.noreply.github.com> Co-authored-by: George The Bot <monkeytypegeorge@gmail.com>
1 parent daa930b commit 6554f0b

2 files changed

Lines changed: 62 additions & 23 deletions

File tree

.github/workflows/monkey-ci.yml

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,57 @@ jobs:
9595
name: Install dependencies
9696
run: npm install --prefer-offline --no-audit
9797

98+
check-pretty:
99+
name: check-pretty
100+
needs: [pre-ci, prime-cache]
101+
runs-on: ubuntu-latest
102+
if: needs.pre-ci.outputs.should-build-be == 'true' || needs.pre-ci.outputs.should-build-fe == 'true' || needs.pre-ci.outputs.should-build-pkg == 'true' || needs.pre-ci.outputs.assets-json == 'true'
103+
steps:
104+
- uses: actions/checkout@v4
105+
- name: Set up Node.js
106+
uses: actions/setup-node@v4
107+
with:
108+
node-version: ${{ env.NODE_VERSION }}
109+
110+
- name: Cache node modules
111+
id: cache-npm
112+
uses: actions/cache@v4
113+
env:
114+
cache-name: cache-node-modules
115+
with:
116+
path: ~/.npm
117+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
118+
restore-keys: |
119+
${{ runner.os }}-build-${{ env.cache-name }}-
120+
${{ runner.os }}-build-
121+
${{ runner.os }}-
122+
123+
- name: Install dependencies
124+
run: npm install --prefer-offline --no-audit
125+
126+
- name: Check pretty (backend)
127+
id: check-pretty-be
128+
if: needs.pre-ci.outputs.should-build-be == 'true'
129+
run: npm run pretty-check-be
130+
131+
- name: Check pretty (frontend)
132+
id: check-pretty-fe
133+
if: needs.pre-ci.outputs.should-build-fe == 'true'
134+
run: npm run pretty-check-fe
135+
136+
- name: Check pretty (packages)
137+
id: check-pretty-pkg
138+
if: needs.pre-ci.outputs.should-build-pkg == 'true'
139+
run: npm run pretty-check-pkg
140+
141+
- name: Check pretty (assets)
142+
id: check-pretty-assets
143+
if: needs.pre-ci.outputs.assets-json == 'true'
144+
run: npm run pretty-check-assets
145+
98146
ci-be:
99147
name: ci-be
100-
needs: [pre-ci, prime-cache]
148+
needs: [pre-ci, prime-cache, check-pretty]
101149
runs-on: ubuntu-latest
102150
if: needs.pre-ci.outputs.should-build-be == 'true'
103151
steps:
@@ -123,9 +171,6 @@ jobs:
123171
- name: Install dependencies
124172
run: npm install --prefer-offline --no-audit
125173

126-
- name: Check pretty
127-
run: npm run pretty-code-be
128-
129174
- name: Check lint
130175
run: npm run lint-be
131176

@@ -137,7 +182,7 @@ jobs:
137182

138183
ci-fe:
139184
name: ci-fe
140-
needs: [pre-ci, prime-cache]
185+
needs: [pre-ci, prime-cache, check-pretty]
141186
runs-on: ubuntu-latest
142187
if: needs.pre-ci.outputs.should-build-fe == 'true'
143188
steps:
@@ -167,9 +212,6 @@ jobs:
167212
- name: Install dependencies
168213
run: npm install --prefer-offline --no-audit
169214

170-
- name: Check pretty
171-
run: npm run pretty-code-fe
172-
173215
- name: Check lint
174216
run: npm run lint-fe
175217

@@ -181,7 +223,7 @@ jobs:
181223

182224
ci-assets:
183225
name: ci-assets
184-
needs: [pre-ci, prime-cache]
226+
needs: [pre-ci, prime-cache, check-pretty]
185227
runs-on: ubuntu-latest
186228
if: needs.pre-ci.outputs.assets-json == 'true'
187229
steps:
@@ -221,9 +263,6 @@ jobs:
221263
- name: Install dependencies
222264
run: npm install --prefer-offline --no-audit
223265

224-
- name: Check Pretty
225-
run: npm run pretty-assets-fe
226-
227266
- name: Lint JSON
228267
run: npm run pr-check-lint-json
229268

@@ -241,7 +280,7 @@ jobs:
241280

242281
ci-pkg:
243282
name: ci-pkg
244-
needs: [pre-ci, prime-cache]
283+
needs: [pre-ci, prime-cache,check-pretty]
245284
runs-on: ubuntu-latest
246285
if: needs.pre-ci.outputs.should-build-pkg == 'true'
247286
steps:
@@ -267,9 +306,6 @@ jobs:
267306
- name: Install dependencies
268307
run: npm install --prefer-offline --no-audit
269308

270-
- name: Check pretty
271-
run: npm run pretty-code-pkg
272-
273309
- name: Check lint
274310
run: npm run lint-pkg
275311

package.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@
2929
"release": "release-it -c .release-it.json",
3030
"release-fe": "release-it -c .release-it-fe.json",
3131
"hotfix": "npm run build-fe && cd frontend && npm run deploy-live && cd .. && sh ./bin/purgeCfCache.sh",
32-
"pretty": "prettier --check \"./backend/**/*.{ts,json,js,css,html}\" \"./frontend/**/*.{ts,js,scss}\" \"./packages/**/*.{ts,js,json}\" \"./frontend/static/**/*.{json,html,css}\"",
33-
"pretty-code": "prettier --check \"./backend/**/*.{ts,js,json,css,html}\" \"./frontend/**/*.{ts,js}\" \"./packages/**/*.{ts,js,json}\" \"./frontend/src/**/*.scss\" ",
34-
"pretty-code-be": "prettier --check \"./backend/**/*.{ts,js,json,css,html}\"",
35-
"pretty-code-fe": "prettier --check \"./frontend/**/*.{ts,js}\" \"./frontend/src/**/*.scss\"",
36-
"pretty-assets-fe": "prettier --check \"./frontend/static/**/*.json\"",
37-
"pretty-code-pkg": "prettier --check \"./packages/**/*.{ts,js}\"",
38-
"pretty-fix": "prettier --write \"./backend/**/*.{ts,json,js,css,html}\" \"./frontend/**/*.{ts,js,scss}\" \"./packages/**/*.{ts,js,json}\" \"./frontend/static/**/*.{json,html,css}\"",
32+
"pretty-check": "prettier --check .",
33+
"pretty-check-be": "prettier --check ./backend",
34+
"pretty-check-fe": "prettier --check ./frontend/src",
35+
"pretty-check-assets": "prettier --check ./frontend/static",
36+
"pretty-check-pkg": "prettier --check ./packages",
37+
"pretty-fix": "prettier --write .",
38+
"pretty-fix-be": "prettier --write ./backend",
39+
"pretty-fix-fe": "prettier --write ./frontend/src",
40+
"pretty-fix-assets": "prettier --write ./frontend/static",
41+
"pretty-fix-pkg": "prettier --write ./packages",
3942
"pr-check-lint-json": "cd frontend && eslint './static/**/*.json'",
4043
"pr-check-quote-json": "cd frontend && npx gulp pr-check-quote-json",
4144
"pr-check-language-json": "cd frontend && npx gulp pr-check-language-json",

0 commit comments

Comments
 (0)