forked from CircleCI-Public/chunk-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
204 lines (175 loc) · 6.42 KB
/
Taskfile.yml
File metadata and controls
204 lines (175 loc) · 6.42 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
version: '3'
vars:
RESULTS_DIR: test-reports
TEST_REPORT: test-reports/tests.xml
LINT_REPORT: test-reports/lint.xml
tasks:
build:
desc: Build the chunk binary
cmds:
- go build -o dist/chunk .
test:
desc: Run the tests
vars:
ARGS: '{{default "./..." .CLI_ARGS}}'
cmds:
- go tool gotestsum -- -race {{.ARGS}}
lint:
desc: Run `golangci-lint run` to lint the code
summary: Lint the project with golangci-lint
vars:
ARGS: '{{default "./..." .CLI_ARGS}}'
cmds:
- go tool golangci-lint run {{.ARGS}}
- uv run --project harness pylint --rcfile harness/pyproject.toml harness/environment.py
fmt:
desc: Format the code
vars:
ARGS: '{{default "." .CLI_ARGS}}'
cmds:
- go tool gosimports -local "$(go list -m)" -w {{.ARGS}}
mod-tidy:
desc: Run 'go mod tidy' to clean up module files.
cmds:
- go mod tidy -v
dev-install:
desc: Build from source and install to ~/.local/bin
cmds:
- task: build
- mkdir -p ${HOME}/.local/bin
- cp dist/chunk ${HOME}/.local/bin
acceptance-test:
desc: Run acceptance tests
vars:
ARGS: '{{default "./acceptance/..." .CLI_ARGS}}'
cmds:
- go tool gotestsum -- -race {{.ARGS}}
env-harness:
desc: |
Run chunk sandbox env/build against target repos, using Claude to improve
envbuilder on failure. Args are passed through to harness/environment.py.
Examples:
task env-harness # all known repos
task env-harness -- --repo flask # single nickname
task env-harness -- --repo https://github.com/x/y # any Git URL
task env-harness -- --repo flask --timeout 1200
cmds:
- uv run --project harness harness/environment.py {{.CLI_ARGS}}
release:
desc: Tag, build, and publish a release (tag → goreleaser → NUR)
vars:
VERSION: '{{.VERSION | default ""}}'
cmds:
- task: tag
vars: { VERSION: '{{.VERSION}}' }
- goreleaser release --clean
generate:
desc: Run generation of any generated code
vars:
ARGS: '{{default "./..." .CLI_ARGS}}'
cmds:
- go generate -x {{.ARGS}}
mod-download:
desc: Run 'go mod download' to retrieve module files.
cmds:
- go mod download -x
nur:publish:
desc: Publish the Nix package to NUR (Nix User Repository)
vars:
NUR_DIR: /tmp/nur-packages
cmds:
# Clone NUR packages repository
- git clone https://github.com/CircleCI-Public/nur-packages.git {{.NUR_DIR}}
# Configure git
- git -C {{.NUR_DIR}} config user.name "CircleCI Bot"
- git -C {{.NUR_DIR}} config user.email "noreply@circleci.com"
# Create package directory and copy the template generated by GoReleaser
- mkdir -p {{.NUR_DIR}}/pkgs/chunk
- cp dist/nix/pkgs/chunk/default.nix {{.NUR_DIR}}/pkgs/chunk/
# Update URLs to point to the release tag
- sed -i "s|/v[0-9.]*-next/|/${CHUNK_TAG}/|g" {{.NUR_DIR}}/pkgs/chunk/default.nix
- sed -i "s|/v[0-9.][0-9.]*[0-9]/|/${CHUNK_TAG}/|g" {{.NUR_DIR}}/pkgs/chunk/default.nix
# Calculate and update SHA256 hashes from local archives
- |
echo "Calculating SHA256 hashes from local archives..."
for platform in "Linux_x86_64:x86_64-linux" "Linux_arm64:aarch64-linux" "Darwin_x86_64:x86_64-darwin" "Darwin_arm64:aarch64-darwin"; do
archive=$(echo $platform | cut -d: -f1)
nixname=$(echo $platform | cut -d: -f2)
archive_path="dist/chunk-cli_${archive}.tar.gz"
echo "Hashing $archive_path..."
sha=$(nix-hash --type sha256 --flat --base32 "$archive_path")
sed -i "/shaMap = {/,/^ };/s|${nixname} = \"[^\"]*\"|${nixname} = \"${sha}\"|" {{.NUR_DIR}}/pkgs/chunk/default.nix
done
# Update version
- sed -i "s|version = \"[^\"]*\"|version = \"${CHUNK_TAG#v}\"|g" {{.NUR_DIR}}/pkgs/chunk/default.nix
# Copy flake.nix if it doesn't exist
- |
if [ ! -f {{.NUR_DIR}}/flake.nix ]; then
cp flake.nix {{.NUR_DIR}}/
git -C {{.NUR_DIR}} add flake.nix
fi
# Commit and push
- git -C {{.NUR_DIR}} add pkgs/chunk/default.nix
- git -C {{.NUR_DIR}} commit -m "Update chunk to ${CHUNK_TAG}" || echo "No changes to commit"
- git -C {{.NUR_DIR}} push https://${GITHUB_TOKEN}@github.com/CircleCI-Public/nur-packages.git main
build-unikraft-image:
desc: Build the Unikraft unikernel image
cmds:
- kraft pkg --plat kraftcloud --arch x86_64 --name index.unikraft.io/circleci/chunk-sandbox:latest
publish-unikraft-image:
desc: Publish the Unikraft unikernel image
cmds:
- kraft pkg push index.unikraft.io/circleci/chunk-sandbox:latest
# Tasks below here are intended mainly to be run as part of CI
ci:lint:
desc: Run `golangci-lint run` to lint the code, outputting a report.
cmds:
- mkdir -p "{{.RESULTS_DIR}}"
- task: lint
vars:
CLI_ARGS: |
./... \
--output.junit-xml.path "{{.LINT_REPORT}}" --output.junit-xml.extended \
--output.text.path=stdout --output.text.colors=true
ci:test:
desc: Run the tests and output the test results
vars:
ARGS: '{{default "./..." .CLI_ARGS}}'
cmds:
- mkdir -p {{.RESULTS_DIR}}
- go tool gotestsum --junitfile="{{.TEST_REPORT}}" -- -race -count=1 {{.ARGS}}
ci:diff:
desc: Check no diffs
cmds:
- task: generate
- task: fmt
- task: mod-tidy
- git diff --exit-code
tag:
desc: Create the next git tag (vX.Y.Z), optionally specifying a version as X.Y.Z
vars:
VERSION: '{{.VERSION | default ""}}'
cmds:
- |
git fetch --force --tags
if [ -n "{{.VERSION}}" ]; then
TAG="v{{.VERSION}}"
if git tag | grep -q "^${TAG}$"; then
echo "Error: tag ${TAG} already exists" >&2
exit 1
fi
else
LATEST=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' \
| sort -t. -k1,1V -k2,2n -k3,3n \
| tail -1)
if [ -z "$LATEST" ]; then
echo "Error: no existing vX.Y.Z tags found" >&2
exit 1
fi
PATCH=$(echo "$LATEST" | awk -F. '{print $3}')
TAG="${LATEST%.*}.$((PATCH + 1))"
fi
echo "Tagging version: ${TAG}"
git tag "${TAG}"
git push origin ${TAG}
echo "${TAG}" > /tmp/chunk-release-tag