Skip to content

Commit ff3bc10

Browse files
committed
feat: ensure Dockerfiles being up-to-date
1 parent 0beea79 commit ff3bc10

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

.github/workflows/lint.yml

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Hadolint
1+
name: Lint
22

33
on:
44
pull_request:
@@ -8,6 +8,10 @@ on:
88
- '**/Dockerfile'
99
- '.github/workflows/lint.yml'
1010

11+
concurrency:
12+
group: ${{ github.head_ref }}-${{ github.workflow }}
13+
cancel-in-progress: true
14+
1115
jobs:
1216
hadolint:
1317
runs-on: ubuntu-24.04
@@ -16,3 +20,48 @@ jobs:
1620
- uses: hadolint/[email protected]
1721
with:
1822
recursive: true
23+
ensure-dockerfiles-up-to-date:
24+
runs-on: ubuntu-24.04
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Install GHC and Stack
28+
uses: haskell-actions/[email protected]
29+
with:
30+
enable-stack: true
31+
32+
- name: "Cache .stack-work and ~/.stack"
33+
uses: actions/[email protected]
34+
with:
35+
path: |
36+
~/.stack
37+
**/.stack-work
38+
key: ${{ runner.os }}-stack-${{ hashFiles('**/stack.yaml') }}
39+
restore-keys: |
40+
${{ runner.os }}-stack-
41+
42+
- name: Build dockerfiles generator
43+
run: |
44+
pushd generator
45+
stack setup
46+
stack build --no-terminal
47+
- name: Ensure Dockerfiles are up-to-date
48+
run: |
49+
# Collect the list of Dockerfiles to be built
50+
mapfile -t dockerfiles < <(find . -type f -name 'Dockerfile' | sort)
51+
# Generate Dockerfiles using the generate.sh wrapper tool
52+
for df in "${dockerfiles[@]}"; do
53+
# Get appropriate YAML data file from the Dockerfile path
54+
df_dir=$(dirname "${df}")
55+
df_yaml="${df_dir}.yaml"
56+
if [ ! -f "${df_yaml}" ]; then
57+
echo "Error: Missing YAML data file ${df_yaml} for Dockerfile ${df}"
58+
exit 1
59+
fi
60+
echo "Generating ${df}"
61+
./generate.sh "${df_yaml}" "${df}.generated"
62+
# Compare generated Dockerfile with the existing one
63+
if ! diff -u "${df}" "${df}.generated"; then
64+
echo "Error: Dockerfile ${df} is out of date. Please regenerate it."
65+
exit 1
66+
fi
67+
done

0 commit comments

Comments
 (0)