Skip to content

Update Release workflow condition check #406

Update Release workflow condition check

Update Release workflow condition check #406

Workflow file for this run

name: Test
on:
pull_request:
paths:
- '.github/workflows/test.yml'
- 'cmd/**'
- 'pkg/**'
- 'test/**'
- 'go.mod'
- 'go.sum'
- 'makefile'
- '!**/*.md'
push:
branches: [ main ]
workflow_call:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Declare default permissions as read only.
permissions: read-all
jobs:
lint:
name: Lint
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
with:
version: latest
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: go.mod
check-latest: true
- name: Check formatting
run: |
make format-check
vulnerability-check:
name: "Vulnerability check"
runs-on: ubuntu-latest
steps:
- name: Scan for Vulnerabilities
uses: golang/govulncheck-action@7da72f730e37eeaad891fcff0a532d27ed737cd4 # v1.0.1
with:
go-version-file: go.mod
check-latest: true
go-package: ./...
test:
strategy:
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
include:
- platform: ubuntu-latest
target: linux
- platform: windows-latest
target: windows
- platform: macos-latest
target: darwin
name: 'Test (${{ matrix.target }})'
runs-on: ${{ matrix.platform }}
steps:
- name: Check out repository code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: go.mod
check-latest: true
- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report/v2@latest
- name: Unit testing
run: |
mkdir -p build
go test -v ./... > build/cbuildtests-${{ matrix.target }}-amd64.txt
- name: Generate JUnit test report
if: always()
run: |
go-junit-report -set-exit-code -in build/cbuildtests-${{ matrix.target }}-amd64.txt -iocopy -out build/cbuild-testreport-${{ matrix.target }}-amd64.xml
- name: Install qemu (for Linux-Arm64)
if: ${{ startsWith(runner.os, 'Linux') }}
run: |
sudo apt update
sudo apt-get install -y \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
qemu-user-binfmt
- name: Unit testing (for Linux-Arm64)
if: ${{ startsWith(runner.os, 'Linux') && always() }}
run: |
GOOS=linux GOARCH=arm64 go test -v ./... > build/cbuildtests-${{ matrix.target }}-arm64.txt
- name: Generate JUnit test report (for Linux-Arm64)
if: ${{ startsWith(runner.os, 'Linux') && always() }}
run: |
go-junit-report -set-exit-code -in build/cbuildtests-${{ matrix.target }}-arm64.txt -iocopy -out build/cbuild-testreport-${{ matrix.target }}-arm64.xml
- name: Archive unit test results
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: test-result
path: ./build/cbuild-testreport-*.xml
if-no-files-found: error
publish-test-results:
if: github.workflow != 'Release'
name: "Publish Tests Results"
needs: [ test ]
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
steps:
- name: Download Artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
path: artifacts
- name: publish test results
uses: EnricoMi/publish-unit-test-result-action@ca89ad036b5fcd524c1017287fb01b5139908408 # v2.11.0
with:
files: "artifacts/**/cbuild-testreport-*.xml"
report_individual_runs: true
coverage:
if: github.workflow != 'Release'
needs: [ test ]
name: 'Coverage check'
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: go.mod
check-latest: true
- name: Check coverage
run: |
make coverage-check
- name: Publish coverage report to Code Climate
uses: paambaati/codeclimate-action@4cace242c6e0a2dd554bbb3cc12c58047d8af3e5 # v5.0.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
debug: true
coverageLocations: ./build/cover.out:gocov
prefix: cbuild