Skip to content

Commit 88ba8d6

Browse files
sylrclaude
andcommitted
chore: backport CI improvements from main
- default action: disable nix cache (downloading from cache.nixos.org is faster), use go env for proper GOCACHE/GOMODCACHE paths, add golangci-lint cache - all workflows: use treeless clones (filter: tree:0) for faster checkout - main.yml: add build provenance attestations, upload goreleaser metadata, update Deploy job to tailscale v4 with OIDC auth - benchmark workflows: fix report path, allow workflow_dispatch trigger for comparison, fix trailing whitespace Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5dc50f7 commit 88ba8d6

File tree

5 files changed

+105
-50
lines changed

5 files changed

+105
-50
lines changed

.github/actions/default/action.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,24 @@ runs:
99
steps:
1010
- name: Install Nix
1111
uses: cachix/install-nix-action@v31
12-
- name: Cache dependencies
13-
uses: nix-community/cache-nix-action@v6
14-
with:
15-
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/flake.nix', '**/flake.lock') }}
16-
restore-prefixes-first-match: nix-${{ runner.os }}-
17-
- name: Load dependencies
12+
## Disabling cache for now, as it's slowing down the build. Downloading nix
13+
## dependencies from cache.nixos.org is faster than restoring from the cache.
14+
#- name: Cache dependencies
15+
# uses: nix-community/cache-nix-action@v6
16+
# with:
17+
# primary-key: nix-${{ runner.os }}-${{ hashFiles('**/flake.nix', '**/flake.lock') }}
18+
# restore-prefixes-first-match: nix-${{ runner.os }}-
19+
- name: go env
20+
id: go-env
1821
shell: bash
19-
run: nix develop --install
22+
run: |
23+
nix develop --command bash -c "go env | sed -E \"s/^([^=]+)='(.*)'\$/\1=\2/\"" >> "$GITHUB_OUTPUT"
2024
- uses: actions/cache@v4
2125
with:
2226
path: |
23-
~/.cache/go-build
24-
/tmp/go/pkg/mod/
27+
${{ steps.go-env.outputs.GOCACHE }}
28+
${{ steps.go-env.outputs.GOMODCACHE }}
29+
~/.cache/golangci-lint
2530
key: ${{ runner.os }}-${{ github.job }}-go-${{ hashFiles('**/go.sum') }}
2631
restore-keys: |
27-
${{ runner.os }}-${{ github.job }}-go-
32+
${{ runner.os }}-${{ github.job }}-go-

.github/workflows/benchmark-comparison.yml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ on:
33
workflow_dispatch:
44
inputs:
55
bench:
6-
description: 'Benchmarks to run'
6+
description: "Benchmarks to run"
77
required: false
8-
default: '.'
8+
default: "."
99
parallelism:
10-
description: 'Number of parallel benchmarks to run'
10+
description: "Number of parallel benchmarks to run"
1111
required: false
1212
default: 5
1313
duration:
14-
description: 'Duration of each benchmark'
14+
description: "Duration of each benchmark"
1515
required: false
16-
default: '10s'
16+
default: "10s"
1717
count:
18-
description: 'Number of times to run each benchmark '
18+
description: "Number of times to run each benchmark "
1919
required: false
2020
default: 1
2121
pull_request:
22-
types: [ assigned, opened, synchronize, reopened, labeled ]
22+
types: [assigned, opened, synchronize, reopened, labeled]
2323

2424
concurrency:
2525
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
@@ -28,11 +28,12 @@ concurrency:
2828
jobs:
2929
BenchmarkCompare:
3030
runs-on: "github-001"
31-
if: contains(github.event.pull_request.labels.*.name, 'benchmarks')
31+
if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'benchmarks')
3232
steps:
33-
- uses: 'actions/checkout@v4'
33+
- uses: actions/checkout@v4
3434
with:
3535
fetch-depth: 0
36+
filter: tree:0 # treeless clone, faster to clone as history and blobs are only fetched when needed.
3637
- name: Setup Env
3738
uses: ./.github/actions/env
3839
with:
@@ -41,15 +42,15 @@ jobs:
4142
/nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes"
4243
develop --impure --command just
4344
--justfile ./test/performance/justfile
44-
--working-directory ./test/performance
45+
--working-directory ./test/performance
4546
writes compare ${{ inputs.bench }} ${{ inputs.parallelism }} ${{ inputs.duration }} ${{ inputs.count }}
4647
- run: >
4748
/nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes"
48-
develop --impure --command just
49-
--justfile ./test/performance/justfile
50-
--working-directory ./test/performance
49+
develop --impure --command just
50+
--justfile ./test/performance/justfile
51+
--working-directory ./test/performance
5152
writes graphs
5253
- uses: actions/upload-artifact@v4
5354
with:
5455
name: graphs
55-
path: test/performance/report
56+
path: test/performance/pkg/write/report

