Skip to content

Commit 45472e6

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

File tree

1 file changed

+62
-1
lines changed

1 file changed

+62
-1
lines changed

.github/workflows/lint.yml

Lines changed: 62 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:
@@ -7,6 +7,17 @@ on:
77
paths:
88
- '**/Dockerfile'
99
- '.github/workflows/lint.yml'
10+
workflow_dispatch:
11+
inputs:
12+
debug_enabled:
13+
type: boolean
14+
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
15+
required: false
16+
default: false
17+
18+
concurrency:
19+
group: ${{ github.head_ref }}-${{ github.workflow }}
20+
cancel-in-progress: true
1021

1122
jobs:
1223
hadolint:
@@ -16,3 +27,53 @@ jobs:
1627
- uses: hadolint/[email protected]
1728
with:
1829
recursive: true
30+
ensure-dockerfiles-up-to-date:
31+
runs-on: ubuntu-24.04
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Install GHC and Stack
35+
uses: haskell-actions/[email protected]
36+
with:
37+
enable-stack: true
38+
39+
- name: "Cache .stack-work and ~/.stack"
40+
uses: actions/[email protected]
41+
with:
42+
path: |
43+
~/.stack
44+
**/.stack-work
45+
key: ${{ runner.os }}-stack-${{ hashFiles('**/stack.yaml') }}
46+
restore-keys: |
47+
${{ runner.os }}-stack-
48+
49+
# Enable tmate debugging of manually triggered workflows if the input option was provided
50+
- name: Setup tmate session
51+
uses: mxschmitt/[email protected]
52+
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
53+
54+
- name: Build dockerfiles generator
55+
run: |
56+
pushd generator
57+
stack setup
58+
stack build --no-terminal
59+
- name: Ensure Dockerfiles are up-to-date
60+
run: |
61+
# Collect the list of Dockerfiles to be built
62+
mapfile -t dockerfiles < <(find . -type f -name 'Dockerfile' | sort)
63+
# Generate Dockerfiles using the generate.sh wrapper tool
64+
for df in "${dockerfiles[@]}"; do
65+
# Get appropriate YAML data file from the Dockerfile path
66+
df_dir=$(dirname "${df}")
67+
df_yaml="${df_dir}.yaml"
68+
if [ ! -f "${df_yaml}" ]; then
69+
echo "Error: Missing YAML data file ${df_yaml} for Dockerfile ${df}"
70+
exit 1
71+
fi
72+
echo "Generating ${df}"
73+
./generate.sh "${df_yaml}" "${df}.generated"
74+
# Compare generated Dockerfile with the existing one
75+
if ! diff -u "${df}" "${df}.generated"; then
76+
echo "Error: Dockerfile ${df} is out of date. Please regenerate it."
77+
exit 1
78+
fi
79+
done

0 commit comments

Comments
 (0)