Skip to content

Commit 2ed03e2

Browse files
r0ohafzaclaude
andcommitted
Use installed Alloy binary instead of docker in CI check
The Alloy team documents `alloy fmt --test` and `alloy validate` as the CI contract (exit codes signal pass/fail) but ships no dedicated setup/fmt/validate GitHub Action, so we invoke the CLI ourselves. Running it through `docker run` required overriding the image entrypoint and a mounted-volume find loop; installing the released binary is simpler and faster. Download the alloy-linux-amd64 release matching the version pinned in the Dockerfile (keeping CI in parity with production), then run `alloy fmt -t` per file and `alloy validate` over the config directory. The format loop uses `find` rather than a bash globstar so it can never silently match zero files. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8e93702 commit 2ed03e2

1 file changed

Lines changed: 34 additions & 29 deletions

File tree

.github/workflows/alloy-check.yaml

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,43 +27,48 @@ jobs:
2727
version="$(grep -Eo 'grafana/alloy:[^ ]+' Dockerfile | cut -d: -f2)"
2828
echo "version=${version}" >> "$GITHUB_OUTPUT"
2929
30+
- name: "Install Alloy"
31+
run: |
32+
version="${{ steps.alloy.outputs.version }}"
33+
curl -fsSL -o alloy.zip \
34+
"https://github.com/grafana/alloy/releases/download/${version}/alloy-linux-amd64.zip"
35+
unzip -q alloy.zip
36+
binary="$(find . -maxdepth 1 -type f -name 'alloy-linux-amd64*' | head -n1)"
37+
sudo install -m 0755 "${binary}" /usr/local/bin/alloy
38+
rm -f alloy.zip "${binary}"
39+
alloy --version
40+
3041
# alloy fmt operates on a single file, so we iterate. The -t flag makes fmt
3142
# exit non-zero when a file is not formatted correctly without writing any
3243
# changes, which is exactly what we want for a check.
3344
- name: "Check Formatting"
3445
run: |
35-
docker run --rm --entrypoint sh \
36-
-v "${PWD}/config:/config" \
37-
"grafana/alloy:${{ steps.alloy.outputs.version }}" -c '
38-
rc=0
39-
for f in $(find /config -name "*.alloy"); do
40-
if ! alloy fmt -t "$f"; then
41-
echo "not formatted: $f (run: alloy fmt -w $f)"
42-
rc=1
43-
fi
44-
done
45-
exit $rc
46-
'
46+
rc=0
47+
while IFS= read -r f; do
48+
if ! alloy fmt -t "$f"; then
49+
echo "not formatted: $f (fix with: alloy fmt -w $f)"
50+
rc=1
51+
fi
52+
done < <(find config -type f -name '*.alloy')
53+
exit $rc
4754
4855
# Validate the whole config directory at once, since the processor pipeline
4956
# references components across files. The env vars below are dummy values
5057
# that only need to be present for sys.env() references to resolve; validate
5158
# checks config structure and does not connect to any of these endpoints.
5259
- name: "Validate Configuration"
53-
run: |
54-
docker run --rm \
55-
-v "${PWD}/config:/config" \
56-
-e AWS_REGION="us-west-2" \
57-
-e ENVIRONMENT="ci" \
58-
-e GRAFANA_CLOUD_API_KEY="ci" \
59-
-e PROMETHEUS_REMOTE_WRITE_URL="https://example.com" \
60-
-e PROMETHEUS_USERNAME="ci" \
61-
-e KAYRON_DISCOVERY_HOST="kayron" \
62-
-e KAYRON_DISCOVERY_PORT="8080" \
63-
-e SERVER_DISCOVERY_HOST="server" \
64-
-e SERVER_DISCOVERY_PORT="8080" \
65-
-e SPECTA_DISCOVERY_HOST="specta" \
66-
-e SPECTA_DISCOVERY_PORT="8080" \
67-
-e WORKER_DISCOVERY_HOST="worker" \
68-
-e WORKER_DISCOVERY_PORT="8080" \
69-
"grafana/alloy:${{ steps.alloy.outputs.version }}" validate /config
60+
env:
61+
AWS_REGION: "us-west-2"
62+
ENVIRONMENT: "ci"
63+
GRAFANA_CLOUD_API_KEY: "ci"
64+
PROMETHEUS_REMOTE_WRITE_URL: "https://example.com"
65+
PROMETHEUS_USERNAME: "ci"
66+
KAYRON_DISCOVERY_HOST: "kayron"
67+
KAYRON_DISCOVERY_PORT: "8080"
68+
SERVER_DISCOVERY_HOST: "server"
69+
SERVER_DISCOVERY_PORT: "8080"
70+
SPECTA_DISCOVERY_HOST: "specta"
71+
SPECTA_DISCOVERY_PORT: "8080"
72+
WORKER_DISCOVERY_HOST: "worker"
73+
WORKER_DISCOVERY_PORT: "8080"
74+
run: alloy validate config/

0 commit comments

Comments
 (0)