-
Notifications
You must be signed in to change notification settings - Fork 1
97 lines (85 loc) · 2.84 KB
/
main.yaml
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
name: Node Pool CI
on:
push:
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Lint and Test Go Code
runs-on:
- ubuntu-latest
env:
GOPRIVATE: github.com/gateway-fm/generic-rpc
GO111MODULE: on
steps:
- name: Check out code
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Configure git for private modules
env:
TOKEN: ${{ secrets.PROXY_PIPELINES_GITHUB_TOKEN }}
run: git config --global url."https://oauth2:${TOKEN}@github.com/gateway-fm".insteadOf "https://github.com/gateway-fm"
# Required by golangci-lint, according to docs
- name: Setup Golang Environment
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version-file: go.mod
cache: true
- run: |
go version
go clean -modcache
go mod tidy
- name: Run linter
uses: golangci/golangci-lint-action@v3
with:
version: v1.52
skip-cache: true
skip-build-cache: true
skip-pkg-cache: true
skip-go-installation: true
args: --timeout=10m
- name: run tests and generate coverage
run: go test ./... -coverprofile=./cover.out
- name: check test coverage
id: coverage ## this step must have id
uses: vladopajic/go-test-coverage@v2
with:
profile: cover.out
local-prefix: github.com/org/project
threshold-file: 30
threshold-package: 30
threshold-total: 30
- name: make coverage badge
uses: action-badges/[email protected]
if: contains(github.ref, 'main')
with:
label: coverage
message: ${{ steps.coverage.outputs.badge-text }}
message-color: ${{ steps.coverage.outputs.badge-color }}
file-name: coverage.svg
badge-branch: badges ## orphan branch where badge will be committed
github-token: "${{ secrets.GITHUB_TOKEN }}"
release:
name: Make Release
needs:
- test
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.tag_version.outputs.new_tag }}
steps:
- uses: actions/checkout@v2
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.RELEASES_ACTION_GITHUB_TOKEN }}
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
token: ${{ secrets.RELEASES_ACTION_GITHUB_TOKEN }}