From b1fdaffa760bdd4e6371e4f95e221d582978ca77 Mon Sep 17 00:00:00 2001 From: Hannes Michalek Date: Fri, 13 Dec 2024 13:58:42 +0100 Subject: [PATCH 1/3] Add pipeline --- frontend/.github/workflows/pipeline.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 frontend/.github/workflows/pipeline.yml diff --git a/frontend/.github/workflows/pipeline.yml b/frontend/.github/workflows/pipeline.yml new file mode 100644 index 0000000..7df0af0 --- /dev/null +++ b/frontend/.github/workflows/pipeline.yml @@ -0,0 +1,11 @@ +name: "CI Pipeline" + +on: + push: + branches: [main] + paths-ignore: + - "**/*.md" + pull_request: + branches: [main] + # Allow to run this workflow manually + workflow_dispatch: From 9cdbb4521fd9faa2a343384a76be373fd7616c48 Mon Sep 17 00:00:00 2001 From: Hannes Michalek Date: Fri, 13 Dec 2024 14:11:42 +0100 Subject: [PATCH 2/3] Run lint, format, unit tests and e2e tests --- frontend/.github/workflows/frontend-jobs.yml | 131 +++++++++++++++++++ frontend/.github/workflows/pipeline.yml | 8 ++ frontend/package.json | 6 +- 3 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 frontend/.github/workflows/frontend-jobs.yml 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 index 7df0af0..4f677c6 100644 --- a/frontend/.github/workflows/pipeline.yml +++ b/frontend/.github/workflows/pipeline.yml @@ -9,3 +9,11 @@ on: branches: [main] # Allow to run this workflow manually workflow_dispatch: + +jobs: + + frontend-checks: + uses: ./.github/workflows/frontend-jobss.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 From b95bb6f4c214e0582781f435ae422255d6e7419e Mon Sep 17 00:00:00 2001 From: Hannes Michalek Date: Fri, 13 Dec 2024 14:16:01 +0100 Subject: [PATCH 3/3] Fix pipeline name --- frontend/.github/workflows/pipeline.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/frontend/.github/workflows/pipeline.yml b/frontend/.github/workflows/pipeline.yml index 4f677c6..d71e819 100644 --- a/frontend/.github/workflows/pipeline.yml +++ b/frontend/.github/workflows/pipeline.yml @@ -11,9 +11,6 @@ on: workflow_dispatch: jobs: - frontend-checks: - uses: ./.github/workflows/frontend-jobss.yml + uses: ./.github/workflows/frontend-jobs.yml secrets: inherit - -