Golang #3
Workflow file for this run
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
# Code generated by craft; DO NOT EDIT. | |
name: Golang | |
run-name: Golang | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- ready_for_review | |
push: | |
branches: | |
- alpha | |
- beta | |
- dev | |
- develop | |
- development | |
- next | |
- staging | |
workflow_call: | |
inputs: | |
build: | |
description: Whether to run build job or not | |
required: false | |
type: boolean | |
version: | |
description: Build version to use in build metadata | |
required: true | |
type: string | |
workflow_dispatch: | |
jobs: | |
run-workflow: | |
name: Run Workflow | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }} | |
outputs: | |
skip: ${{ steps.skip.outputs.skip }} | |
steps: | |
- id: skip | |
run: echo "Running workflow" && echo "skip=false" >> $GITHUB_OUTPUT | |
go-vulncheck: | |
name: Go Vulnerability Check | |
runs-on: ubuntu-latest | |
needs: run-workflow | |
steps: | |
- uses: golang/govulncheck-action@v1 | |
with: | |
check-latest: true | |
go-package: ./... | |
go-version-file: go.mod | |
go-lint: | |
name: Go Lint | |
runs-on: ubuntu-latest | |
needs: run-workflow | |
permissions: | |
checks: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
cache: false | |
check-latest: true | |
go-version-file: go.mod | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- run: mkdir -p reports/ | |
- uses: golangci/golangci-lint-action@v6 | |
with: | |
args: --config .golangci.yml --timeout 240s --fast --sort-results --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number | |
go-test: | |
name: Go Test | |
runs-on: ${{ matrix.os }} | |
needs: run-workflow | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- macos-latest | |
- ubuntu-latest | |
- windows-latest | |
env: | |
OS: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
check-latest: true | |
go-version-file: go.mod | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- run: mkdir -p reports/ | |
- run: go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s | |
- if: ${{ ! startsWith(github.head_ref, 'dependabot') }} # ignore codecov on dependabot branches | |
uses: codecov/codecov-action@v5 | |
with: | |
codecov_yml_path: .codecov.yml | |
disable_search: true | |
env_vars: OS | |
fail_ci_if_error: true | |
file: reports/go-coverage.native.out | |
flags: ${{ matrix.os }} | |
slug: ${{ github.repository }} | |
token: ${{ secrets.CODECOV_TOKEN }} | |
go-build: | |
name: Go Build | |
runs-on: ubuntu-latest | |
if: ${{ inputs.build }} | |
needs: | |
- run-workflow | |
- go-test | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
check-latest: true | |
go-version-file: go.mod | |
token: ${{ secrets.GITHUB_TOKEN }} | |
# https://github.com/marketplace/actions/goreleaser-action | |
- uses: goreleaser/goreleaser-action@v6 | |
with: | |
args: release --clean --config .goreleaser.yml --skip=validate --skip=announce --skip=publish --snapshot | |
env: | |
VERSION: ${{ inputs.version }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
# order is important to filter unwanted globs after the filter or desired globs | |
path: | | |
dist/* | |
!dist/*.json | |
!dist/*.yaml | |
!dist/*/ | |
retention-days: 1 |