-
Notifications
You must be signed in to change notification settings - Fork 3
62 lines (52 loc) · 1.95 KB
/
go-standards.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
# This workflow will build, test, and lint a Golang project.
# For more information see:
# - https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
# - https://golangci-lint.run/usage/install/#github-action
name: Go Standards (Build, Test & Lint)
on:
push:
branches: ["main", "ci", "test"]
pull_request:
branches: ["main", "ci", "test"]
permissions:
contents: read
jobs:
build-test-lint:
# This job runs on the latest Ubuntu environment
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository
- name: Checkout repository
uses: actions/checkout@v4
# Step 2: Set up Go environment
- name: Set up Go v1.22.3
uses: actions/setup-go@v5
with:
go-version: "1.22.3"
# Step 3: Build the project
- name: Build the project
run: go build -v ./...
# Ensures build step is only attempted if the repository was checked out successfully
continue-on-error: false
# Step 4: Test the project
- name: Run tests
run: go test -v ./... -test.short
# Ensures test step is only attempted if the build step was successful
continue-on-error: false
# Step 5: Run golangci-lint
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.59.1
# Specify the output format for the linting report
args: --out-format=checkstyle:golangci-lint-report.yml,github-actions
# Ensures lint step is only attempted if the test step was successful
continue-on-error: false
# Step 6: Upload golangci-lint report as an artifact
- name: Upload golangci-lint report
uses: actions/upload-artifact@v4
with:
name: golangci-lint-report
path: golangci-lint-report.yml
# Ensures artifact upload step is only attempted if the lint step was successful
continue-on-error: false