From 7f63cf87740ae741b826ef9b1de4e15f1fc45385 Mon Sep 17 00:00:00 2001 From: Filip Niklas Date: Sat, 7 Dec 2024 17:34:31 +0100 Subject: [PATCH 01/10] test fetch depth --- .github/workflows/verify_formatting.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/verify_formatting.yaml b/.github/workflows/verify_formatting.yaml index d907e42..70e8d2f 100644 --- a/.github/workflows/verify_formatting.yaml +++ b/.github/workflows/verify_formatting.yaml @@ -15,6 +15,8 @@ jobs: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Set up Node.js uses: actions/setup-node@v4 From 8b6d6aca2d32809a340db5fa9107300ef3ca22d5 Mon Sep 17 00:00:00 2001 From: Filip Niklas Date: Sat, 7 Dec 2024 17:37:57 +0100 Subject: [PATCH 02/10] try different prettier cmdns --- .github/workflows/verify_formatting.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify_formatting.yaml b/.github/workflows/verify_formatting.yaml index 70e8d2f..c1ccbc9 100644 --- a/.github/workflows/verify_formatting.yaml +++ b/.github/workflows/verify_formatting.yaml @@ -30,7 +30,7 @@ jobs: - name: Check formatting run: | - npx --yes prettier@$PRETTIER_VERSION --check --config .prettierrc . + npx --yes prettier@$PRETTIER_VERSION . --check --config .prettierrc --list-different - name: Fail if formatting check failed if: failure() From c8a1734a377c0fa4f29f5ab09b6c93be6df20326 Mon Sep 17 00:00:00 2001 From: Filip Niklas Date: Sat, 7 Dec 2024 17:39:01 +0100 Subject: [PATCH 03/10] remove conflict cmnd --- .github/workflows/verify_formatting.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify_formatting.yaml b/.github/workflows/verify_formatting.yaml index c1ccbc9..9c4e329 100644 --- a/.github/workflows/verify_formatting.yaml +++ b/.github/workflows/verify_formatting.yaml @@ -30,7 +30,7 @@ jobs: - name: Check formatting run: | - npx --yes prettier@$PRETTIER_VERSION . --check --config .prettierrc --list-different + npx --yes prettier@$PRETTIER_VERSION . --config .prettierrc --list-different - name: Fail if formatting check failed if: failure() From df12509939eaeabf5158b649a731fc0a8cb458c0 Mon Sep 17 00:00:00 2001 From: Filip Niklas Date: Sat, 7 Dec 2024 17:41:23 +0100 Subject: [PATCH 04/10] bump node --- .github/workflows/verify_formatting.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/verify_formatting.yaml b/.github/workflows/verify_formatting.yaml index 9c4e329..1f04cb7 100644 --- a/.github/workflows/verify_formatting.yaml +++ b/.github/workflows/verify_formatting.yaml @@ -15,13 +15,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 22 - name: Get Prettier version from package-lock.json run: | From cd7bd83f83e02c68092099968db6320e3557970c Mon Sep 17 00:00:00 2001 From: Filip Niklas Date: Sat, 7 Dec 2024 17:45:25 +0100 Subject: [PATCH 05/10] debug --- .github/workflows/verify_formatting.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/verify_formatting.yaml b/.github/workflows/verify_formatting.yaml index 1f04cb7..af5c606 100644 --- a/.github/workflows/verify_formatting.yaml +++ b/.github/workflows/verify_formatting.yaml @@ -26,6 +26,11 @@ jobs: PRETTIER_VERSION=$(grep -m 1 'prettier' package-lock.json | cut -d '"' -f 4 | cut -c 2-) echo $PRETTIER_VERSION + - name: Format and Commit + run: | + npx prettier --write --config .prettierrc . + git diff + - name: Check formatting run: | npx --yes prettier@$PRETTIER_VERSION . --config .prettierrc --list-different From ac762f4fb80d7c4715b4b2b6b50b43af70cd089f Mon Sep 17 00:00:00 2001 From: Filip Niklas Date: Sat, 7 Dec 2024 17:47:52 +0100 Subject: [PATCH 06/10] remove config from prettier cmd --- .github/workflows/verify_formatting.yaml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/verify_formatting.yaml b/.github/workflows/verify_formatting.yaml index af5c606..cd33585 100644 --- a/.github/workflows/verify_formatting.yaml +++ b/.github/workflows/verify_formatting.yaml @@ -26,14 +26,9 @@ jobs: PRETTIER_VERSION=$(grep -m 1 'prettier' package-lock.json | cut -d '"' -f 4 | cut -c 2-) echo $PRETTIER_VERSION - - name: Format and Commit - run: | - npx prettier --write --config .prettierrc . - git diff - - name: Check formatting run: | - npx --yes prettier@$PRETTIER_VERSION . --config .prettierrc --list-different + npx --yes prettier@$PRETTIER_VERSION . --check - name: Fail if formatting check failed if: failure() From 1da5c3422e67bcbb75a22a14c77ae7afa9b42feb Mon Sep 17 00:00:00 2001 From: Filip Niklas Date: Sat, 7 Dec 2024 17:53:16 +0100 Subject: [PATCH 07/10] try explicit config --- .github/workflows/verify_formatting.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify_formatting.yaml b/.github/workflows/verify_formatting.yaml index cd33585..8211405 100644 --- a/.github/workflows/verify_formatting.yaml +++ b/.github/workflows/verify_formatting.yaml @@ -28,7 +28,7 @@ jobs: - name: Check formatting run: | - npx --yes prettier@$PRETTIER_VERSION . --check + npx --yes prettier@$PRETTIER_VERSION . --check --config ./.prettierrc - name: Fail if formatting check failed if: failure() From 846d1ab0715bdb1c7d6b6dfd4702f11b0cd1ead0 Mon Sep 17 00:00:00 2001 From: Filip Niklas Date: Sat, 7 Dec 2024 18:04:23 +0100 Subject: [PATCH 08/10] try scripted --- .github/workflows/verify_formatting.yaml | 17 ++++++++++++----- package.json | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/verify_formatting.yaml b/.github/workflows/verify_formatting.yaml index 8211405..7917517 100644 --- a/.github/workflows/verify_formatting.yaml +++ b/.github/workflows/verify_formatting.yaml @@ -21,14 +21,21 @@ jobs: with: node-version: 22 - - name: Get Prettier version from package-lock.json - run: | - PRETTIER_VERSION=$(grep -m 1 'prettier' package-lock.json | cut -d '"' -f 4 | cut -c 2-) - echo $PRETTIER_VERSION + - name: Install dependencies + run: npm install - name: Check formatting run: | - npx --yes prettier@$PRETTIER_VERSION . --check --config ./.prettierrc + npm run prettier:check + + # - name: Get Prettier version from package-lock.json + # run: | + # PRETTIER_VERSION=$(grep -m 1 'prettier' package-lock.json | cut -d '"' -f 4 | cut -c 2-) + # echo $PRETTIER_VERSION + + # - name: Check formatting + # run: | + # npx --yes prettier@$PRETTIER_VERSION . --check --config ./.prettierrc - name: Fail if formatting check failed if: failure() diff --git a/package.json b/package.json index afe63cb..baccdb6 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "build": "next build", "start": "next start", "lint": "next lint", + "prettier:check": "npx prettier --check .", "postbuild": "pagefind --site .next/standalone/.next/server/app/articles --output-path public/_pagefind", "stripe:listen": "stripe listen --forward-to 127.0.0.1:3000/api/stripe-webhook", "db:regen": "npx prisma generate", From 8dfc8e04362dfbd7b19b78a6712b0e0c4de11e44 Mon Sep 17 00:00:00 2001 From: Filip Niklas Date: Sat, 7 Dec 2024 18:06:48 +0100 Subject: [PATCH 09/10] only install prettier --- .github/workflows/verify_formatting.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/verify_formatting.yaml b/.github/workflows/verify_formatting.yaml index 7917517..151bd64 100644 --- a/.github/workflows/verify_formatting.yaml +++ b/.github/workflows/verify_formatting.yaml @@ -19,10 +19,10 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 20 - name: Install dependencies - run: npm install + run: npm install -g prettier - name: Check formatting run: | From 3bd51690ad93de74a519f5ef2a78251100abd78c Mon Sep 17 00:00:00 2001 From: Filip Niklas Date: Sat, 7 Dec 2024 18:10:17 +0100 Subject: [PATCH 10/10] chore: restore ci install --- .github/workflows/verify_formatting.yaml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/verify_formatting.yaml b/.github/workflows/verify_formatting.yaml index 151bd64..82a3c8e 100644 --- a/.github/workflows/verify_formatting.yaml +++ b/.github/workflows/verify_formatting.yaml @@ -21,22 +21,15 @@ jobs: with: node-version: 20 + # This installs all dependencies, but if we use "npm install -g prettier", + # then prettier won't pick up the project's .prettierrc file. - name: Install dependencies - run: npm install -g prettier + run: npm ci - name: Check formatting run: | npm run prettier:check - # - name: Get Prettier version from package-lock.json - # run: | - # PRETTIER_VERSION=$(grep -m 1 'prettier' package-lock.json | cut -d '"' -f 4 | cut -c 2-) - # echo $PRETTIER_VERSION - - # - name: Check formatting - # run: | - # npx --yes prettier@$PRETTIER_VERSION . --check --config ./.prettierrc - - name: Fail if formatting check failed if: failure() run: |