Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/cleanup code ql #1309

Merged
merged 26 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d5f297d
.github/workflows/unit-tests.yml -> .github/workflows/analysis.yml
DerekRoberts Aug 17, 2023
3186e4e
Split off codeql into own job
DerekRoberts Aug 17, 2023
b76daf2
Test
DerekRoberts Sep 2, 2023
3fa353a
Test Go build
DerekRoberts Sep 2, 2023
71b9647
Clip Go toolchain for build
DerekRoberts Sep 2, 2023
1d3899c
Go analysis
DerekRoberts Sep 7, 2023
c9ff2d3
CodeQL Java
DerekRoberts Sep 7, 2023
7d2236a
CodeQL Java - simplify
DerekRoberts Sep 7, 2023
a72772b
CodeQL JavaScript and Python
DerekRoberts Sep 7, 2023
bddbf1f
Move Java into matrix
DerekRoberts Sep 7, 2023
dc27742
Move Java into matrix
DerekRoberts Sep 7, 2023
9cba0ac
Move Java into matrix
DerekRoberts Sep 7, 2023
66198f9
Move Java into matrix
DerekRoberts Sep 7, 2023
5a57fb2
Move Java into matrix
DerekRoberts Sep 7, 2023
11f0d5c
Move Go into matrix
DerekRoberts Sep 7, 2023
88c3c38
Run conditionally
DerekRoberts Sep 7, 2023
8ecb425
Re-enable workflows
DerekRoberts Sep 7, 2023
cf575ce
Workflow events don't like github vars
DerekRoberts Sep 7, 2023
5ce983c
Remove unnecessary matrices
DerekRoberts Sep 7, 2023
87b604d
.github/workflows/analysis.yml -> .github/workflows/tests.yml
DerekRoberts Sep 7, 2023
b7e3d58
.github/workflows/codeql.yml -> .github/workflows/analysis.yml
DerekRoberts Sep 7, 2023
d6e35b6
Move Trivy to Analysis workflow
DerekRoberts Sep 7, 2023
d1148b1
Stagger cronjobs
DerekRoberts Sep 7, 2023
6ec7081
Shorten workflow names
DerekRoberts Sep 7, 2023
490dd30
Restore go.mod
DerekRoberts Sep 7, 2023
7c3b5a3
Restore go.mod
DerekRoberts Sep 7, 2023
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
79 changes: 79 additions & 0 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Analysis

on:
push:
branches: ["main"]
pull_request:
types: ["opened", "reopened", "synchronize", "ready_for_review"]
schedule:
- cron: "0 12 * * 0" # 4 AM PST = 12 PM UDT, runs sundays
workflow_dispatch:

jobs:
CodeQL:
name: CodeQL
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-22.04
strategy:
matrix:
language: ["go", "java", "javascript", "python"]
include:
- language: "go"
working-directory: backend-go
build: |
sed -i '/^toolchain .*$/d' go.mod
go install github.com/swaggo/swag/cmd/swag@latest
CGO_ENABLED=0 GOOS=linux go build -v
- language: "java"
working-directory: backend-java
build: ./mvnw package -Pnative -DskipTests
- language: "javascript"
- language: "python"
steps:
- uses: actions/checkout@v4
- uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Autobuild
if: ${{ ! matrix.build }}
uses: github/codeql-action/autobuild@v2

- uses: actions/setup-java@v3
if: ${{ matrix.build && matrix.language == 'java' }}
with:
distribution: "temurin"
java-version: "17"

- name: Build
if: ${{ matrix.build }}
run: ${{ matrix.build }}
working-directory: ${{ matrix.working-directory }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
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/[email protected]
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@v2
with:
sarif_file: "trivy-results.sarif"
30 changes: 2 additions & 28 deletions .github/workflows/merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,17 @@ name: Merge to Main

on:
workflow_run:
workflows: ["Pull Request Closed"]
types:
- completed
workflows: ["PR Closed"]
types: ["completed"]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

jobs:
codeql:
name: Semantic Code Analysis
runs-on: ubuntu-22.04
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@v4

- name: Initialize
uses: github/codeql-action/init@v2
with:
languages: javascript

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

deploys-test:
name: TEST Deployments
needs:
- codeql
environment: test
runs-on: ubuntu-22.04
strategy:
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/pr-close.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pull Request Closed
name: PR Closed

on:
pull_request:
Expand All @@ -16,7 +16,7 @@ jobs:
# Clean up OpenShift when PR closed, no conditions
cleanup-openshift:
name: Cleanup OpenShift
if: '!github.event.pull_request.head.repo.fork'
if: "!github.event.pull_request.head.repo.fork"
runs-on: ubuntu-22.04
steps:
- name: Remove OpenShift artifacts
Expand All @@ -36,7 +36,18 @@ jobs:
packages: write
strategy:
matrix:
package: [backend, database,database-migrations, frontend, database-migrations-py, backend-py, backend-java, backend-go, database-migrations-go]
package:
[
backend,
database,
database-migrations,
frontend,
database-migrations-py,
backend-py,
backend-java,
backend-go,
database-migrations-go,
]
steps:
- uses: shrink/actions-docker-registry-tag@v3
with:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Pull Request
name: PR

on:
pull_request:
branches:
- main
branches: ["main"]
workflow_dispatch:

concurrency:
# PR open and close use the same group, allowing only one at a time
group: pr-${{ github.workflow }}-${{ github.event.number }}
Expand Down
67 changes: 16 additions & 51 deletions .github/workflows/unit-tests.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
name: Unit Tests and Analysis
name: Tests

on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
types: ["opened", "reopened", "synchronize", "ready_for_review"]
push:
branches:
- main
branches: ["main"]
schedule:
- cron: "0 11 * * 0" # 3 AM PST = 11 PM UDT, runs sundays
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests-java:
name: Quarkus API Unit Tests
java:
name: Java
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-22.04
defaults:
Expand All @@ -38,29 +35,25 @@ jobs:
--health-retries 5
ports:
- 5432:5432
strategy:
matrix:
distribution: ["temurin"]
java-version: ["17"]
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v3
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.java-version }}
distribution: "temurin"
java-version: "17"
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-

- name: Run unit tests
run: mvn -f pom.xml clean package

tests-python:
name: Python API Unit Tests
python:
name: Python
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-22.04
defaults:
Expand All @@ -80,17 +73,12 @@ jobs:
--health-retries 5
ports:
- 5432:5432
strategy:
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: "3.11"

- name: cache poetry install
uses: actions/cache@v3
Expand Down Expand Up @@ -119,8 +107,8 @@ jobs:
run: |
poetry run pytest

tests:
name: Unit Tests
javascript:
name: JavaScript
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-22.04
services:
Expand Down Expand Up @@ -167,26 +155,3 @@ jobs:
-Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
sonar_token: ${{ secrets[matrix.token] }}
triggers: ${{ matrix.triggers }}

# 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/[email protected]
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@v2
with:
sarif_file: "trivy-results.sarif"
2 changes: 1 addition & 1 deletion backend-go/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN go mod download && \
RUN go install github.com/swaggo/swag/cmd/swag@latest
COPY . .
RUN swag init && swag fmt
RUN mkdir -p /workspace/app/target/application
RUN mkdir -p /workspace/app/target/application
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /workspace/app/target/application ./...
HEALTHCHECK --interval=3000s --timeout=30s CMD go version || exit 1

Expand Down
Binary file added backend-go/backend-go
Binary file not shown.