From 6554f0b2a9887538d60bb3de2c0c19cafe2ab34c Mon Sep 17 00:00:00 2001 From: Jack Date: Sun, 28 Jul 2024 14:15:11 +0200 Subject: [PATCH] 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 Co-authored-by: George The Bot --- .github/workflows/monkey-ci.yml | 68 +++++++++++++++++++++++++-------- package.json | 17 +++++---- 2 files changed, 62 insertions(+), 23 deletions(-) diff --git a/.github/workflows/monkey-ci.yml b/.github/workflows/monkey-ci.yml index 0787d953c..9f2365d59 100644 --- a/.github/workflows/monkey-ci.yml +++ b/.github/workflows/monkey-ci.yml @@ -95,9 +95,57 @@ jobs: name: Install dependencies run: npm install --prefer-offline --no-audit + check-pretty: + name: check-pretty + needs: [pre-ci, prime-cache] + runs-on: ubuntu-latest + 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' + steps: + - uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Cache node modules + id: cache-npm + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + 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 install --prefer-offline --no-audit + + - name: Check pretty (backend) + id: check-pretty-be + if: needs.pre-ci.outputs.should-build-be == 'true' + run: npm run pretty-check-be + + - name: Check pretty (frontend) + id: check-pretty-fe + if: needs.pre-ci.outputs.should-build-fe == 'true' + run: npm run pretty-check-fe + + - name: Check pretty (packages) + id: check-pretty-pkg + if: needs.pre-ci.outputs.should-build-pkg == 'true' + run: npm run pretty-check-pkg + + - name: Check pretty (assets) + id: check-pretty-assets + if: needs.pre-ci.outputs.assets-json == 'true' + run: npm run pretty-check-assets + ci-be: name: ci-be - needs: [pre-ci, prime-cache] + needs: [pre-ci, prime-cache, check-pretty] runs-on: ubuntu-latest if: needs.pre-ci.outputs.should-build-be == 'true' steps: @@ -123,9 +171,6 @@ jobs: - name: Install dependencies run: npm install --prefer-offline --no-audit - - name: Check pretty - run: npm run pretty-code-be - - name: Check lint run: npm run lint-be @@ -137,7 +182,7 @@ jobs: ci-fe: name: ci-fe - needs: [pre-ci, prime-cache] + needs: [pre-ci, prime-cache, check-pretty] runs-on: ubuntu-latest if: needs.pre-ci.outputs.should-build-fe == 'true' steps: @@ -167,9 +212,6 @@ jobs: - name: Install dependencies run: npm install --prefer-offline --no-audit - - name: Check pretty - run: npm run pretty-code-fe - - name: Check lint run: npm run lint-fe @@ -181,7 +223,7 @@ jobs: ci-assets: name: ci-assets - needs: [pre-ci, prime-cache] + needs: [pre-ci, prime-cache, check-pretty] runs-on: ubuntu-latest if: needs.pre-ci.outputs.assets-json == 'true' steps: @@ -221,9 +263,6 @@ jobs: - name: Install dependencies run: npm install --prefer-offline --no-audit - - name: Check Pretty - run: npm run pretty-assets-fe - - name: Lint JSON run: npm run pr-check-lint-json @@ -241,7 +280,7 @@ jobs: ci-pkg: name: ci-pkg - needs: [pre-ci, prime-cache] + needs: [pre-ci, prime-cache,check-pretty] runs-on: ubuntu-latest if: needs.pre-ci.outputs.should-build-pkg == 'true' steps: @@ -267,9 +306,6 @@ jobs: - name: Install dependencies run: npm install --prefer-offline --no-audit - - name: Check pretty - run: npm run pretty-code-pkg - - name: Check lint run: npm run lint-pkg diff --git a/package.json b/package.json index 192d46f7a..bf78d8e5d 100644 --- a/package.json +++ b/package.json @@ -29,13 +29,16 @@ "release": "release-it -c .release-it.json", "release-fe": "release-it -c .release-it-fe.json", "hotfix": "npm run build-fe && cd frontend && npm run deploy-live && cd .. && sh ./bin/purgeCfCache.sh", - "pretty": "prettier --check \"./backend/**/*.{ts,json,js,css,html}\" \"./frontend/**/*.{ts,js,scss}\" \"./packages/**/*.{ts,js,json}\" \"./frontend/static/**/*.{json,html,css}\"", - "pretty-code": "prettier --check \"./backend/**/*.{ts,js,json,css,html}\" \"./frontend/**/*.{ts,js}\" \"./packages/**/*.{ts,js,json}\" \"./frontend/src/**/*.scss\" ", - "pretty-code-be": "prettier --check \"./backend/**/*.{ts,js,json,css,html}\"", - "pretty-code-fe": "prettier --check \"./frontend/**/*.{ts,js}\" \"./frontend/src/**/*.scss\"", - "pretty-assets-fe": "prettier --check \"./frontend/static/**/*.json\"", - "pretty-code-pkg": "prettier --check \"./packages/**/*.{ts,js}\"", - "pretty-fix": "prettier --write \"./backend/**/*.{ts,json,js,css,html}\" \"./frontend/**/*.{ts,js,scss}\" \"./packages/**/*.{ts,js,json}\" \"./frontend/static/**/*.{json,html,css}\"", + "pretty-check": "prettier --check .", + "pretty-check-be": "prettier --check ./backend", + "pretty-check-fe": "prettier --check ./frontend/src", + "pretty-check-assets": "prettier --check ./frontend/static", + "pretty-check-pkg": "prettier --check ./packages", + "pretty-fix": "prettier --write .", + "pretty-fix-be": "prettier --write ./backend", + "pretty-fix-fe": "prettier --write ./frontend/src", + "pretty-fix-assets": "prettier --write ./frontend/static", + "pretty-fix-pkg": "prettier --write ./packages", "pr-check-lint-json": "cd frontend && eslint './static/**/*.json'", "pr-check-quote-json": "cd frontend && npx gulp pr-check-quote-json", "pr-check-language-json": "cd frontend && npx gulp pr-check-language-json",