Skip to content

Commit c8095b9

Browse files
committed
ci: switch to flow gha
1 parent 7a27cdb commit c8095b9

File tree

6 files changed

+241
-137
lines changed

6 files changed

+241
-137
lines changed

.github/workflows/ci.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
8+
permissions:
9+
contents: read # for actions/checkout to fetch code
10+
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
lint:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: "^1.24"
25+
- uses: jahvon/flow-action@v1.0.0-beta1
26+
with:
27+
executable: 'lint --param CI=true'
28+
timeout: '5m'
29+
flow-version: 'main'
30+
- name: Upload SARIF file
31+
uses: github/codeql-action/upload-sarif@v3
32+
with:
33+
sarif_file: lint.sarif
34+
category: golangci-lint
35+
36+
tests:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
- name: Set up Go
41+
uses: actions/setup-go@v5
42+
with:
43+
go-version: "^1.24"
44+
- uses: jahvon/flow-action@v1.0.0-beta1
45+
with:
46+
executable: 'test --param CI=true'
47+
timeout: '5m'
48+
flow-version: 'main'
49+
- name: Upload to codecov
50+
uses: codecov/codecov-action@v3
51+
env:
52+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
53+
with:
54+
file: coverage.out
55+
fail_ci_if_error: true
56+
57+
validate-generated:
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v4
61+
- name: Set up Go
62+
uses: actions/setup-go@v5
63+
with:
64+
go-version: "^1.24"
65+
- name: Install mockgen
66+
run: go install go.uber.org/mock/mockgen@v0.4.0
67+
- uses: jahvon/flow-action@v1.0.0-beta1
68+
with:
69+
executable: 'generate'
70+
timeout: '10m'
71+
flow-version: 'main'
72+
- name: Check for uncommitted changes
73+
uses: jahvon/flow-action@v1.0.0-beta1
74+
with:
75+
executable: 'validate generated'
76+
timeout: '2m'
77+
flow-version: 'main'
78+
79+
security:
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v4
83+
- name: Set up Go
84+
uses: actions/setup-go@v5
85+
with:
86+
go-version: "^1.24"
87+
- uses: jahvon/flow-action@v1.0.0-beta1
88+
with:
89+
executable: 'scan security'
90+
timeout: '10m'
91+
flow-version: 'main'
92+
- name: Upload govuln SARIF file
93+
uses: github/codeql-action/upload-sarif@v3
94+
with:
95+
sarif_file: govuln.sarif

.github/workflows/validate.yaml

Lines changed: 0 additions & 79 deletions
This file was deleted.

dev.flow

Lines changed: 0 additions & 55 deletions
This file was deleted.

execs.flow

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# yaml-language-server: $schema=https://flowexec.io/schemas/flowfile_schema.json
2+
tags: [development]
3+
executables:
4+
- verb: validate
5+
description: Run all development checks
6+
serial:
7+
params:
8+
- envKey: COLORFGBG
9+
text: 15;0
10+
- envKey: COLORTERM
11+
text: truecolor
12+
- envKey: TERM
13+
text: xterm-256color
14+
execs:
15+
- ref: generate
16+
- ref: lint
17+
- ref: test tui
18+
- ref: validate generated
19+
- cmd: echo "✅ All development checks passed"
20+
21+
- verb: test
22+
name: tui
23+
aliases: [go]
24+
tags: [go]
25+
description: Run tests with coverage
26+
serial:
27+
dir: //
28+
execs:
29+
# TODO: Add -race flag when the container becomes thread safe
30+
- cmd: |
31+
set -e
32+
echo "Running Go unit tests..."
33+
if [ "$CI" = "true" ]; then
34+
echo "Running Go unit tests with coverage..."
35+
go test -coverprofile=coverage.out -covermode=atomic ./...
36+
else
37+
go test ./...
38+
fi
39+
echo "Unit tests completed"
40+
retries: 3
41+
42+
- verb: generate
43+
tags: [go]
44+
exec:
45+
dir: //
46+
cmd: |
47+
echo "Generating go CLI code..."
48+
go generate ./...
49+
echo "All go code generated successfully"
50+
51+
- verb: validate
52+
name: generated
53+
description: Check for uncommitted generated files
54+
exec:
55+
dir: //
56+
cmd: |
57+
echo "Checking for uncommitted generated files..."
58+
59+
if [ -n "$(git status --porcelain)" ]; then
60+
echo "❌ Generated files are not up to date!"
61+
echo "Please run 'flow generate' and commit the changes."
62+
echo ""
63+
echo "Uncommitted changes:"
64+
git status --porcelain
65+
exit 1
66+
else
67+
echo "✅ All generated files are up to date"
68+
fi
69+
70+
- verb: test
71+
name: snapshot
72+
description: Run the snapshot tests
73+
exec:
74+
dir: //
75+
params:
76+
- envKey: COLORFGBG
77+
text: 15;0
78+
- envKey: COLORTERM
79+
text: truecolor
80+
- envKey: TERM
81+
text: xterm-256color
82+
args:
83+
- envKey: BUILDER
84+
pos: 1
85+
default: podman
86+
cmd: |
87+
$BUILDER run --rm -it -v "$PWD":/go/src/app -w /go/src/app golang:1.23-bookworm go test ./container_test.go
88+
89+
- verb: run
90+
name: sample
91+
description: Run the sample container program
92+
visibility: hidden # TODO: fix running of tea programs from within the container
93+
exec:
94+
dir: //
95+
args:
96+
- envKey: VIEW
97+
pos: 1
98+
default: frame
99+
logMode: text
100+
cmd: go run ./sample --view $VIEW
101+
102+
- verb: lint
103+
tags: [go]
104+
description: Run linters and formatters
105+
parallel:
106+
dir: //
107+
failFast: false
108+
execs:
109+
- cmd: go fmt ./...
110+
- cmd: go mod tidy
111+
- cmd: |
112+
if ! command -v golangci-lint &> /dev/null; then
113+
echo "Installing golangci-lint..."
114+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s v2.1.6
115+
export PATH="$PATH:./bin"
116+
fi
117+
118+
if [ "$CI" = "true" ]; then
119+
echo "Running golangci-lint with sarif output..."
120+
golangci-lint run ./... --fix --output.sarif.path lint.sarif
121+
else
122+
golangci-lint run ./... --fix
123+
fi
124+
125+
- verb: scan
126+
name: security
127+
tags: [security, go]
128+
description: Run security scanning with govulncheck
129+
exec:
130+
dir: //
131+
cmd: |
132+
if ! command -v govulncheck &> /dev/null; then
133+
echo "Installing govulncheck..."
134+
go install golang.org/x/vuln/cmd/govulncheck@latest
135+
fi
136+
137+
if [ "$CI" = "true" ]; then
138+
govulncheck -format sarif ./... > govuln.sarif
139+
echo "Security scan completed. Results saved to govuln.sarif"
140+
else
141+
govulncheck ./...
142+
echo "Security scan completed. No vulnerabilities found."
143+
fi

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ require (
5050
github.com/yuin/goldmark-emoji v1.0.3 // indirect
5151
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
5252
golang.org/x/mod v0.18.0 // indirect
53-
golang.org/x/net v0.27.0 // indirect
53+
golang.org/x/net v0.34.0 // indirect
5454
golang.org/x/sync v0.13.0 // indirect
5555
golang.org/x/sys v0.33.0 // indirect
5656
golang.org/x/text v0.23.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM
112112
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
113113
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
114114
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
115-
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
116-
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
115+
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
116+
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
117117
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
118118
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
119119
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

0 commit comments

Comments
 (0)