-
Notifications
You must be signed in to change notification settings - Fork 37
75 lines (69 loc) · 2.29 KB
/
lint.yml
File metadata and controls
75 lines (69 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Lint
on:
pull_request:
branches:
- master
paths:
- '**/Dockerfile'
- '.github/workflows/lint.yml'
concurrency:
group: ${{ github.head_ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
hadolint:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: hadolint/hadolint-action@v3.1.0
with:
recursive: true
ensure-dockerfiles-up-to-date:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install GHC and Stack
uses: haskell-actions/setup@v2.8.2
with:
enable-stack: true
- name: Cache ~/.stack
uses: actions/cache@v4.3.0
with:
path: ~/.stack
key: ${{ runner.os }}-stack-home-${{ hashFiles('**/stack.yaml') }}
restore-keys: |
${{ runner.os }}-stack-home-
- name: "Cache generator binaries at generator/.stack-work"
uses: actions/cache@v4.3.0
with:
path: |
generator/.stack-work
key: ${{ runner.os }}-stack-${{ hashFiles('**/stack.yaml') }}
restore-keys: |
${{ runner.os }}-stack-
- name: Download generator-binary release
run: |
gh release download generator-binary --repo haskell/docker-haskell --pattern 'generator' --dir artifacts
chmod +x artifacts/generator
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Ensure Dockerfiles are up-to-date
run: |
# Collect the list of Dockerfiles to be built
mapfile -t dockerfiles < <(find . -type f -name 'Dockerfile' | sort)
# Generate Dockerfiles using the generate.sh wrapper tool
for df in "${dockerfiles[@]}"; do
# Get appropriate YAML data file from the Dockerfile path
df_dir=$(dirname "${df}")
df_yaml="${df_dir}.yaml"
if [ ! -f "${df_yaml}" ]; then
echo "Error: Missing YAML data file ${df_yaml} for Dockerfile ${df}"
else
echo "Generating ${df}"
./generate.sh "${df_yaml}" "${df}.generated"
# Compare generated Dockerfile with the existing one
if ! diff -u "${df}" "${df}.generated"; then
echo "Error: Dockerfile ${df} is out of date. Please regenerate it."
exit 1
fi
fi
done