Skip to content

Commit

Permalink
Merge pull request #3 from digitalservicebund/RISDEV-5816-add-continu…
Browse files Browse the repository at this point in the history
…ous-integration

Setup Continuous Integration
  • Loading branch information
hannes-mk authored Dec 13, 2024
2 parents 514b3b3 + b95bb6f commit 55ff029
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 2 deletions.
131 changes: 131 additions & 0 deletions frontend/.github/workflows/frontend-jobs.yml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions frontend/.github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -43,4 +45,4 @@
"vitest": "^2.1.5",
"vue-tsc": "^2.1.10"
}
}
}

0 comments on commit 55ff029

Please sign in to comment.