-
Notifications
You must be signed in to change notification settings - Fork 3
139 lines (131 loc) · 3.75 KB
/
golang.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# 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') && ! startsWith(github.head_ref, 'renovate') }}
uses: codecov/codecov-action@v5
with:
codecov_yml_path: .codecov.yml
disable_search: true
env_vars: OS
fail_ci_if_error: true
files: 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