This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
Code Analysis #490
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: "Code Analysis" | |
on: | |
push: | |
tags: | |
- v* | |
branches: | |
- main | |
pull_request: | |
schedule: | |
- cron: "0 0 * * 0" | |
concurrency: | |
group: ${{ format('{0}-{1}-{2}', github.workflow, github.head_ref, github.ref_name) }} | |
cancel-in-progress: true | |
env: | |
GO: "1.21" | |
jobs: | |
codeql: | |
runs-on: ubuntu-latest | |
permissions: | |
security-events: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v2 | |
with: | |
queries: security-and-quality | |
languages: go | |
- name: Autobuild | |
uses: github/codeql-action/autobuild@v2 | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v2 | |
fmt: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO }} | |
- name: go fmt | |
run: make fmt | |
- name: check for dirty state | |
run: | | |
DELTA="$(git diff --numstat)" | |
if [ -n "${DELTA}" ] | |
then | |
echo "${DELTA}" | |
git diff | |
exit 1 | |
fi | |
generate-config: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO }} | |
- name: generate config | |
run: make generate-config | |
- name: check for dirty state | |
run: | | |
DELTA="$(git diff --numstat)" | |
if [ -n "${DELTA}" ] | |
then | |
echo "${DELTA}" | |
git diff | |
exit 1 | |
fi | |
vet: | |
defaults: | |
run: | |
shell: bash | |
strategy: | |
matrix: | |
go: | |
- "1.21" | |
- "1.20" | |
os: | |
- ubuntu-latest | |
include: | |
- go: "1.21" | |
os: macos-latest | |
- go: "1.21" | |
os: windows-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go }} | |
- name: format for windows | |
if: matrix.os == 'windows-latest' | |
run: go fmt ./... | |
- name: go vet | |
run: make github-vet | |
tested: | |
runs-on: ubuntu-latest | |
needs: [ CodeQL, fmt, generate-config, vet ] | |
if: always() | |
steps: | |
- name: All tests ok | |
if: ${{ !(contains(needs.*.result, 'failure')) }} | |
run: exit 0 | |
- name: Some tests failed | |
if: ${{ contains(needs.*.result, 'failure') }} | |
run: exit 1 |