generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (102 loc) · 4.01 KB
/
analysis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Analysis
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review, converted_to_draft]
push:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tests-backend:
name: Tests (Backend)
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-latest
steps:
- uses: bcgov-nr/action-test-and-analyse-java@v1.0.2
with:
commands: mvn --no-transfer-progress clean compile verify package checkstyle:checkstyle -P all-tests
dir: backend
java-cache: maven
java-distribution: temurin
java-version: 21
sonar_args: >
-Dsonar.exclusions=**/configuration/**,**/dto/**,**/entity/**,**/exception/**,**/job/**,**/*$*Builder*,**/ResultsApplication.*,**/*Constants.*,
-Dsonar.coverage.jacoco.xmlReportPaths=target/coverage-reports/merged-test-report/jacoco.xml
-Dsonar.organization=bcgov-sonarcloud
-Dsonar.project.monorepo.enabled=true
-Dsonar.projectKey=nr-silva-backend
sonar_token: ${{ secrets.SONAR_TOKEN_BACKEND }}
# Only use triggers for PRs
triggers: ${{ github.event_name == 'pull_request' && '("backend/")' || '' }}
lint-frontend:
name: Lint (Frontend)
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-latest
steps:
- uses: bcgov-nr/action-test-and-analyse@v1.2.1
with:
commands: |
npm ci
npm run lint || true
dir: frontend
node_version: "20"
# Only use triggers for PRs
triggers: ${{ github.event_name == 'pull_request' && '("frontend/")' || '' }}
tests-frontend:
name: Tests (Frontend)
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-latest
steps:
- uses: bcgov-nr/action-test-and-analyse@v1.2.1
env:
VITE_ZONE: test
VITE_USER_POOLS_ID: ca-central-1_abc123
VITE_USER_POOLS_WEB_CLIENT_ID: abc123
VITE_BACKEND_URL: http://localhost:8080
with:
commands: |
npm ci
npm run test:coverage
dir: frontend
node_version: "20"
sonar_args: >
-Dsonar.organization=bcgov-sonarcloud
-Dsonar.projectKey=nr-silva-frontend
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
-Dsonar.typescript.tsconfigPaths=tsconfig.json
-Dsonar.sources=src/
-Dsonar.exclusions=src/__test__/**,src/amplifyconfiguration.*,src/**/*.scss,src/**/*.css,src/**/*.d.*,src/setupTests.*
-Dsonar.tests=src/__test__/
-Dsonar.project.monorepo.enabled=true
sonar_token: ${{ secrets.SONAR_TOKEN_FRONTEND }}
# Only use triggers for PRs
triggers: ${{ github.event_name == 'pull_request' && '("frontend/")' || '' }}
# https://github.com/marketplace/actions/aqua-security-trivy
trivy:
name: Trivy Security Scan
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@0.28.0
with:
format: "sarif"
output: "trivy-results.sarif"
ignore-unfixed: true
scan-type: "fs"
scanners: "vuln,secret,config"
severity: "CRITICAL,HIGH"
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: "trivy-results.sarif"
results:
name: Analysis Results
if: always() && (!failure()) && (!cancelled())
needs: [lint-frontend, tests-backend, tests-frontend] # Include trivy when/if it gets back to being reliable
runs-on: ubuntu-latest
steps:
- run: echo "Workflow completed successfully!"