Skip to content

Commit aca3852

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

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

.github/workflows/lint.yml

Lines changed: 54 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,52 @@ 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+
# Enable tmate debugging of manually triggered workflows if the input option was provided
43+
- name: Setup tmate session
44+
uses: mxschmitt/[email protected]
45+
46+
- name: Build dockerfiles generator
47+
run: |
48+
pushd generator
49+
stack setup
50+
stack build --no-terminal
51+
- name: Ensure Dockerfiles are up-to-date
52+
run: |
53+
# Collect the list of Dockerfiles to be built
54+
mapfile -t dockerfiles < <(find . -type f -name 'Dockerfile' | sort)
55+
# Generate Dockerfiles using the generate.sh wrapper tool
56+
for df in "${dockerfiles[@]}"; do
57+
# Get appropriate YAML data file from the Dockerfile path
58+
df_dir=$(dirname "${df}")
59+
df_yaml="${df_dir}.yaml"
60+
if [ ! -f "${df_yaml}" ]; then
61+
echo "Error: Missing YAML data file ${df_yaml} for Dockerfile ${df}"
62+
exit 1
63+
fi
64+
echo "Generating ${df}"
65+
./generate.sh "${df_yaml}" "${df}.generated"
66+
# Compare generated Dockerfile with the existing one
67+
if ! diff -u "${df}" "${df}.generated"; then
68+
echo "Error: Dockerfile ${df} is out of date. Please regenerate it."
69+
exit 1
70+
fi
71+
done

0 commit comments

Comments
 (0)