diff --git a/.github/workflows/code_check_frontend.yml b/.github/workflows/code_check_frontend.yml new file mode 100644 index 000000000..eaa943dae --- /dev/null +++ b/.github/workflows/code_check_frontend.yml @@ -0,0 +1,78 @@ +name: Frontend Test, Lint & Type Check + +on: + push: + paths: + - govtool/frontend/** + - .github/workflows/test_frontend.yml + +defaults: + run: + working-directory: govtool/frontend + +jobs: + test: + 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: ๐Ÿงช Test + run: | + npm install + npm run test + + 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 + + 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 tsc diff --git a/.github/workflows/test_frontend.yml b/.github/workflows/test_frontend.yml deleted file mode 100644 index a98de2266..000000000 --- a/.github/workflows/test_frontend.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Frontend Test - -on: - push: - paths: - - govtool/frontend/** - - .github/workflows/test_frontend.yml - -jobs: - test: - 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: Run Frontend Test - working-directory: govtool/frontend - run: | - npm install - npm run test 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..e2eba5500 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": "npx tsc --noEmit --skipLibCheck", "preview": "vite preview", "storybook": "storybook dev -p 6006", "build-storybook": "storybook build",