Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .github/workflows/.unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: .Unit Tests

on:
workflow_call:
secrets:
SONAR_TOKEN_BACKEND:
required: true
SONAR_TOKEN_FRONTEND:
required: true

jobs:
backend-tests:
name: Backend
runs-on: ubuntu-24.04
timeout-minutes: 5
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: default
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v6
- uses: bcgov/action-test-and-analyse@v2
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BACKEND }}
with:
commands: |
npm ci
npm run lint
npm run test:cov
dir: backend
node_version: "22"
sonar_args: >
-Dsonar.exclusions=**/coverage/**,**/node_modules/**,**/*spec.ts
-Dsonar.organization=bcgov-sonarcloud
-Dsonar.projectKey=quickstart-openshift_backend
-Dsonar.sources=src
-Dsonar.test.inclusions=**/*spec.ts
-Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
sonar_token: ${{ env.SONAR_TOKEN }}
dep_scan: warning
supply_scan: true
triggers: ('backend/')

frontend-tests:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Comment on lines +13 to +52
name: Frontend
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
- uses: bcgov/action-test-and-analyse@v2
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_FRONTEND }}
with:
commands: |
npm ci
npm run lint
npm run test:cov
dir: frontend
node_version: "22"
sonar_args: >-
-Dsonar.exclusions=**/coverage/**,**/node_modules/**,**/*spec.ts
-Dsonar.organization=bcgov-sonarcloud
-Dsonar.projectKey=quickstart-openshift_frontend
-Dsonar.sources=src
-Dsonar.test.inclusions=**/*spec.ts
-Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
sonar_token: ${{ env.SONAR_TOKEN }}
dep_scan: warning
supply_scan: true
triggers: ('frontend/')

trivy:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Comment on lines +53 to +80
name: Security
permissions:
security-events: write
runs-on: ubuntu-slim
timeout-minutes: 1
steps:
- uses: actions/checkout@v6
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@v0.35.0
with:
format: "sarif"
output: "trivy-results.sarif"
ignore-unfixed: true
scan-type: "fs"
scanners: "vuln,secret,misconfig"
severity: "CRITICAL,HIGH"
exit-code: "1"
trivy-config: ".github/trivy.yaml"
trivyignores: ".trivyignore"

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: "trivy-results.sarif"
111 changes: 10 additions & 101 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Analysis
on:
push:
branches: [main]
pull_request:
types: [opened, reopened, synchronize, ready_for_review, converted_to_draft]
schedule:
- cron: "0 11 * * 0" # 3 AM PST = 12 PM UDT, runs sundays
workflow_dispatch:
Expand All @@ -16,108 +14,19 @@ concurrency:
permissions: {}

jobs:
backend-tests:
name: Backend Tests
if: (! github.event.pull_request.draft)
runs-on: ubuntu-24.04
timeout-minutes: 5
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: default
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: bcgov/action-test-and-analyse@8f699e3fd3fadd9a6adf6f4b1f2638ef7ecfefb9 # v2.0.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BACKEND }}
with:
commands: |
npm ci
npm run lint
npm run test:cov
dir: backend
node_version: "22"
sonar_args: >
-Dsonar.exclusions=**/coverage/**,**/node_modules/**,**/*spec.ts
-Dsonar.organization=bcgov-sonarcloud
-Dsonar.projectKey=quickstart-openshift_backend
-Dsonar.sources=src
-Dsonar.test.inclusions=**/*spec.ts
-Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
sonar_token: ${{ env.SONAR_TOKEN }}
dep_scan: warning
supply_scan: true
triggers: ('backend/')

frontend-tests:
name: Frontend Tests
if: (! github.event.pull_request.draft)
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- uses: bcgov/action-test-and-analyse@8f699e3fd3fadd9a6adf6f4b1f2638ef7ecfefb9 # v2.0.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_FRONTEND }}
with:
commands: |
npm ci
npm run lint
npm run test:cov
dir: frontend
node_version: "22"
sonar_args: >
-Dsonar.exclusions=**/coverage/**,**/node_modules/**,**/*spec.ts
-Dsonar.organization=bcgov-sonarcloud
-Dsonar.projectKey=quickstart-openshift_frontend
-Dsonar.sources=src
-Dsonar.test.inclusions=**/*spec.ts
-Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
sonar_token: ${{ env.SONAR_TOKEN }}
dep_scan: warning
supply_scan: true
triggers: ('frontend/')

# https://github.com/marketplace/actions/aqua-security-trivy
trivy:
name: Trivy Security Scan
if: (! github.event.pull_request.draft)
continue-on-error: true
permissions:
security-events: write
runs-on: ubuntu-slim
timeout-minutes: 1
steps:
- uses: actions/checkout@v6
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # 0.35.0
with:
format: "sarif"
output: "trivy-results.sarif"
ignore-unfixed: true
scan-type: "fs"
scanners: "vuln,secret,misconfig"
severity: "CRITICAL,HIGH"
trivy-config: ".github/trivy.yaml"
trivyignores: ".trivyignore"

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: "trivy-results.sarif"
unit-tests:
name: Unit Tests
uses: ./.github/workflows/.unit-tests.yml
secrets:
SONAR_TOKEN_BACKEND: ${{ secrets.SONAR_TOKEN_BACKEND }}
SONAR_TOKEN_FRONTEND: ${{ secrets.SONAR_TOKEN_FRONTEND }}

results:
name: Analysis Results
needs: [backend-tests, frontend-tests]
if: (! github.event.pull_request.draft)
needs: [unit-tests]
if: always()
runs-on: ubuntu-slim
steps:
- if: contains(needs.*.result, 'failure')||contains(needs.*.result, 'canceled')
run: echo "At least one job has failed." && exit 1
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'canceled')
run: exit 1
- run: echo "Success!"
14 changes: 11 additions & 3 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,20 @@ jobs:
needs: [deploys]
uses: ./.github/workflows/.tests.yml

unit-tests:
name: Unit Tests
if: (! github.event.pull_request.draft)
uses: ./.github/workflows/.unit-tests.yml
secrets:
SONAR_TOKEN_BACKEND: ${{ secrets.SONAR_TOKEN_BACKEND }}
SONAR_TOKEN_FRONTEND: ${{ secrets.SONAR_TOKEN_FRONTEND }}

results:
name: PR Results
needs: [builds, deploys, tests]
needs: [builds, deploys, tests, unit-tests]
Comment on lines +59 to +63
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Postgres service uses the floating postgres image tag, which can change over time (including major-version upgrades) and make CI behavior non-deterministic. Pin the image to a specific major/minor (e.g., postgres:16 or similar) to keep PR test runs reproducible.

Copilot uses AI. Check for mistakes.
if: always()
runs-on: ubuntu-slim
steps:
- if: contains(needs.*.result, 'failure')||contains(needs.*.result, 'canceled')
run: echo "At least one job has failed." && exit 1
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'canceled')
run: exit 1
- run: echo "Success!"
Loading