Skip to content

Commit

Permalink
ci: set up testing (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekRoberts authored Nov 20, 2024
1 parent 8706294 commit 37e0f0e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 28 deletions.
56 changes: 28 additions & 28 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,34 @@ concurrency:
cancel-in-progress: true

jobs:
# tests:
# name: Unit Tests
# if: github.event_name != 'pull_request' || !github.event.pull_request.draft
# runs-on: ubuntu-24.04
# strategy:
# matrix:
# dir: [backend]
# include:
# - dir: backend
# sonar_projectKey: bcgov_nr-fam-idim-lookup-proxy
# token: SONAR_TOKEN
# steps:
# - uses: bcgov-nr/[email protected]
# with:
# commands: |
# npm ci
# npm run test:cov
# dir: ${{ matrix.dir }}
# node_version: "20"
# sonar_args: >
# -Dsonar.exclusions=**/coverage/**,**/node_modules/**,**/*spec.ts
# -Dsonar.organization=bcgov-sonarcloud
# -Dsonar.project.monorepo.enabled=true
# -Dsonar.projectKey=${{ matrix.sonar_projectKey }}
# -Dsonar.sources=src
# -Dsonar.tests.inclusions=**/*spec.ts
# -Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
# sonar_project_token: ${{ secrets[matrix.token] }}
tests:
name: Unit Tests
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-24.04
strategy:
matrix:
dir: [backend]
include:
- dir: backend
sonar_projectKey: bcgov_nr-fam-idim-lookup-proxy
token: SONAR_TOKEN
steps:
- uses: bcgov-nr/[email protected]
with:
commands: |
npm ci
npm run test:cov
dir: ${{ matrix.dir }}
node_version: "20"
sonar_args: >
-Dsonar.exclusions=**/coverage/**,**/node_modules/**,**/*spec.ts
-Dsonar.organization=bcgov-sonarcloud
-Dsonar.project.monorepo.enabled=true
-Dsonar.projectKey=${{ matrix.sonar_projectKey }}
-Dsonar.sources=src
-Dsonar.tests.inclusions=**/*spec.ts
-Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
sonar_project_token: ${{ secrets[matrix.token] }}

# https://github.com/marketplace/actions/aqua-security-trivy
trivy:
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ services:
volumes: ["./backend:/app:z", "/app/node_modules"]
<<: *common

# Local test - docker compose up dev
test:
profiles: ["test"]
entrypoint: ["sh", "-c", "npm i && npm run test"]
image: node:18
volumes: ["./backend:/app:z", "/app/node_modules"]
<<: *common

# Container/deploy - docker compose up deploy
deploy:
profiles: ["deploy"]
Expand Down

0 comments on commit 37e0f0e

Please sign in to comment.