Skip to content

Commit 3ced120

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 3ced120

File tree

1 file changed

+91
-5
lines changed

1 file changed

+91
-5
lines changed

action.yml

Lines changed: 91 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,94 @@ 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+
# For release-5.4/release branches, install clang-format 8 via pip
32+
echo "use_pixi=false" >> $GITHUB_OUTPUT
33+
echo "use_pip=true" >> $GITHUB_OUTPUT
34+
echo "clang_format_version=8.0.1" >> $GITHUB_OUTPUT
35+
echo "Using pip clang-format 8.0.1 for ${ITK_BRANCH} branch"
36+
fi
37+
38+
- name: Install pixi
39+
if: steps.config.outputs.use_pixi == 'true'
40+
uses: prefix-dev/setup-pixi@v0.9.4
41+
with:
42+
run-install: false
43+
44+
- name: Install clang-format via pixi
45+
if: steps.config.outputs.use_pixi == 'true'
46+
shell: bash
47+
run: |
48+
set -euo pipefail
49+
pixi global install "clang-format==${{ steps.config.outputs.clang_format_version }}"
50+
echo "$HOME/.pixi/bin" >> $GITHUB_PATH
51+
52+
- name: Install clang-format via pip
53+
if: steps.config.outputs.use_pip == 'true'
54+
shell: bash
55+
run: |
56+
set -euo pipefail
57+
python3 -m pip install "clang-format==${{ steps.config.outputs.clang_format_version }}"
58+
59+
- name: Verify clang-format
60+
shell: bash
61+
run: |
62+
echo "clang-format location: $(which clang-format)"
63+
clang-format --version
64+
65+
- name: Fetch ITK clang-format configuration
66+
shell: bash
67+
run: |
68+
set -euo pipefail
69+
ITK_BRANCH="${{ inputs.itk-branch }}"
70+
71+
# Use the module's own .clang-format if present, otherwise fetch from ITK
72+
if ! test -f ./.clang-format; then
73+
echo "Downloading ITK .clang-format from ${ITK_BRANCH}"
74+
curl --retry 3 --retry-delay 30 --retry-all-errors -fsSL \
75+
"https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK/${ITK_BRANCH}/.clang-format" \
76+
-o .clang-format
77+
fi
78+
79+
# Fetch the clang-format runner script
80+
curl --retry 3 --retry-delay 30 --retry-all-errors -fsSL \
81+
"https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK/${ITK_BRANCH}/Utilities/Maintenance/clang-format.bash" \
82+
-o clang-format.bash
83+
chmod +x ./clang-format.bash
84+
85+
- name: Run clang-format check
86+
shell: bash
87+
run: |
88+
set -euo pipefail
89+
./clang-format.bash --tracked
90+
if ! git diff-index --diff-filter=M --quiet HEAD -- ':!.clang-format'; then
91+
echo "::error ::${{ inputs.error-message }}"
92+
echo ""
93+
echo "Changes required:"
94+
echo ""
95+
echo "Files:"
96+
git diff-index --diff-filter=M --name-only HEAD -- ':!.clang-format'
97+
echo ""
98+
echo "Changes:"
99+
git diff HEAD -- ':!.clang-format'
100+
exit 1
101+
fi
102+
echo "clang-format ITK Coding Style check completed successfully."

0 commit comments

Comments
 (0)