-
Notifications
You must be signed in to change notification settings - Fork 25
130 lines (110 loc) · 3.84 KB
/
main.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
---
# based on https://github.com/mvdan/github-actions-golang
name: CI
on:
pull_request:
branches: ["main"]
paths-ignore:
- "docs/**"
- "config/version.txt"
- "README.md"
- "nix/**"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: "^1.20.6"
- name: Checkout code
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
ref: ${{ github.head_ref }}
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
# cache go modules
- uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
bin
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run linting
if: matrix.os == 'ubuntu-latest'
run: make lint
- name: Run unittest
if: matrix.os == 'ubuntu-latest'
run: make test-coverage
- name: Go Coverage Badge
uses: tj-actions/coverage-badge-go@v2
if: matrix.os == 'ubuntu-latest'
with:
green: 80
filename: out/coverage.out
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v16
if: matrix.os == 'ubuntu-latest'
id: verify-changed-files-coverage
with:
files: README.md
- name: Commit changes
if: steps.verify-changed-files-coverage.outputs.files_changed == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add README.md
git commit -m "chore(docs): update coverage badge"
- name: Build package
run: make build
- name: Execute build
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: ./out/bin/gt --help
- name: Execute build
if: matrix.os == 'windows-latest'
run: ./out/bin/gt.exe --help
- name: Create a test project & test it
run: |
make testing-project-default
make -C testing-project ci
make -C testing-project all
- name: Test generate projects
run: make testing-project-ci
- name: Run generate
if: matrix.os == 'ubuntu-latest'
run: make generate
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v16
if: matrix.os == 'ubuntu-latest'
id: verify-changed-files-generate
with:
files: |
nix/gomod2nix.toml
docs/options.md
- name: Commit changes
if: steps.verify-changed-files-generate.outputs.files_changed == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add nix/gomod2nix.toml docs/options.md
git commit -m "chore: regenerate files"
- name: Push changes
if: steps.verify-changed-files-coverage.outputs.files_changed == 'true' || steps.verify-changed-files-generate.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.SIT_BOT_PAT }}
branch: ${{ github.head_ref }}