From 28ef3698b791b78a7cd974d727a91aeceeb520b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Tue, 19 Mar 2024 19:00:20 +0100 Subject: [PATCH 1/5] [#512] chore: add type checking & lint workflow to github actions --- .../workflows/code_style_check_frontend.yml | 37 +++++++++++++++++++ CHANGELOG.md | 1 + govtool/frontend/package.json | 1 + 3 files changed, 39 insertions(+) create mode 100644 .github/workflows/code_style_check_frontend.yml diff --git a/.github/workflows/code_style_check_frontend.yml b/.github/workflows/code_style_check_frontend.yml new file mode 100644 index 000000000..cf4486159 --- /dev/null +++ b/.github/workflows/code_style_check_frontend.yml @@ -0,0 +1,37 @@ +name: Frontend Lint & Type Check + +on: + push: + paths: + - govtool/frontend/** + - .github/workflows/code_check_frontend.yml + +jobs: + code_check: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: govtool/frontend/node_modules + key: ${{ runner.os }}-node-${{ hashFiles('govtool/frontend/package-lock.json') }} + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "18.x" + + - name: Install dependencies + working-directory: govtool/frontend + run: npm install + + - name: Lint + working-directory: govtool/frontend + run: npm run lint + + - name: Type Check + working-directory: govtool/frontend + run: npm run tsc diff --git a/CHANGELOG.md b/CHANGELOG.md index 66f7e2413..7bafec6db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ changes. - Add hash and validation of the metadata [Issue 378](https://github.com/IntersectMBO/govtool/issues/378) - Add githubusercontent.com and ipfs.io to content security policy header [Issue 451](https://github.com/IntersectMBO/govtool/issues/451) - Add frontend test workflow on github actions [Issue 500](https://github.com/IntesectMBO/govtool/issues/500) +- Add type check & lint to github actions [Issue 512](https://github.com/IntesectMBO/govtool/issues/512) ### Added diff --git a/govtool/frontend/package.json b/govtool/frontend/package.json index 8ce160dd4..523792b81 100644 --- a/govtool/frontend/package.json +++ b/govtool/frontend/package.json @@ -7,6 +7,7 @@ "dev": "vite", "build": "vite build", "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "tsc": "tsc --noEmit --skipLibCheck", "preview": "vite preview", "storybook": "storybook dev -p 6006", "build-storybook": "storybook build", From 5dd8ccc4959ffe94f74a4d81685a95ad3a5b82fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Tue, 19 Mar 2024 19:20:38 +0100 Subject: [PATCH 2/5] [#512] chore: join test & code check workflows into one --- ...t_frontend.yml => code_check_frontend.yml} | 15 ++++++-- .../workflows/code_style_check_frontend.yml | 37 ------------------- 2 files changed, 12 insertions(+), 40 deletions(-) rename .github/workflows/{test_frontend.yml => code_check_frontend.yml} (75%) delete mode 100644 .github/workflows/code_style_check_frontend.yml diff --git a/.github/workflows/test_frontend.yml b/.github/workflows/code_check_frontend.yml similarity index 75% rename from .github/workflows/test_frontend.yml rename to .github/workflows/code_check_frontend.yml index a98de2266..c38232d3a 100644 --- a/.github/workflows/test_frontend.yml +++ b/.github/workflows/code_check_frontend.yml @@ -1,4 +1,4 @@ -name: Frontend Test +name: Frontend Test, Lint & Type Check on: push: @@ -6,8 +6,12 @@ on: - govtool/frontend/** - .github/workflows/test_frontend.yml +defaults: + run: + working-directory: govtool/frontend + jobs: - test: + code_check: runs-on: ubuntu-latest steps: - name: Checkout code @@ -25,7 +29,12 @@ jobs: node-version: "18.x" - name: Run Frontend Test - working-directory: govtool/frontend run: | npm install npm run test + + - name: Lint + run: npm run lint + + - name: Type Check + run: npm run tsc diff --git a/.github/workflows/code_style_check_frontend.yml b/.github/workflows/code_style_check_frontend.yml deleted file mode 100644 index cf4486159..000000000 --- a/.github/workflows/code_style_check_frontend.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Frontend Lint & Type Check - -on: - push: - paths: - - govtool/frontend/** - - .github/workflows/code_check_frontend.yml - -jobs: - code_check: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: govtool/frontend/node_modules - key: ${{ runner.os }}-node-${{ hashFiles('govtool/frontend/package-lock.json') }} - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: "18.x" - - - name: Install dependencies - working-directory: govtool/frontend - run: npm install - - - name: Lint - working-directory: govtool/frontend - run: npm run lint - - - name: Type Check - working-directory: govtool/frontend - run: npm run tsc From e3d780532336adbb9b97114df0d99790d55e80f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Tue, 19 Mar 2024 19:23:30 +0100 Subject: [PATCH 3/5] [#512] chore: set .nvmrc as node version source --- .github/workflows/code_check_frontend.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code_check_frontend.yml b/.github/workflows/code_check_frontend.yml index c38232d3a..08a58a085 100644 --- a/.github/workflows/code_check_frontend.yml +++ b/.github/workflows/code_check_frontend.yml @@ -26,7 +26,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: "18.x" + node-version-file: "govtool/frontend/.nvmrc" - name: Run Frontend Test run: | From 0284628246f2c3a76194773825bb7941f8acfcbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Tue, 19 Mar 2024 19:45:46 +0100 Subject: [PATCH 4/5] [#512] chore: split jobs to work in parallel; add emoji to label actions --- .github/workflows/code_check_frontend.yml | 50 ++++++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/.github/workflows/code_check_frontend.yml b/.github/workflows/code_check_frontend.yml index 08a58a085..2a65fa195 100644 --- a/.github/workflows/code_check_frontend.yml +++ b/.github/workflows/code_check_frontend.yml @@ -11,7 +11,7 @@ defaults: working-directory: govtool/frontend jobs: - code_check: + test: runs-on: ubuntu-latest steps: - name: Checkout code @@ -28,13 +28,51 @@ jobs: with: node-version-file: "govtool/frontend/.nvmrc" - - name: Run Frontend Test + - name: ๐Ÿงช Test run: | npm install npm run test - - name: Lint - run: npm run lint + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: govtool/frontend/node_modules + key: ${{ runner.os }}-node-${{ hashFiles('govtool/frontend/package-lock.json') }} + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version-file: "govtool/frontend/.nvmrc" + + - name: ๐Ÿ‘• Lint + run: / + npm install + npm run lint - - name: Type Check - run: npm run tsc + type_check: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: govtool/frontend/node_modules + key: ${{ runner.os }}-node-${{ hashFiles('govtool/frontend/package-lock.json') }} + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version-file: "govtool/frontend/.nvmrc" + + - name: ๐Ÿ” Type Check + run: / + npm install + npm run lint From 7a5d234e8903084f335490aa8b66afd1bab83d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Tue, 19 Mar 2024 19:48:06 +0100 Subject: [PATCH 5/5] [#512] chore: fix tsc execution --- .github/workflows/code_check_frontend.yml | 2 +- govtool/frontend/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code_check_frontend.yml b/.github/workflows/code_check_frontend.yml index 2a65fa195..eaa943dae 100644 --- a/.github/workflows/code_check_frontend.yml +++ b/.github/workflows/code_check_frontend.yml @@ -75,4 +75,4 @@ jobs: - name: ๐Ÿ” Type Check run: / npm install - npm run lint + npm run tsc diff --git a/govtool/frontend/package.json b/govtool/frontend/package.json index 523792b81..e2eba5500 100644 --- a/govtool/frontend/package.json +++ b/govtool/frontend/package.json @@ -7,7 +7,7 @@ "dev": "vite", "build": "vite build", "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", - "tsc": "tsc --noEmit --skipLibCheck", + "tsc": "npx tsc --noEmit --skipLibCheck", "preview": "vite preview", "storybook": "storybook dev -p 6006", "build-storybook": "storybook build",