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

Shared CI configurations #13

Merged
merged 76 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
3c57a7a
feat: :construction_worker: Github actions shared
Nov 25, 2024
4bc3449
feat: :construction_worker: Github actions shared
Nov 25, 2024
e81dd10
feat: :construction_worker: Github actions shared
Nov 25, 2024
2b69a24
feat: :construction_worker: Github actions shared
Nov 25, 2024
bece58b
feat: :construction_worker: Github actions shared
Nov 25, 2024
8b0e07a
feat: :construction_worker: Github actions shared
Nov 25, 2024
1698962
feat: :construction_worker: Github actions shared
Nov 25, 2024
b9aa0d9
feat: :construction_worker: Github actions shared
Nov 25, 2024
2d5e21b
fix: :construction_worker: Github actions shared
Nov 25, 2024
2c54a78
fix: :construction_worker: Github actions shared
Nov 25, 2024
6015058
fix: :construction_worker: Github actions shared
Nov 25, 2024
3ab0477
fix: :construction_worker: Github actions shared
Nov 25, 2024
f1967f7
fix: :construction_worker: Github actions shared
Nov 25, 2024
c72158c
fix: :construction_worker: Github actions shared
Nov 25, 2024
fab8c9a
fix: :construction_worker: Github actions shared
Nov 25, 2024
315d366
fix: :construction_worker: Github actions shared
Nov 25, 2024
c67ad83
fix: :construction_worker: Github actions shared
Nov 25, 2024
bc7992b
fix: :construction_worker: Github actions shared
Nov 25, 2024
4332539
fix: :construction_worker: Github actions shared
Nov 25, 2024
5872659
fix: :construction_worker: Github actions shared
Nov 25, 2024
2432068
fix: :construction_worker: Github actions shared
Nov 25, 2024
7cc5415
fix: :construction_worker: Github actions shared
Nov 25, 2024
d509000
fix: :construction_worker: Github actions shared
Nov 25, 2024
543d60e
fix: :construction_worker: Github actions shared
Nov 25, 2024
986c9b3
fix: :construction_worker: Github actions shared
Nov 25, 2024
8f883ff
fix: :construction_worker: Github actions shared
Nov 25, 2024
0b736a9
fix: :construction_worker: Github actions shared
Nov 26, 2024
6c7ce6c
fix: :construction_worker: Github actions shared
Nov 26, 2024
69dc8aa
fix: :construction_worker: Github actions shared
Nov 26, 2024
66eacfd
fix: :construction_worker: Github actions shared
Nov 26, 2024
6f22b8b
fix: :construction_worker: Github actions shared
Nov 26, 2024
807e807
fix: :construction_worker: Github actions shared
Nov 26, 2024
ca88efa
fix: :construction_worker: Github actions shared
Nov 26, 2024
7f9bedf
fix: :construction_worker: Github actions shared
Nov 26, 2024
1e554ce
fix: :construction_worker: Github actions shared
Nov 26, 2024
a5824d2
fix: :construction_worker: Github actions shared
Nov 26, 2024
ccbe7f5
fix: :construction_worker: Github actions shared
Nov 26, 2024
e9808a5
fix: :construction_worker: Github actions shared
Nov 26, 2024
1ed72ff
fix: :construction_worker: Github actions shared
Nov 26, 2024
72da0d9
fix: :construction_worker: Github actions shared
Nov 26, 2024
76dfced
fix: :construction_worker: Github actions shared
Nov 26, 2024
5ee72ad
fix: :construction_worker: Github actions shared
Nov 26, 2024
9732e60
fix: :construction_worker: Github actions shared
Nov 26, 2024
76f65b0
fix: :construction_worker: Github actions shared
Nov 26, 2024
e8fe818
fix: :construction_worker: Github actions shared
Nov 26, 2024
5f7f813
Merge branch 'feature/security' into feature/shared-ci
Nov 26, 2024
6881520
Merge branch 'main' into feature/shared-ci
Nov 26, 2024
32cb304
Merge branch 'main' into feature/shared-ci
Nov 27, 2024
6e06107
fix: :construction_worker: Github actions shared
Nov 27, 2024
91833b3
fix: :construction_worker: Github actions shared
Nov 27, 2024
58d1eba
fix: :construction_worker: Github actions shared
Nov 27, 2024
ca55275
fix: :construction_worker: Github actions shared
Nov 27, 2024
3689bdf
fix: :construction_worker: Github actions shared
Nov 27, 2024
0167e84
fix: :construction_worker: Github actions shared
Nov 27, 2024
698e7fd
fix: :construction_worker: Github actions shared
Nov 27, 2024
a98b880
fix: :construction_worker: Github actions shared
Nov 27, 2024
19be62f
fix: :construction_worker: Github actions shared
Nov 27, 2024
09ef471
fix: :construction_worker: Github actions shared
Nov 27, 2024
1d6213d
Merge branch 'main' into feature/shared-ci
Nov 28, 2024
0e1ba52
fix: :construction_worker: Github actions shared
Nov 28, 2024
275b64f
fix: :construction_worker: Github actions shared
Nov 28, 2024
b624842
feat: :construction_worker: Github actions Java test
Nov 28, 2024
c603401
fix: :construction_worker: Github actions shared
Nov 28, 2024
63ef604
Merge branch 'main' into feature/shared-ci
Nov 28, 2024
e728385
fix: :construction_worker: Github actions shared
Nov 28, 2024
7ffc5ac
fix: :construction_worker: Github actions shared
Nov 28, 2024
7f87355
fix: :construction_worker: Github actions shared
Nov 28, 2024
bd6723b
docs: :memo: Documentation
Nov 28, 2024
8422b8a
fix: :construction_worker: Github actions shared
Nov 28, 2024
3da7969
fix: :construction_worker: Github actions shared
Nov 28, 2024
be9e951
fix: :construction_worker: Github actions shared
Nov 28, 2024
fc8e474
fix: :construction_worker: Github actions shared
Nov 28, 2024
fb22529
fix: :construction_worker: Github actions shared
Nov 28, 2024
9d95bf7
fix: :construction_worker: Github actions shared
Nov 28, 2024
0487545
fix: :construction_worker: Github actions shared
Nov 28, 2024
19c9da1
fix: :construction_worker: Review
Nov 29, 2024
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
64 changes: 64 additions & 0 deletions .github/workflows/component-container-image-security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Generic security scan

