Skip to content

Commit 3aadc8f

Browse files
author
Test User
committed
Merge branch 'master'
2 parents 0a69779 + c41de38 commit 3aadc8f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3253
-377
lines changed

.github/workflows/build.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
pull_request:
7+
branches: [master, main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
name: Build on ${{ matrix.os }}/${{ matrix.arch }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
include:
19+
- os: ubuntu-latest
20+
arch: amd64
21+
goos: linux
22+
goarch: amd64
23+
- os: ubuntu-latest
24+
arch: arm64
25+
goos: linux
26+
goarch: arm64
27+
- os: macos-latest
28+
arch: amd64
29+
goos: darwin
30+
goarch: amd64
31+
- os: macos-latest
32+
arch: arm64
33+
goos: darwin
34+
goarch: arm64
35+
- os: windows-latest
36+
arch: amd64
37+
goos: windows
38+
goarch: amd64
39+
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v4
43+
44+
- name: Set up Go
45+
uses: actions/setup-go@v5
46+
with:
47+
go-version: '1.21'
48+
49+
- name: Build binary
50+
shell: bash
51+
env:
52+
GOOS: ${{ matrix.goos }}
53+
GOARCH: ${{ matrix.goarch }}
54+
CGO_ENABLED: 0
55+
run: |
56+
VERSION=dev
57+
COMMIT=$(git rev-parse --short HEAD)
58+
BUILD_TIME=$(date -u '+%Y-%m-%d_%H:%M:%S')
59+
BINARY_NAME=doplan
60+
if [ "${{ matrix.goos }}" = "windows" ]; then
61+
BINARY_NAME=doplan.exe
62+
fi
63+
go build -ldflags "-X main.version=$VERSION -X main.commit=$COMMIT -X main.date=$BUILD_TIME -s -w" -trimpath -o bin/$BINARY_NAME ./cmd/doplan
64+
65+
- name: Verify binary exists
66+
shell: bash
67+
run: |
68+
if [ "${{ matrix.goos }}" = "windows" ]; then
69+
if [ ! -f "bin/doplan.exe" ]; then
70+
echo "Error: Binary bin/doplan.exe not found"
71+
exit 1
72+
fi
73+
echo "✅ Binary bin/doplan.exe created successfully"
74+
ls -lh bin/doplan.exe
75+
else
76+
if [ ! -f "bin/doplan" ]; then
77+
echo "Error: Binary bin/doplan not found"
78+
exit 1
79+
fi
80+
echo "✅ Binary bin/doplan created successfully"
81+
ls -lh bin/doplan
82+
fi
83+
84+
- name: Test binary (native architecture only)
85+
shell: bash
86+
# Only test if building for native architecture (can execute on runner)
87+
# Cross-compiled binaries (arm64 on amd64 runners) cannot be executed
88+
# Strategy: Test amd64 builds which can run on all amd64 runners
89+
# For arm64 builds, skip testing (see "Verify cross-compiled binary" step)
90+
if: matrix.goarch == 'amd64'
91+
run: |
92+
echo "Testing binary for ${{ matrix.goos }}/${{ matrix.goarch }}..."
93+
if [ "${{ matrix.goos }}" = "windows" ]; then
94+
./bin/doplan.exe --version
95+
echo "✅ Binary test passed for windows/amd64"
96+
else
97+
./bin/doplan --version
98+
echo "✅ Binary test passed for ${{ matrix.goos }}/${{ matrix.goarch }}"
99+
fi
100+
101+
- name: Verify cross-compiled binary
102+
shell: bash
103+
# For cross-compiled builds (arm64 on amd64 runners), verify binary exists but skip execution
104+
if: matrix.goarch == 'arm64'
105+
run: |
106+
echo "ℹ️ Binary built for ${{ matrix.goos }}/${{ matrix.goarch }} (cross-compiled)"
107+
echo "ℹ️ Skipping execution test - binary cannot run on amd64 runner architecture"
108+
echo "ℹ️ Binary verified to exist and will be uploaded as artifact"
109+
if [ "${{ matrix.goos }}" = "windows" ]; then
110+
file bin/doplan.exe || echo "⚠️ file command not available, but binary exists"
111+
else
112+
file bin/doplan || echo "⚠️ file command not available, but binary exists"
113+
fi
114+
115+
- name: Upload binary
116+
uses: actions/upload-artifact@v4
117+
with:
118+
name: doplan-${{ matrix.goos }}-${{ matrix.goarch }}
119+
path: bin/*
120+

.github/workflows/lint.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
pull_request:
7+
branches: [master, main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
fmt:
14+
name: Check Formatting
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: '1.21'
24+
25+
- name: Check formatting
26+
run: |
27+
if [ "$(gofmt -s -d .)" ]; then
28+
echo "Code is not formatted. Run 'go fmt ./...' to fix."
29+
gofmt -s -d .
30+
exit 1
31+
fi
32+
33+
vet:
34+
name: Go Vet
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v4
39+
40+
- name: Set up Go
41+
uses: actions/setup-go@v5
42+
with:
43+
go-version: '1.21'
44+
45+
- name: Run go vet
46+
run: go vet ./...
47+
48+
mod:
49+
name: Go Mod Verify
50+
runs-on: ubuntu-latest
51+
steps:
52+
- name: Checkout code
53+
uses: actions/checkout@v4
54+
55+
- name: Set up Go
56+
uses: actions/setup-go@v5
57+
with:
58+
go-version: '1.21'
59+
60+
- name: Download dependencies
61+
run: go mod download
62+
63+
- name: Verify dependencies
64+
run: go mod verify
65+
66+
- name: Check for updates
67+
run: go mod tidy && git diff --exit-code go.mod go.sum
68+
69+
lint:
70+
name: Lint (Optional)
71+
runs-on: ubuntu-latest
72+
if: false # Disabled by default, enable if golangci-lint config is added
73+
steps:
74+
- name: Checkout code
75+
uses: actions/checkout@v4
76+
77+
- name: Set up Go
78+
uses: actions/setup-go@v5
79+
with:
80+
go-version: '1.21'
81+
82+
- name: Run golangci-lint
83+
uses: golangci/golangci-lint-action@v6
84+
with:
85+
version: latest
86+
args: --timeout=5m
87+

.github/workflows/pr-checks.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: PR Checks
2+
3+
on:
4+
pull_request:
5+
branches: [master, main]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
pr-checks:
13+
name: PR Quality Checks
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: '1.21'
25+
26+
- name: Run tests
27+
run: go test -v ./...
28+
29+
- name: Check formatting
30+
run: |
31+
if [ "$(gofmt -s -d .)" ]; then
32+
echo "Code is not formatted. Run 'go fmt ./...' to fix."
33+
gofmt -s -d .
34+
exit 1
35+
fi
36+
37+
- name: Run go vet
38+
run: go vet ./...
39+
40+
- name: Verify go mod
41+
run: |
42+
go mod download
43+
go mod verify
44+
go mod tidy
45+
git diff --exit-code go.mod go.sum || (echo "go.mod or go.sum needs to be updated" && exit 1)
46+
47+
- name: Build binary
48+
run: make build
49+
50+
- name: Test binary
51+
run: ./bin/doplan --version
52+
53+
- name: Comment PR
54+
if: failure()
55+
uses: actions/github-script@v7
56+
with:
57+
script: |
58+
github.rest.issues.createComment({
59+
issue_number: context.issue.number,
60+
owner: context.repo.owner,
61+
repo: context.repo.repo,
62+
body: '❌ PR checks failed. Please review the workflow logs and fix the issues.'
63+
})
64+

0 commit comments

Comments
 (0)