Repository navigation
118 lines (96 loc) · 2.75 KB
/
Copy pathci.yml
File metadata and controls
118 lines (96 loc) · 2.75 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
# Copyright © 2026 envaar
# SPDX-License-Identifier: Apache-2.0
name: CI
on:
push:
pull_request:
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
hygiene:
name: Hygiene
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Format check
run: |
if [ -n "$(gofmt -l .)" ]; then
echo "gofmt found unformatted Go files:"
gofmt -l .
exit 1
fi
- name: Go mod tidy check
run: |
go mod tidy
git diff --exit-code go.mod go.sum
- name: Lint smoke test
run: |
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT INT TERM
rsync -a --exclude='.git' --exclude='bin' --exclude='dist' --exclude='.env' --exclude='examples' ./ "$tmpdir"/
cd "$tmpdir"
go run ./cmd/vaar lint
- name: Lint smoke test with JSON output
run: |
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT INT TERM
rsync -a --exclude='.git' --exclude='bin' --exclude='dist' --exclude='.env' --exclude='examples' ./ "$tmpdir"/
cd "$tmpdir"
go run ./cmd/vaar lint --json
- name: Fix smoke test
run: |
binary="$RUNNER_TEMP/vaar"
go build -buildvcs=false -o "$binary" ./cmd/vaar
tmpdir="$(mktemp -d)"
expected="$RUNNER_TEMP/expected.env"
printf 'KEY=value\n' > "$expected"
printf 'KEY=value \n\n\n' > "$tmpdir/.env"
(cd "$tmpdir" && "$binary" lint --fix)
if ! cmp -s "$expected" "$tmpdir/.env"; then
echo "unexpected normalized content:"
cat -vet "$tmpdir/.env"
exit 1
fi
build-test:
name: Build and test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Vet
run: go vet ./...
- name: Test
run: go test ./...
- name: Build
run: go build -buildvcs=false -o "$RUNNER_TEMP/vaar$(go env GOEXE)" ./cmd/vaar
- name: Smoke version
run: |
binary="$RUNNER_TEMP/vaar$(go env GOEXE)"
"$binary" --version