fix: pr close workflow #396
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Analysis | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize, ready_for_review] | |
push: | |
branches: [main] | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
frontend: | |
name: Frontend Tests | |
if: github.event_name != 'pull_request' || !github.event.pull_request.draft | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: bcgov-nr/action-test-and-analyse@v1.1.0 | |
with: | |
commands: | | |
npm ci | |
npm run test:coverage | |
dir: frontend | |
node_version: "20" | |
sonar_args: > | |
-Dsonar.exclusions=**/coverage/**,**/node_modules/**,**/*spec.ts | |
-Dsonar.organization=bcgov-sonarcloud | |
-Dsonar.project.monorepo.enabled=true | |
-Dsonar.projectKey=nr-silva-frontend | |
-Dsonar.sources=src | |
-Dsonar.tests.inclusions=**/*spec.ts | |
-Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info | |
sonar_token: ${{ secrets.SONAR_TOKEN_FRONTEND }} | |
# Only use triggers for PRs | |
triggers: ${{ github.event_name == 'pull_request' && '("frontend/")' || '' }} | |
backend: | |
name: Backend Tests | |
if: github.event_name != 'pull_request' || !github.event.pull_request.draft | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: bcgov-nr/action-test-and-analyse-java@v1.0.0 | |
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=**/config/**,*/dto/**,**/entity/**,**/exception/**,**/response/**,**/*$*Builder*,**/RestExceptionEndpoint.*,**/ResultsApplication.* | |
-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/")' || '' }} | |
codeql: | |
name: CodeQL | |
if: github.event_name != 'pull_request' || !github.event.pull_request.draft | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
language: [java, javascript] | |
include: | |
- language: "java" | |
working-directory: backend | |
build: ./mvnw package -DskipTests | |
- language: "javascript" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: github/codeql-action/init@v3 | |
with: | |
languages: ${{ matrix.language }} | |
- name: Autobuild | |
if: ${{ ! matrix.build }} | |
uses: github/codeql-action/autobuild@v3 | |
- uses: actions/setup-java@v4 | |
if: ${{ matrix.build && matrix.language == 'java' }} | |
with: | |
distribution: "oracle" | |
java-version: "21" | |
- uses: actions/cache@v3 | |
if: ${{ matrix.build && matrix.language == 'java' }} | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Build | |
if: ${{ matrix.build }} | |
run: ${{ matrix.build }} | |
working-directory: ${{ matrix.working-directory }} | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v3 | |
with: | |
category: "/language:${{matrix.language}}" | |
# 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-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run Trivy vulnerability scanner in repo mode | |
uses: aquasecurity/trivy-action@0.16.1 | |
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" |