on:
workflow_call:
inputs:
context:
description: "Path to the Dockerfile directory to analyse"
required: true
default: "."
type: string
image-path:
description: "Path of the docker image to analyse"
default: "ghcr.io/${{ github.repository }}/app"
type: string

permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status

jobs:
security-dependency-trivy:
name: Trivy dependency scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
# need to format as github.repository contains uppercase
# and pull request workflow contains slashes
- id: format
name: Format proper image path and tag
env:
IMAGE_PATH: ${{ inputs.image-path }}
run: |
echo "image-tag=${GITHUB_REF_NAME/\//-}" >> $GITHUB_OUTPUT
echo "image-path=${IMAGE_PATH@L}" >> $GITHUB_OUTPUT
- name: Build Docker image
uses: docker/build-push-action@v6
if: ${{ github.event_name != 'release' }}
with:
context: "{{defaultContext}}:${{ inputs.context }}"
tags: "${{ steps.format.outputs.image-path }}:${{ steps.format.outputs.image-tag }}"
push: false
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db,aquasec/trivy-db,ghcr.io/aquasecurity/trivy-db
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db,aquasec/trivy-java-db,ghcr.io/aquasecurity/trivy-java-db
with:
image-ref: "${{ steps.format.outputs.image-path }}:${{ steps.format.outputs.image-tag }}"
format: 'sarif'
output: 'trivy-results.sarif'
vuln-type: "os,library"
severity: "CRITICAL,HIGH"
exit-code: "1"
ignore-unfixed: true
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-results.sarif'
- name: Inspect bandit SARIF report
if: always()
run: cat trivy-results.sarif
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
name: Java Docker
name: Build and push Docker image

on:
push:
branches:
- main
paths:
- "java-demo/**"
pull_request:
paths:
- "java-demo/**"
release:
types: [created]
workflow_call:
inputs:
context:
description: "Path to the Dockerfile directory to build"
default: "."
type: string
image-path:
description: "Path of the docker image Tag"
default: "ghcr.io/${{ github.repository }}/app"
type: string

