Skip to content

Commit f87aa5a

Browse files
hjmjohnsonclaude
andcommitted
ENH: Convert from Docker action to composite action
Replace the Docker-based action (FROM ubuntu:18.04) with a composite action that runs directly on the GitHub Actions runner. This fixes two recurring CI reliability issues: 1. Docker Hub rate limiting (401/429) pulling ubuntu:18.04 (EOL) which intermittently breaks the linter across all remote modules. 2. Transient pixi download failures (HTTP 502) from the raw curl-pipe-to-bash install method. The composite action uses: - prefix-dev/setup-pixi@v0.9.4 for reliable pixi installation with built-in caching and retry (run-install: false since we only need pixi global install) - curl --retry 3 --retry-delay 30 for resilient downloads - Step outputs instead of env vars for clang-format version passing - Explicit version verification step - Direct runner execution (no Docker pull needed) The Dockerfile and entrypoint.sh are retained for backwards compatibility but are no longer referenced by action.yml. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6d1758b commit f87aa5a

1 file changed

Lines changed: 81 additions & 5 deletions

File tree

action.yml

Lines changed: 81 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,84 @@ inputs:
99
description: 'The Git branch of the ITK repository to fetch .clang-format from.'
1010
default: 'main'
1111
runs:
12-
using: 'docker'
13-
image: 'Dockerfile'
14-
args:
15-
- ${{ inputs.error-message }}
16-
- ${{ inputs.itk-branch }}
12+
using: 'composite'
13+
steps:
14+
- name: Determine clang-format version
15+
id: config
16+
shell: bash
17+
run: |
18+
set -euo pipefail
19+
ITK_BRANCH="${{ inputs.itk-branch }}"
20+
21+
if test "${ITK_BRANCH}" != "release-5.4" -a "${ITK_BRANCH}" != "release"; then
22+
curl --retry 3 --retry-delay 30 --retry-all-errors -fsSL \
23+
"https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK/${ITK_BRANCH}/.pre-commit-config.yaml" \
24+
-o ITK.pre-commit-config.yaml
25+
CLANG_FORMAT_VERSION=$(grep -A 1 "mirrors-clang-format" ITK.pre-commit-config.yaml | tail -n 1 | cut -d: -f2 | tr -d ' v')
26+
echo "clang_format_version=${CLANG_FORMAT_VERSION}" >> $GITHUB_OUTPUT
27+
echo "use_pixi=true" >> $GITHUB_OUTPUT
28+
echo "Detected clang-format version: ${CLANG_FORMAT_VERSION}"
29+
rm -f ITK.pre-commit-config.yaml
30+
else
31+
echo "use_pixi=false" >> $GITHUB_OUTPUT
32+
echo "Using system clang-format for ${ITK_BRANCH} branch"
33+
fi
34+
35+
- name: Install pixi
36+
if: steps.config.outputs.use_pixi == 'true'
37+
uses: prefix-dev/setup-pixi@v0.9.4
38+
with:
39+
run-install: false
40+
41+
- name: Install clang-format
42+
if: steps.config.outputs.use_pixi == 'true'
43+
shell: bash
44+
run: |
45+
set -euo pipefail
46+
pixi global install "clang-format==${{ steps.config.outputs.clang_format_version }}"
47+
echo "$HOME/.pixi/bin" >> $GITHUB_PATH
48+
49+
- name: Verify clang-format
50+
shell: bash
51+
run: |
52+
echo "clang-format location: $(which clang-format)"
53+
clang-format --version
54+
55+
- name: Fetch ITK clang-format configuration
56+
shell: bash
57+
run: |
58+
set -euo pipefail
59+
ITK_BRANCH="${{ inputs.itk-branch }}"
60+
61+
# Use the module's own .clang-format if present, otherwise fetch from ITK
62+
if ! test -f ./.clang-format; then
63+
echo "Downloading ITK .clang-format from ${ITK_BRANCH}"
64+
curl --retry 3 --retry-delay 30 --retry-all-errors -fsSL \
65+
"https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK/${ITK_BRANCH}/.clang-format" \
66+
-o .clang-format
67+
fi
68+
69+
# Fetch the clang-format runner script
70+
curl --retry 3 --retry-delay 30 --retry-all-errors -fsSL \
71+
"https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK/${ITK_BRANCH}/Utilities/Maintenance/clang-format.bash" \
72+
-o clang-format.bash
73+
chmod +x ./clang-format.bash
74+
75+
- name: Run clang-format check
76+
shell: bash
77+
run: |
78+
set -euo pipefail
79+
./clang-format.bash --tracked
80+
if ! git diff-index --diff-filter=M --quiet HEAD -- ':!.clang-format'; then
81+
echo "::error ::${{ inputs.error-message }}"
82+
echo ""
83+
echo "Changes required:"
84+
echo ""
85+
echo "Files:"
86+
git diff-index --diff-filter=M --name-only HEAD -- ':!.clang-format'
87+
echo ""
88+
echo "Changes:"
89+
git diff HEAD -- ':!.clang-format'
90+
exit 1
91+
fi
92+
echo "clang-format ITK Coding Style check completed successfully."

0 commit comments

Comments
 (0)