-
Notifications
You must be signed in to change notification settings - Fork 36
125 lines (105 loc) · 3.58 KB
/
Copy pathci.yaml
File metadata and controls
125 lines (105 loc) · 3.58 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
name: CI Workflow
on:
pull_request:
# trigger also if labels are set/unsed to allow to ignore the gorelease check
types: [opened, synchronize, reopened, labeled, unlabeled]
workflow_dispatch:
permissions:
pull-requests: write # required to add comments to the PR
contents: read
jobs:
main:
name: CI
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
go-version: ["1.25", "1.26"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Test
run: make test
lint:
name: Linting
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.25
- name: Install project tools and dependencies
run: make project-tools
- name: Lint
run: |
make lint
scripts/check-sync-tidy.sh
gorelease-check:
name: Gorelease check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.25
- name: Install project tools and dependencies
run: make project-tools
- name: Create gorelease report
run: make gorelease-report
# Creates a new comment or updates the existing one to show the report result
- name: Comment PR
uses: actions/github-script@v7
env:
REPORT_FILE: "gorelease_report.md"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const identifier = `<!-- gorelease-report -->`;
const fs = require('fs');
let report = "No output generated.";
if (process.env.REPORT_FILE && fs.existsSync(process.env.REPORT_FILE)) {
report = fs.readFileSync(process.env.REPORT_FILE, 'utf8');
}
// Format the comment
const body = `${identifier}\n${report}`;
// Fetch existing comments on the PR
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
// Look for a comment containing our unique identifier
const existingComment = comments.find(c => c.body.includes(identifier));
if (existingComment) {
// Update the existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: body
});
} else {
// Create a new comment if one doesn't exist
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});
}
- name: Fail job if gorelease failed
if: ${{ !contains(github.event.pull_request.labels.*.name, 'ignore-gorelease-check') }}
run: make gorelease-check