Skip to content

Commit f54b18b

Browse files
authored
feat(installer): Add possibility to update device-agent package (#413) and bundled NodeJS version (#416)
1 parent 561c3ac commit f54b18b

File tree

13 files changed

+1146
-127
lines changed

13 files changed

+1146
-127
lines changed
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
name: Installer Build and Quality Check
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- 'installer/go/**'
8+
- '.github/workflows/installer-build.yaml'
9+
pull_request:
10+
branches: [ main ]
11+
paths:
12+
- 'installer/go/**'
13+
- '.github/workflows/installer-build.yaml'
14+
workflow_dispatch: # Allow manual trigger
15+
16+
env:
17+
GO_VERSION: '1.21'
18+
GOLANGCI_LINT_VERSION: 'v2.1.6'
19+
20+
jobs:
21+
quality-check:
22+
name: Code Quality & Standards Check
23+
runs-on: ubuntu-latest
24+
defaults:
25+
run:
26+
working-directory: ./installer/go
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
31+
32+
- name: Set up Go
33+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
34+
with:
35+
go-version: ${{ env.GO_VERSION }}
36+
37+
- name: Cache Go modules
38+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
39+
with:
40+
path: |
41+
~/.cache/go-build
42+
~/go/pkg/mod
43+
key: ${{ runner.os }}-go-${{ hashFiles('installer/go/go.sum') }}
44+
restore-keys: |
45+
${{ runner.os }}-go-
46+
47+
- name: Download dependencies
48+
run: go mod download
49+
50+
- name: Verify dependencies
51+
run: go mod verify
52+
53+
- name: Run go fmt check
54+
if: false
55+
run: |
56+
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
57+
echo "❌ Code formatting issues found:"
58+
gofmt -s -l .
59+
echo ""
60+
echo "Please run 'go fmt ./...' to format your code."
61+
exit 1
62+
fi
63+
echo "✅ Code formatting is correct"
64+
65+
- name: Run go vet
66+
run: |
67+
echo "Running go vet static analysis..."
68+
go vet ./...
69+
70+
- name: Install golangci-lint
71+
run: |
72+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin ${{ env.GOLANGCI_LINT_VERSION }}
73+
74+
- name: Run golangci-lint
75+
if: false
76+
run: |
77+
echo "Running comprehensive linting..."
78+
$(go env GOPATH)/bin/golangci-lint run --timeout=10m ./...
79+
80+
- name: Run tests
81+
run: |
82+
echo "Running tests..."
83+
if [ -n "$(find . -name '*_test.go')" ]; then
84+
go test -v -race -coverprofile=coverage.out ./...
85+
echo "✅ Tests completed"
86+
else
87+
echo "ℹ️ No tests found, skipping test execution"
88+
fi
89+
90+
- name: Check for security vulnerabilities
91+
if: false
92+
run: |
93+
echo "Installing govulncheck..."
94+
go install golang.org/x/vuln/cmd/govulncheck@latest
95+
echo "Running vulnerability check..."
96+
$(go env GOPATH)/bin/govulncheck ./...
97+
echo "✅ Vulnerability check completed"
98+
99+
- name: Run security-focused linting
100+
if: false
101+
run: |
102+
echo "Running security-focused analysis..."
103+
$(go env GOPATH)/bin/golangci-lint run --enable=gosec --timeout=5m ./...
104+
echo "✅ Security analysis completed"
105+
106+
build-validation:
107+
name: Multi-Platform Build Validation
108+
runs-on: ubuntu-latest
109+
needs: quality-check
110+
defaults:
111+
run:
112+
working-directory: ./installer/go
113+
114+
strategy:
115+
matrix:
116+
goos: [linux, windows, darwin]
117+
goarch: [amd64, arm64]
118+
exclude:
119+
- goos: windows
120+
goarch: arm64
121+
include:
122+
- goos: linux
123+
goarch: arm
124+
125+
steps:
126+
- name: Checkout code
127+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
128+
129+
- name: Set up Go
130+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
131+
with:
132+
go-version: ${{ env.GO_VERSION }}
133+
134+
- name: Cache Go modules
135+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
136+
with:
137+
path: |
138+
~/.cache/go-build
139+
~/go/pkg/mod
140+
key: ${{ runner.os }}-go-${{ hashFiles('installer/go/go.sum') }}
141+
restore-keys: |
142+
${{ runner.os }}-go-
143+
144+
- name: Download dependencies
145+
run: go mod download
146+
147+
- name: Build binary
148+
env:
149+
GOOS: ${{ matrix.goos }}
150+
GOARCH: ${{ matrix.goarch }}
151+
VERSION: 'ci-${{ github.run_id }}'
152+
run: |
153+
echo "Building for $GOOS/$GOARCH..."
154+
BINARY_NAME="flowfuse-device-installer-${{ matrix.goos }}-${{ matrix.goarch }}"
155+
if [ "${{ matrix.goos }}" == "windows" ]; then
156+
BINARY_NAME="${BINARY_NAME}.exe"
157+
fi
158+
159+
# Build with optimized flags
160+
go build -ldflags "-X main.version=$VERSION -s -w" -o $BINARY_NAME main.go
161+
162+
# Verify the binary was created
163+
if [ ! -f "$BINARY_NAME" ]; then
164+
echo "❌ Binary was not created: $BINARY_NAME"
165+
exit 1
166+
fi
167+
168+
echo "✅ Binary created: $BINARY_NAME"
169+
170+
# Basic execution test - verify binary can execute --help
171+
echo "Running basic execution test..."
172+
if [ "${{ matrix.goos }}" = "linux" ] && [ "${{ matrix.goarch }}" = "amd64" ]; then
173+
chmod +x "$BINARY_NAME"
174+
if ./"$BINARY_NAME" --help >/dev/null 2>&1; then
175+
echo "✅ Basic execution test passed: Binary can execute --help"
176+
else
177+
echo "❌ Basic execution test failed: Binary cannot execute --help"
178+
exit 1
179+
fi
180+
else
181+
echo "ℹ️ Skipping basic execution test for cross-compiled binary (${{ matrix.goos }}/${{ matrix.goarch }})"
182+
fi
183+
184+
# Clean up binary after validation (no artifact storage)
185+
rm "$BINARY_NAME"
186+
echo "✅ Build validation completed for ${{ matrix.goos }}/${{ matrix.goarch }}"

0 commit comments

Comments
 (0)