Fix: Linter issue with non-constant format string #136
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
name: eventlist | |
on: | |
pull_request: | |
branches: [ main ] | |
paths: | |
- '.github/workflows/eventlist.yml' | |
- 'tools/eventlist/**' | |
- '!.github/workflows/tpip-check.yml' | |
- '!tools/eventlist/template/**' | |
push: | |
branches: [ main ] | |
paths: | |
- '.github/workflows/eventlist.yml' | |
- 'tools/eventlist/**' | |
- '!.github/workflows/tpip-check.yml' | |
- '!tools/eventlist/template/**' | |
release: | |
types: [published] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
if: | | |
github.event_name != 'release' || | |
startsWith(github.ref, 'refs/tags/tools/eventlist/') | |
name: 'Build' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Install Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: tools/eventlist/go.mod | |
check-latest: true | |
- name: Initialize CodeQL | |
if: github.event_name != 'release' | |
uses: github/codeql-action/init@v2 | |
with: | |
languages: go | |
queries: security-and-quality | |
- name: Build linux-amd64 executable | |
run: | | |
./make.sh build -os linux -arch amd64 -outdir build/linux-amd64 | |
working-directory: ./tools/eventlist | |
- name: Perform CodeQL Analysis | |
if: github.event_name != 'release' | |
uses: github/codeql-action/analyze@v2 | |
- name: Build remaining executables | |
run: | | |
./make.sh build -os linux -arch arm64 -outdir build/linux-arm64 | |
./make.sh build -os darwin -arch amd64 -outdir build/darwin-amd64 | |
./make.sh build -os darwin -arch arm64 -outdir build/darwin-arm64 | |
./make.sh build -os windows -arch amd64 -outdir build/windows-amd64 | |
./make.sh build -os windows -arch arm64 -outdir build/windows-arm64 | |
working-directory: ./tools/eventlist | |
- name: Archive eventlist | |
uses: actions/upload-artifact@v3 | |
with: | |
name: eventlist-linux-amd64 | |
path: ./tools/eventlist/build/linux-amd64 | |
retention-days: 1 | |
if-no-files-found: error | |
- name: Archive eventlist | |
uses: actions/upload-artifact@v3 | |
with: | |
name: eventlist-linux-arm64 | |
path: ./tools/eventlist/build/linux-arm64 | |
retention-days: 1 | |
if-no-files-found: error | |
- name: Archive eventlist | |
uses: actions/upload-artifact@v3 | |
with: | |
name: eventlist-darwin-amd64 | |
path: ./tools/eventlist/build/darwin-amd64 | |
retention-days: 1 | |
if-no-files-found: error | |
- name: Archive eventlist | |
uses: actions/upload-artifact@v3 | |
with: | |
name: eventlist-darwin-arm64 | |
path: ./tools/eventlist/build/darwin-arm64 | |
retention-days: 1 | |
if-no-files-found: error | |
- name: Archive eventlist | |
uses: actions/upload-artifact@v3 | |
with: | |
name: eventlist-windows-amd64 | |
path: ./tools/eventlist/build/windows-amd64 | |
retention-days: 1 | |
if-no-files-found: error | |
- name: Archive eventlist | |
uses: actions/upload-artifact@v3 | |
with: | |
name: eventlist-windows-arm64 | |
path: ./tools/eventlist/build/windows-arm64 | |
retention-days: 1 | |
if-no-files-found: error | |
# lint: | |
# if: github.event_name == 'pull_request' | |
# name: Lint | |
# timeout-minutes: 10 | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Check out repository code | |
# uses: actions/checkout@v3 | |
# - name: Install Go | |
# uses: actions/setup-go@v3 | |
# with: | |
# go-version-file: tools/eventlist/go.mod | |
# check-latest: true | |
# - name: golangci-lint | |
# uses: golangci/golangci-lint-action@v3 | |
# with: | |
# # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version | |
# version: latest | |
# working-directory: ./tools/eventlist | |
format: | |
if: github.event_name != 'pull_request' | |
name: Format | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Install Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: tools/eventlist/go.mod | |
check-latest: true | |
- name: Create build folder | |
run: mkdir build | |
working-directory: ./tools/eventlist | |
- name: Check formatting | |
run: | | |
gofmt -d . | tee build/format-check.out | |
test ! -s build/format-check.out | |
working-directory: ./tools/eventlist | |
vulnerability-check: | |
name: "Vulnerability check" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Scan for Vulnerabilities | |
uses: golang/govulncheck-action@v1 | |
with: | |
go-version-file: ./tools/eventlist/go.mod | |
check-latest: true | |
go-package: ./... | |
work-dir: ./tools/eventlist | |
test: | |
if: | | |
github.event_name != 'release' || | |
startsWith(github.ref, 'refs/tags/tools/eventlist/') | |
needs: [ build ] | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
name: 'Test (${{ matrix.os }})' | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Install Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: tools/eventlist/go.mod | |
check-latest: true | |
- name: Create build folder | |
run: mkdir build | |
working-directory: ./tools/eventlist | |
- name: Install go-junit-report | |
run: go install github.com/jstemmer/go-junit-report/v2@latest | |
- name: Run unit test-TEMP | |
run: | | |
go test -v ./... | |
working-directory: ./tools/eventlist | |
- name: Run unit test | |
run: | | |
go test -v 2>&1 ./... | go-junit-report -set-exit-code > build/evenlistunittest-${{ matrix.os }}.xml | |
working-directory: ./tools/eventlist | |
- name: Archive unit test results | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: unit-test-result-${{ matrix.os }} | |
path: ./tools/eventlist/build/evenlistunittest-*.xml | |
if-no-files-found: error | |
publish-test-results: | |
if: github.event_name != 'release' | |
name: "Publish Tests Results" | |
needs: [ test ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download unit test report windows | |
uses: actions/download-artifact@v3 | |
with: | |
name: unit-test-result-windows-latest | |
path: testreports/ | |
- name: Download unit test report linux | |
uses: actions/download-artifact@v3 | |
with: | |
name: unit-test-result-ubuntu-latest | |
path: testreports/ | |
- name: Download unit test report macos | |
uses: actions/download-artifact@v3 | |
with: | |
name: unit-test-result-macos-latest | |
path: testreports/ | |
- name: publish test results | |
uses: EnricoMi/publish-unit-test-result-action/composite@v2 | |
with: | |
commit: ${{ github.event.workflow_run.head_sha }} | |
report_individual_runs: true | |
junit_files: "testreports/*.xml" | |
coverage: | |
if: | | |
github.event_name != 'release' || | |
startsWith(github.ref, 'refs/tags/tools/eventlist/') | |
needs: [ build ] | |
name: 'Coverage check' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Install Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: tools/eventlist/go.mod | |
check-latest: true | |
- name: Create build folder | |
run: mkdir build | |
working-directory: ./tools/eventlist | |
- name: Check coverage | |
run: | | |
go test ./... -race -coverprofile=build/cover.out -covermode=atomic | |
test `go tool cover -func build/cover.out | tail -1 | awk '{print ($3 + 0)*10}'` -gt 950 | |
working-directory: ./tools/eventlist | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
files: ./tools/eventlist/build/cover.out | |
fail_ci_if_error: true | |
verbose: true | |
release: | |
needs: [ build, test, coverage ] | |
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/tools/eventlist/') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout devtools | |
uses: actions/checkout@v3 | |
- name: Create distribution folders | |
run: | | |
mkdir -p release/eventlist-linux-amd64/docs | |
mkdir -p release/eventlist-linux-arm64/docs | |
mkdir -p release/eventlist-darwin-amd64/docs | |
mkdir -p release/eventlist-darwin-arm64/docs | |
mkdir -p release/eventlist-windows-amd64/docs | |
mkdir -p release/eventlist-windows-arm64/docs | |
cp LICENSE release/eventlist-linux-amd64/ | |
cp LICENSE release/eventlist-linux-arm64/ | |
cp LICENSE release/eventlist-darwin-amd64/ | |
cp LICENSE release/eventlist-darwin-arm64/ | |
cp LICENSE release/eventlist-windows-amd64/ | |
cp LICENSE release/eventlist-windows-arm64/ | |
cp tools/eventlist/docs/* release/eventlist-linux-amd64/docs/ | |
cp tools/eventlist/docs/* release/eventlist-linux-arm64/docs/ | |
cp tools/eventlist/docs/* release/eventlist-darwin-amd64/docs/ | |
cp tools/eventlist/docs/* release/eventlist-darwin-arm64/docs/ | |
cp tools/eventlist/docs/* release/eventlist-windows-amd64/docs/ | |
cp tools/eventlist/docs/* release/eventlist-windows-arm64/docs/ | |
cp tools/eventlist/third_party_licenses.md release/eventlist-linux-amd64/ | |
cp tools/eventlist/third_party_licenses.md release/eventlist-linux-arm64/ | |
cp tools/eventlist/third_party_licenses.md release/eventlist-darwin-amd64/ | |
cp tools/eventlist/third_party_licenses.md release/eventlist-darwin-arm64/ | |
cp tools/eventlist/third_party_licenses.md release/eventlist-windows-amd64/ | |
cp tools/eventlist/third_party_licenses.md release/eventlist-windows-arm64/ | |
- name: Download eventlist linux | |
uses: actions/download-artifact@v3 | |
with: | |
name: eventlist-linux-amd64 | |
path: release/eventlist-linux-amd64/ | |
- name: Download eventlist linux | |
uses: actions/download-artifact@v3 | |
with: | |
name: eventlist-linux-arm64 | |
path: release/eventlist-linux-arm64/ | |
- name: Download eventlist macos | |
uses: actions/download-artifact@v3 | |
with: | |
name: eventlist-darwin-amd64 | |
path: release/eventlist-darwin-amd64/ | |
- name: Download eventlist macos | |
uses: actions/download-artifact@v3 | |
with: | |
name: eventlist-darwin-arm64 | |
path: release/eventlist-darwin-arm64/ | |
- name: Download eventlist windows | |
uses: actions/download-artifact@v2 | |
with: | |
name: eventlist-windows-amd64 | |
path: release/eventlist-windows-amd64/ | |
- name: Download eventlist windows | |
uses: actions/download-artifact@v2 | |
with: | |
name: eventlist-windows-arm64 | |
path: release/eventlist-windows-arm64/ | |
- name: Zip folders | |
run: | | |
# Ensure executable eventlist due to this limitation | |
# https://github.com/actions/upload-artifact#permission-loss | |
chmod +x */eventlist* | |
zip -r eventlist-windows-amd64.zip eventlist-windows-amd64/eventlist.exe eventlist-windows-amd64/docs eventlist-windows-amd64/LICENSE eventlist-windows-amd64/third_party_licenses.md | |
zip -r eventlist-windows-arm64.zip eventlist-windows-arm64/eventlist.exe eventlist-windows-arm64/docs eventlist-windows-arm64/LICENSE eventlist-windows-arm64/third_party_licenses.md | |
tar -czvf eventlist-linux-amd64.tar.gz eventlist-linux-amd64/eventlist eventlist-linux-amd64/docs eventlist-linux-amd64/LICENSE eventlist-linux-amd64/third_party_licenses.md | |
tar -czvf eventlist-linux-arm64.tar.gz eventlist-linux-arm64/eventlist eventlist-linux-arm64/docs eventlist-linux-arm64/LICENSE eventlist-linux-arm64/third_party_licenses.md | |
tar -czvf eventlist-darwin-amd64.tar.gz eventlist-darwin-amd64/eventlist eventlist-darwin-amd64/docs eventlist-darwin-amd64/LICENSE eventlist-darwin-amd64/third_party_licenses.md | |
tar -czvf eventlist-darwin-arm64.tar.gz eventlist-darwin-arm64/eventlist eventlist-darwin-arm64/docs eventlist-darwin-arm64/LICENSE eventlist-darwin-arm64/third_party_licenses.md | |
working-directory: release | |
- name: Calculate checksums | |
run: | | |
sha256sum eventlist-windows-amd64.zip --text > eventlist-checksums.txt | |
sha256sum eventlist-windows-arm64.zip --text >> eventlist-checksums.txt | |
sha256sum eventlist-linux-amd64.tar.gz --text >> eventlist-checksums.txt | |
sha256sum eventlist-linux-arm64.tar.gz --text >> eventlist-checksums.txt | |
sha256sum eventlist-darwin-amd64.tar.gz --text >> eventlist-checksums.txt | |
sha256sum eventlist-darwin-arm64.tar.gz --text >> eventlist-checksums.txt | |
working-directory: release | |
- name: Attach installer to release assets | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: release/eventlist-* | |
tag: ${{ github.ref }} | |
overwrite: true | |
file_glob: true |