.github/workflows/benchmark.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ on:
33
workflow_dispatch:
44
inputs:
55
bench:
6-
description: 'Benchmarks to run'
6+
description: "Benchmarks to run"
77
required: false
8-
default: '.'
8+
default: "."
99
parallelism:
10-
description: 'Number of parallel benchmarks to run'
10+
description: "Number of parallel benchmarks to run"
1111
required: false
1212
default: 5
1313
duration:
14-
description: 'Duration of each benchmark'
14+
description: "Duration of each benchmark"
1515
required: false
16-
default: '10s'
16+
default: "10s"
1717

1818
concurrency:
1919
group: ${{ github.workflow }}-${{ github.ref }}
@@ -23,9 +23,10 @@ jobs:
2323
Benchmark:
2424
runs-on: "github-001"
2525
steps:
26-
- uses: 'actions/checkout@v4'
26+
- uses: actions/checkout@v4
2727
with:
2828
fetch-depth: 0
29+
filter: tree:0 # treeless clone, faster to clone as history and blobs are only fetched when needed.
2930
- name: Setup Env
3031
uses: ./.github/actions/env
3132
with:
@@ -34,15 +35,15 @@ jobs:
3435
/nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes"
3536
develop --impure --command just
3637
--justfile ./test/performance/justfile
37-
--working-directory ./test/performance
38+
--working-directory ./test/performance
3839
writes run ${{ inputs.bench }} ${{ inputs.parallelism }} ${{ inputs.duration }} 1
3940
- run: >
4041
/nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes"
41-
develop --impure --command just
42-
--justfile ./test/performance/justfile
43-
--working-directory ./test/performance
42+
develop --impure --command just
43+
--justfile ./test/performance/justfile
44+
--working-directory ./test/performance
4445
writes graphs
4546
- uses: actions/upload-artifact@v4
4647
with:
4748
name: graphs
48-
path: test/performance/report
49+
path: test/performance/pkg/write/report

