-
Notifications
You must be signed in to change notification settings - Fork 18
68 lines (68 loc) · 1.9 KB
/
ci.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
name: CI
on:
pull_request:
permissions:
contents: read
pull-requests: read
jobs:
lint:
name: Run linting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
with:
files_yaml: |
go:
- '**/*.go'
- name: Set up Go
if: steps.changed-files.outputs.go_any_changed == 'true'
uses: actions/setup-go@v5
with:
go-version: "1.19"
cache: false
- name: Run golangci-lint
if: steps.changed-files.outputs.go_any_changed == 'true'
uses: golangci/golangci-lint-action@v6
with:
version: latest
only-new-issues: true
# TODO(zqzten): add verify job
test:
name: Run unit tests
needs: lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
with:
files_yaml: |
go:
- '**/*.go'
- go.mod
- go.sum
- Makefile
- name: Git config
if: steps.changed-files.outputs.go_any_modified == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Rebase code
if: steps.changed-files.outputs.go_any_modified == 'true'
run: git rebase origin/main
- name: Set up Go
if: steps.changed-files.outputs.go_any_modified == 'true'
uses: actions/setup-go@v5
with:
go-version: "1.19"
- name: Run unit tests
if: steps.changed-files.outputs.go_any_modified == 'true'
run: make unit-test