diff --git a/frontend/.github/workflows/frontend-jobs.yml b/frontend/.github/workflows/frontend-jobs.yml new file mode 100644 index 0000000..bc7f621 --- /dev/null +++ b/frontend/.github/workflows/frontend-jobs.yml @@ -0,0 +1,131 @@ +on: + workflow_call: + +jobs: + confirm-frontend-changes: + runs-on: ubuntu-latest + outputs: + frontend: ${{ steps.filter.outputs.frontend }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + frontend: + - 'frontend/**' + + linting-formatting-frontend: + needs: confirm-frontend-changes + if: ${{ needs.scan-frontend-changes.outputs.frontend == 'true' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version-file: ./frontend/package.json + cache: npm + cache-dependency-path: ./frontend/package-lock.json + - name: Cache node_modules + uses: actions/cache@v4 + id: node-modules-cache + with: + path: | + ./frontend/node_modules + key: modules-${{ hashFiles('./frontend/package-lock.json') }} + - name: Install dependencies + if: steps.node-modules-cache.outputs.cache-hit != 'true' + run: | + npm ci + working-directory: ./frontend + - name: Linting + run: npm run style:check + working-directory: ./frontend + - name: Formatting + run: npm run format:check + working-directory: ./frontend + - name: Send status to Slack + # Third-party action, pin to commit SHA! + # See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions + uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0 + if: ${{ failure() && github.ref == 'refs/heads/main' }} + with: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + + unit-tests-frontend: + needs: confirm-frontend-changes + if: ${{ needs.scan-frontend-changes.outputs.frontend == 'true' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version-file: ./frontend/package.json + cache: npm + cache-dependency-path: ./frontend/package-lock.json + - name: Cache node_modules + uses: actions/cache@v4 + id: node-modules-cache + with: + path: | + ./frontend/node_modules + key: modules-${{ hashFiles('./frontend/package-lock.json') }} + - name: Install dependencies + if: steps.node-modules-cache.outputs.cache-hit != 'true' + run: | + npm ci + working-directory: ./frontend + - name: Unit tests + run: | + npm run test:unit + working-directory: ./frontend + # TODO: enable later + # + # - name: Send status to Slack + # # Third-party action, pin to commit SHA! + # # See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions + # uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0 + # if: ${{ failure() && github.ref == 'refs/heads/main' }} + # with: + # SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + + e2e-tests-frontend: + needs: confirm-frontend-changes + if: ${{ needs.scan-frontend-changes.outputs.frontend == 'true' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version-file: ./frontend/package.json + cache: npm + cache-dependency-path: ./frontend/package-lock.json + - name: Cache node_modules + uses: actions/cache@v4 + id: node-modules-cache + with: + path: | + ./frontend/node_modules + key: modules-${{ hashFiles('./frontend/package-lock.json') }} + - name: Install dependencies + if: steps.node-modules-cache.outputs.cache-hit != 'true' + run: | + npm ci + working-directory: ./frontend + - name: Unit tests + run: | + npm run test:e2e + working-directory: ./frontend + # TODO: enable later + # + # - name: Send status to Slack + # # Third-party action, pin to commit SHA! + # # See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions + # uses: digitalservicebund/notify-on-failure-gha@814d0c4b2ad6a3443e89c991f8657b10126510bf # v1.5.0 + # if: ${{ failure() && github.ref == 'refs/heads/main' }} + # with: + # SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} +#TODO sonar analysis diff --git a/frontend/.github/workflows/pipeline.yml b/frontend/.github/workflows/pipeline.yml new file mode 100644 index 0000000..d71e819 --- /dev/null +++ b/frontend/.github/workflows/pipeline.yml @@ -0,0 +1,16 @@ +name: "CI Pipeline" + +on: + push: + branches: [main] + paths-ignore: + - "**/*.md" + pull_request: + branches: [main] + # Allow to run this workflow manually + workflow_dispatch: + +jobs: + frontend-checks: + uses: ./.github/workflows/frontend-jobs.yml + secrets: inherit diff --git a/frontend/package.json b/frontend/package.json index e19d470..c8f43b0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -12,7 +12,9 @@ "build-only": "vite build", "type-check": "vue-tsc --build", "lint": "eslint . --fix", - "format": "prettier --write src/" + "lint:check": "eslint .", + "format": "prettier --write src/", + "format:check": "prettier --check src/" }, "dependencies": { "pinia": "^2.2.6", @@ -43,4 +45,4 @@ "vitest": "^2.1.5", "vue-tsc": "^2.1.10" } -} +} \ No newline at end of file