.github/workflows/main.yml

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ jobs:
3030
GOPATH: /tmp/go
3131
GOLANGCI_LINT_CACHE: /tmp/golangci-lint
3232
steps:
33-
- uses: 'actions/checkout@v4'
33+
- uses: actions/checkout@v4
3434
with:
3535
fetch-depth: 0
36+
filter: tree:0 # treeless clone, faster to clone as history and blobs are only fetched when needed.
3637
- name: Setup Env
3738
uses: ./.github/actions/default
3839
with:
@@ -45,7 +46,7 @@ jobs:
4546
id: changed-files
4647
shell: bash
4748
run: |
48-
hasChanged=$(git status --porcelain)
49+
hasChanged=$(git status --porcelain)
4950
if (( $(echo ${#hasChanged}) != 0 )); then
5051
git status
5152
echo "There are changes in the repository"
@@ -58,9 +59,10 @@ jobs:
5859
env:
5960
GOPATH: /tmp/go
6061
steps:
61-
- uses: 'actions/checkout@v4'
62+
- uses: actions/checkout@v4
6263
with:
6364
fetch-depth: 0
65+
filter: tree:0 # treeless clone, faster to clone as history and blobs are only fetched when needed.
6466
- name: Setup Env
6567
uses: ./.github/actions/default
6668
with:
@@ -76,6 +78,9 @@ jobs:
7678

7779
GoReleaser:
7880
runs-on: "shipfox-4vcpu-ubuntu-2404"
81+
permissions:
82+
id-token: write
83+
attestations: write
7984
if: contains(github.event.pull_request.labels.*.name, 'build-images') || github.ref == 'refs/heads/main' || github.event_name == 'merge_group'
8085
steps:
8186
- name: Set up QEMU
@@ -86,9 +91,10 @@ jobs:
8691
with:
8792
github-token: ${{ secrets.GITHUB_TOKEN }}
8893
version: "latest"
89-
- uses: 'actions/checkout@v4'
94+
- uses: actions/checkout@v4
9095
with:
9196
fetch-depth: 0
97+
filter: tree:0 # treeless clone, faster to clone as history and blobs are only fetched when needed.
9298
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
9399
- name: Setup Env
94100
uses: ./.github/actions/default
@@ -112,37 +118,78 @@ jobs:
112118
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
113119
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
114120
121+
- uses: actions/upload-artifact@v4
122+
with:
123+
name: goreleaser-metadata
124+
path: |
125+
dist/*.json
126+
dist/ledger_checksums.txt
127+
retention-days: 7
128+
compression-level: 0
129+
130+
# Generate attestations for the goreleaser output archives
131+
- uses: actions/attest-build-provenance@v2
132+
with:
133+
subject-checksums: ./dist/ledger_checksums.txt
134+
# Generate attestations for the goreleaser output binaries
135+
- uses: actions/attest-build-provenance@v2
136+
with:
137+
subject-path: ./dist/*/**
138+
# Extract image metadata from the artifacts.json file
139+
- run: |
140+
jq -r '[ .[]|select(.type=="Docker Manifest") | .extra.Digest ] | to_entries | .[] | ( "digest"+ (.key | tostring) + "=" + .value )' < dist/artifacts.json >> "$GITHUB_OUTPUT"
141+
jq -r '[ .[]|select(.type=="Docker Manifest") | .name | split(":")[0] ] | to_entries | .[] | ( "name"+ (.key | tostring) + "=" + .value )' < dist/artifacts.json >> "$GITHUB_OUTPUT"
142+
id: image_metadata
143+
# Generate attestations for docker images
144+
- uses: actions/attest-build-provenance@v2
145+
with:
146+
subject-digest: ${{ steps.image_metadata.outputs.digest0 }}
147+
subject-name: ${{ steps.image_metadata.outputs.name0 }}
148+
push-to-registry: true
149+
- uses: actions/attest-build-provenance@v2
150+
with:
151+
subject-digest: ${{ steps.image_metadata.outputs.digest1 }}
152+
subject-name: ${{ steps.image_metadata.outputs.name1 }}
153+
push-to-registry: true
115154

116155
Deploy:
117-
runs-on: "shipfox-2vcpu-ubuntu-2404"
156+
runs-on: ubuntu-24.04
118157
if: github.ref == 'refs/heads/main'
119158
environment: staging
159+
permissions:
160+
id-token: write
120161
needs:
121162
- GoReleaser
122163
- Tests
123164
steps:
124165
- name: Tailscale
125-
uses: tailscale/github-action@v3
166+
uses: tailscale/github-action@v4
126167
with:
127-
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
128-
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
129-
tags: tag:ci
168+
oauth-client-id: ${{ secrets.TS_OIDC_OAUTH_CLIENT_ID }}
169+
audience: ${{ secrets.TS_OIDC_AUDIENCE }}
170+
tags: ${{ vars.TS_TAGS }}
171+
version: ${{ vars.TS_VERSION }}
172+
args: ${{ vars.TS_ARGS }}
173+
retry: ${{ vars.TS_RETRY }}
174+
timeout: ${{ vars.TS_TIMEOUT }}
175+
ping: ${{ vars.TS_PING }}
130176
- uses: earthly/actions-setup@v1
131177
with:
132178
github-token: ${{ secrets.GITHUB_TOKEN }}
133179
version: "latest"
134-
- uses: 'actions/checkout@v4'
180+
- uses: actions/checkout@v4
135181
with:
136182
fetch-depth: 0
183+
filter: tree:0 # treeless clone, faster to clone as history and blobs are only fetched when needed.
137184
- name: "Deploy in staging"
138185
env:
139186
TAG: ${{ github.sha }}
140187
COMPONENT: ledger
141188
ARGOCD_REGION_AUTH_TOKEN: ${{ secrets.ARGOCD_REGION_AUTH_TOKEN }}
142189
run: >
143-
earthly
144-
--no-output
190+
earthly
191+
--no-output
145192
--secret AUTH_TOKEN=$ARGOCD_REGION_AUTH_TOKEN
146193
+deploy-staging
147194
--TAG=$TAG
148-
--COMPONENT=$COMPONENT
195+
--COMPONENT=$COMPONENT

.github/workflows/releases.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ jobs:
1010
GoReleaser:
1111
runs-on: "shipfox-4vcpu-ubuntu-2404"
1212
steps:
13-
- uses: 'actions/checkout@v4'
13+
- uses: actions/checkout@v4
1414
with:
1515
fetch-depth: 0
16+
filter: tree:0 # treeless clone, faster to clone as history and blobs are only fetched when needed.
1617
- name: Setup Env
1718
uses: ./.github/actions/default
1819
with:
@@ -33,4 +34,4 @@ jobs:
3334
GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
3435
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
3536
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
36-
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
37+
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

0 commit comments

Comments
 (0)