jobs:
container-image-build:
name: Docker
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- id: format
name: Lowercase repository path
uses: ASzc/change-string-case-action@v1
with:
string: ${{ inputs.image-path }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: ${{ github.event_name == 'release' }}
Expand All @@ -31,12 +37,13 @@ jobs:
uses: docker/build-push-action@v6
if: ${{ github.event_name != 'release' }}
with:
context: "{{defaultContext}}:java-demo"
context: "{{defaultContext}}:${{ inputs.context }}"
tags: "${{ steps.format.outputs.lowercase }}:develop"
push: false
- name: Build and push
uses: docker/build-push-action@v6
if: ${{ github.event_name == 'release' }}
with:
context: "{{defaultContext}}:java-demo"
context: "{{defaultContext}}:${{ inputs.context }}"
tags: "${{ steps.format.outputs.lowercase }}:${{ github.ref_name }}"
push: true
tags: "ghcr.io/british-oceanographic-data-centre/amrit-repos/java/app:${{ github.ref_name }}"
27 changes: 27 additions & 0 deletions .github/workflows/component-java-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Java Lint

on:
workflow_call:
inputs:
context:
description: "Path to the module to lint"
default: ""
type: string
java-version:
description: "Java version"
default: "21"
type: string

jobs:
java-linter-spotless:
name: Lint with spotless
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: ${{ inputs.java-version }}
- name: Run Spotless lint
working-directory: ./${{ inputs.context }}
run: ./mvnw spotless:check
32 changes: 32 additions & 0 deletions .github/workflows/component-java-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Java Tests

on:
workflow_call:
inputs:
context:
description: "Path to the module to lint"
default: ""
type: string
java-version:
description: "Java version"
default: "21"
type: string

jobs:
java-test-maven:
name: Test with Maven
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: ${{ inputs.java-version }}
- name: Run Maven run tests
working-directory: ./${{ inputs.context }}
run: ./mvnw clean test
- name: Publish Test Report
uses: mikepenz/action-junit-report@v5
if: always()
with:
report_paths: '**/target/**/TEST-*.xml'
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
name: Python Tox
name: Python Linting

on:
push:
branches:
# Run on our main branch
- main
paths:
- example-python/**
pull_request:
# Run for any pull requests
paths:
- example-python/**
workflow_call:
inputs:
context:
description: "Path to the module to lint"
default: ""
type: string

jobs:
tox:
runs-on: ubuntu-latest
Expand All @@ -20,21 +17,21 @@ jobs:
python-version: ["3.10", "3.11", "3.12", "3.13"]
tox-job: ["test", "build", "lint", "type"]
steps:
- uses: actions/checkout@v4 # Checkout the current branch/merge state
- name: Set up Python ${{ matrix.python-version }} # Get Python ready to use
- uses: actions/checkout@v4 # Checkout the current branch/merge state
- name: Set up Python ${{ matrix.python-version }} # Get Python ready to use
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies # Get Tox and Poetry ready
working-directory: ./example-python
- name: Install dependencies # Get Tox and Poetry ready
working-directory: ./${{ inputs.context }}
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
curl -sSL https://install.python-poetry.org | python -
tox depends --recreate
# Run Tox jobs
- name: Tox (${{ matrix.tox-job }})
working-directory: ./example-python
working-directory: ./${{ inputs.context }}
run: |
poetry config virtualenvs.create false
poetry install --no-root --with ${{ matrix.tox-job }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
name: Python Security

on:
push:
branches:
# Run on our main branch
- main
paths:
- example-python/**
pull_request:
# Run for any pull requests
paths:
- example-python/**
workflow_call:
inputs:
context:
description: "Path to the module to lint"
default: ""
type: string

permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status

jobs:
# https://github.com/marketplace/actions/anchore-container-scan
dependency-check:
name: Grype & Pip Audit dependency scan
runs-on: ubuntu-latest
permissions:
# Required for uploading sarif file
security-events: write
steps:
- uses: actions/checkout@v4 # Checkout the current branch/merge state
- name: Grype Scan
uses: anchore/scan-action@v3
id: grype-scan
with:
path: example-python
path: ${{ inputs.context }}
- name: Upload grype sarif file
if: always()
uses: github/codeql-action/upload-sarif@v3
Expand All @@ -38,8 +38,9 @@ jobs:
- name: Pip Audit
uses: pypa/[email protected]
with:
inputs: example-python
inputs: ${{ inputs.context }}
code-check:
name: Bandit scan
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -54,21 +55,21 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies # Install bandit
working-directory: ./example-python
working-directory: ./${{ inputs.context }}
run: |
python -m pip install --upgrade pip
python -m pip install bandit[toml,sarif]
- name: Run Bandit
working-directory: ./example-python
working-directory: ./${{ inputs.context }}
# Run bandit and output to sarif file
run: |
bandit -r . -c pyproject.toml -f sarif -o bandit.sarif
- name: Upload bandit sarif file
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: example-python/bandit.sarif
sarif_file: ${{ inputs.context }}/bandit.sarif
category: bandit-python-analysis
- name: Inspect bandit SARIF report
if: always()
run: cat example-python/bandit.sarif
run: cat ${{ inputs.context }}/bandit.sarif
21 changes: 21 additions & 0 deletions .github/workflows/component-ts-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Typescript Lint

on:
workflow_call:
inputs:
context:
description: "Path to the module to lint"
default: ""
type: string

jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install modules
working-directory: ./${{ inputs.context }}
run: npm install
- name: Run ESLint
working-directory: ./${{ inputs.context }}
run: npm run lint
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
#
# This workflow file requires a free account on Bearer.com to manage findings, notifications and more.
# See https://docs.bearer.com/guides/bearer-cloud/
name: Bearer
name: Typescript security

on:
pull_request:

schedule:
- cron: '*/15 * * * *'
workflow_call:
inputs:
context:
description: "Path to the module to lint"
default: ""
type: string

permissions:
contents: read # for actions/checkout to fetch code
Expand All @@ -20,6 +22,7 @@ permissions:

jobs:
bearer:
name: Bearer scan
runs-on: ubuntu-latest
steps:
# Checkout project source
Expand All @@ -29,4 +32,4 @@ jobs:
id: report
uses: bearer/bearer-action@828eeb928ce2f4a7ca5ed57fb8b59508cb8c79bc
with:
path: typescript-demo
path: ${{ inputs.context }}
Loading
Loading