Skip to content

Commit 436488b

Browse files
committed
ci: introduce pr-check action
1 parent ee5d7b1 commit 436488b

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

.github/workflows/pr.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: PR Checks
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
concurrency:
8+
group: pr-checks-${{ github.event.pull_request.number || github.ref }}
9+
cancel-in-progress: true
10+
11+
env:
12+
GO_VERSION: '1.26.x'
13+
BINARY_NAME: linkctl
14+
15+
jobs:
16+
format-and-lint:
17+
runs-on: macos-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: ${{ env.GO_VERSION }}
26+
cache: true
27+
28+
- name: Install mise & tools
29+
uses: jdx/mise-action@v2
30+
31+
- name: Cache Go tools
32+
id: go-tools-cache
33+
uses: actions/cache@v4
34+
with:
35+
path: ~/go/bin
36+
key: ${{ runner.os }}-go-tools-${{ hashFiles('.mise.toml') }}
37+
38+
- name: Install tooling
39+
if: steps.go-tools-cache.outputs.cache-hit != 'true'
40+
run: make tools
41+
42+
- name: Check formatting
43+
run: |
44+
export PATH="$(go env GOPATH)/bin:$PATH"
45+
make format-check
46+
47+
- name: Run lint
48+
run: |
49+
export PATH="$(go env GOPATH)/bin:$PATH"
50+
make lint
51+
52+
unit-tests:
53+
runs-on: macos-latest
54+
steps:
55+
- name: Checkout code
56+
uses: actions/checkout@v4
57+
58+
- name: Set up Go
59+
uses: actions/setup-go@v5
60+
with:
61+
go-version: ${{ env.GO_VERSION }}
62+
cache: true
63+
64+
- name: Run unit tests
65+
run: make test-short
66+
67+
build:
68+
runs-on: macos-latest
69+
steps:
70+
- name: Checkout code
71+
uses: actions/checkout@v4
72+
with:
73+
fetch-depth: 0
74+
75+
- name: Set up Go
76+
uses: actions/setup-go@v5
77+
with:
78+
go-version: ${{ env.GO_VERSION }}
79+
cache: true
80+
81+
- name: Build — macOS (arm64 / amd64)
82+
run: |
83+
mkdir -p build
84+
GOOS=darwin GOARCH=arm64 go build -o build/${{ env.BINARY_NAME }}_dev_darwin_arm64 ./cmd
85+
GOOS=darwin GOARCH=amd64 go build -o build/${{ env.BINARY_NAME }}_dev_darwin_amd64 ./cmd
86+
87+
- name: Build — Linux (arm64 / amd64)
88+
run: |
89+
GOOS=linux GOARCH=arm64 go build -o build/${{ env.BINARY_NAME }}_dev_linux_arm64 ./cmd
90+
GOOS=linux GOARCH=amd64 go build -o build/${{ env.BINARY_NAME }}_dev_linux_amd64 ./cmd
91+
92+
- name: Build — Windows (amd64)
93+
run: |
94+
GOOS=windows GOARCH=amd64 go build -o build/${{ env.BINARY_NAME }}_dev_windows_amd64.exe ./cmd
95+
96+
- name: Upload artifacts
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: pr-${{ github.event.pull_request.number }}-builds
100+
path: build/
101+
retention-days: 3

0 commit comments

Comments
 (0)