generated from canonical/is-charms-template-repo
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add nightly CRON job for Tiobe TICS.
This patch adds: - the necessary tox env targets for generating Cobertura coverage report XML format - a GitHub Workflow which runs the unit tests with coverage enabled, and calls the `TICSServer` to upload the analysis results Signed-off-by: Nashwan Azhari <[email protected]>
- Loading branch information
Nashwan Azhari
committed
Dec 13, 2024
1 parent
072754d
commit 7286b37
Showing
4 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: TiCS Nightly Security Report | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 10 * * *' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
TiCS: | ||
|
||
permissions: | ||
contents: read | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
include: | ||
# Latest branches | ||
- { branch: main } | ||
|
||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@v2 | ||
with: | ||
egress-policy: audit | ||
|
||
- name: Checking out repo | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{matrix.branch}} | ||
|
||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
|
||
- name: Install Python Testing Deps | ||
run: | | ||
set -eux -o pipefail | ||
sudo python3 -m pip install tox | ||
- name: Install Go for Cobertura Coverage Converter | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.22" | ||
|
||
- name: Run Tests With Coverage | ||
run: | | ||
set -eux -o pipefail | ||
pushd $GITHUB_WORKSPACE | ||
tox -e unit,coverage-xml | ||
GENERATED_COVERAGE_XML="$GITHUB_WORKSPACE/charms/worker/k8s/coverage.xml" | ||
cat "$GENERATED_COVERAGE_XML" | ||
# TiCS expects the report to be under a "$(pwd)/.coverage" directory. | ||
mkdir -p "$GITHUB_WORKSPACE/.coverage" | ||
mv "$GENERATED_COVERAGE_XML" .coverage/coverage.xml | ||
- name: Run TiCS | ||
run: | | ||
# NOTE(aznashwan): TiCS install script doesn't define defaults; cannot '-u' | ||
set -ex -o pipefail | ||
export TICSAUTHTOKEN=${{ secrets.TICSAUTHTOKEN }} | ||
# Install the TiCS and staticcheck | ||
go install honnef.co/go/tools/cmd/[email protected] | ||
. <(curl --silent --show-error 'https://canonical.tiobe.com/tiobeweb/TICS/api/public/v1/fapi/installtics/Script?cfg=default&platform=linux&url=https://canonical.tiobe.com/tiobeweb/TICS/') | ||
cd $GITHUB_WORKSPACE | ||
TICSQServer -project k8s-operator -tmpdir /tmp/tics -branchdir "$GITHUB_WORKSPACE" | ||
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
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
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