-
Notifications
You must be signed in to change notification settings - Fork 6
135 lines (127 loc) · 3.69 KB
/
ci.yml
File metadata and controls
135 lines (127 loc) · 3.69 KB
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
name: ci
on:
push:
branches:
- "**"
pull_request:
workflow_dispatch:
inputs:
run_integration:
description: "Run integration tests with GitLab Testcontainers"
required: false
default: false
type: boolean
permissions:
contents: write
pull-requests: write
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go from go.mod
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install golangci-lint
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
- name: Run golangci-lint
run: golangci-lint run --timeout=10m
test-fast:
name: test (fast)
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go from go.mod
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Download dependencies
run: go mod download
- name: Run fast tests
run: go test -v ./...
coverage:
name: coverage
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go from go.mod
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Download dependencies
run: go mod download
- name: Generate coverage
id: coverage-output
run: |
go test ./... -coverprofile=coverage.out
go tool cover -func=coverage.out | tee coverage.txt
{
echo 'coverage_text<<EOF_TEXT'
cat coverage.txt
echo EOF_TEXT
} >> "$GITHUB_OUTPUT"
echo "## Coverage" >> "$GITHUB_STEP_SUMMARY"
echo '```text' >> "$GITHUB_STEP_SUMMARY"
cat coverage.txt >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: go-coverage
path: |
coverage.out
coverage.txt
- name: Comment coverage on PR
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: coverage
message: |
## Coverage
```text
${{ steps.coverage-output.outputs.coverage_text }}
```
test-integration:
name: test (integration)
runs-on: ubuntu-latest
timeout-minutes: 90
if: >-
github.ref == 'refs/heads/main' ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.run_integration == 'true')
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go from go.mod
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Download dependencies
run: go mod download
- name: Run integration tests
env:
GLABS_RUN_GITLAB_TC: "1"
run: |
go test -tags=integration ./gitlab/... -count=1 -v -run '^TestIntegration_'
release:
runs-on: ubuntu-latest
needs:
- golangci
- test-fast
- coverage
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: go-semantic-release/action@v1
with:
changelog-generator-opt: "emojis=true"
allow-initial-development-versions: true
hooks: goreleaser
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}