Skip to content

ci: integration with TiCS code quality analysis #939

ci: integration with TiCS code quality analysis

ci: integration with TiCS code quality analysis #939

Workflow file for this run

name: Tests
on:
workflow_call:
inputs:
repository:
description: 'Repository name (with owner) to clone'
required: true
type: string
ref:
description: 'The branch, tag or SHA to checkout'
required: true
type: string
outputs:
test-coverage-file:
description: 'The name of the coverage report file'
value: ${{ jobs.unit-tests.outputs.test-coverage-file }}
test-coverage-artifact:
description: 'The name used to upload the coverage file as a GH artifact'
value: ${{ jobs.unit-tests.outputs.test-coverage-artifact }}
workflow_dispatch:
push:
paths-ignore:
- '**.md'
pull_request:
branches: [main]
jobs:
unit-tests:
runs-on: ubuntu-22.04
name: Unit Tests
env:
TEST_COVERAGE_FILE: test-coverage.out
TEST_COVERAGE_ARTIFACT: chisel-test-coverage
TEST_COVERAGE_HTML_FILE: test-coverage.html
outputs:
test-coverage-file: ${{ env.TEST_COVERAGE_FILE }}
test-coverage-artifact: ${{ env.TEST_COVERAGE_ARTIFACT }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'workflow_call' && inputs.ref || '' }}
repository: ${{ github.event_name == 'workflow_call' && inputs.repository || '' }}
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Run unit tests
run: go test -v -cover -coverprofile=${TEST_COVERAGE_FILE} ./...
- name: Convert test coverage to HTML
if: always()
continue-on-error: true
run: |
set -eu
if [ -f ${TEST_COVERAGE_FILE} ]
then
go tool cover -html=${TEST_COVERAGE_FILE} \
-o=${TEST_COVERAGE_HTML_FILE}
fi
- name: Upload test coverage
uses: actions/upload-artifact@v4
if: always()
continue-on-error: true
with:
name: ${{ env.TEST_COVERAGE_ARTIFACT }}
path: ./test-coverage*
real-archive-tests:
# Do not change to newer releases as "fips" may not be available there.
runs-on: ubuntu-20.04
name: Real Archive Tests
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Run real archive tests
run: |
go test ./internal/archive/ --real-archive