|  | 
| 1 |  | -name: Hadolint | 
|  | 1 | +name: Lint | 
| 2 | 2 | 
 | 
| 3 | 3 | on: | 
| 4 | 4 |   pull_request: | 
|  | 
| 8 | 8 |       - '**/Dockerfile' | 
| 9 | 9 |       - '.github/workflows/lint.yml' | 
| 10 | 10 | 
 | 
|  | 11 | +concurrency: | 
|  | 12 | +  group: ${{ github.head_ref }}-${{ github.workflow }} | 
|  | 13 | +  cancel-in-progress: true | 
|  | 14 | + | 
| 11 | 15 | jobs: | 
| 12 | 16 |   hadolint: | 
| 13 | 17 |     runs-on: ubuntu-24.04 | 
|  | 
| 16 | 20 |     - uses : hadolint/[email protected] | 
| 17 | 21 |       with: | 
| 18 | 22 |         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 | 
|  | 33 | + | 
|  | 34 | +      with: | 
|  | 35 | +        path: ~/.stack | 
|  | 36 | +        key: ${{ runner.os }}-stack-home-${{ hashFiles('**/stack.yaml') }} | 
|  | 37 | +        restore-keys: | | 
|  | 38 | +          ${{ runner.os }}-stack-home- | 
|  | 39 | +    - name: "Cache generator binaries at generator/.stack-work" | 
|  | 40 | + | 
|  | 41 | +      with: | 
|  | 42 | +        path: | | 
|  | 43 | +          generator/.stack-work | 
|  | 44 | +        key: ${{ runner.os }}-stack-${{ hashFiles('**/stack.yaml') }} | 
|  | 45 | +        restore-keys: | | 
|  | 46 | +          ${{ runner.os }}-stack- | 
|  | 47 | +
 | 
|  | 48 | +    - name: Download generator-binary release | 
|  | 49 | +      run: | | 
|  | 50 | +        gh release download generator-binary --repo haskell/docker-haskell --pattern 'generator' --dir artifacts | 
|  | 51 | +        chmod +x artifacts/generator | 
|  | 52 | +      env: | 
|  | 53 | +        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | 
|  | 54 | + | 
|  | 55 | +    - name: Ensure Dockerfiles are up-to-date | 
|  | 56 | +      run: | | 
|  | 57 | +        # Collect the list of Dockerfiles to be built | 
|  | 58 | +        mapfile -t dockerfiles < <(find . -type f -name 'Dockerfile' | sort) | 
|  | 59 | +        # Generate Dockerfiles using the generate.sh wrapper tool | 
|  | 60 | +        for df in "${dockerfiles[@]}"; do | 
|  | 61 | +          # Get appropriate YAML data file from the Dockerfile path | 
|  | 62 | +          df_dir=$(dirname "${df}") | 
|  | 63 | +          df_yaml="${df_dir}.yaml" | 
|  | 64 | +          if [ ! -f "${df_yaml}" ]; then | 
|  | 65 | +            echo "Error: Missing YAML data file ${df_yaml} for Dockerfile ${df}" | 
|  | 66 | +          else | 
|  | 67 | +            echo "Generating ${df}" | 
|  | 68 | +            ./generate.sh "${df_yaml}" "${df}.generated" | 
|  | 69 | +            # Compare generated Dockerfile with the existing one | 
|  | 70 | +            if ! diff -u "${df}" "${df}.generated"; then | 
|  | 71 | +                echo "Error: Dockerfile ${df} is out of date. Please regenerate it." | 
|  | 72 | +                exit 1 | 
|  | 73 | +            fi | 
|  | 74 | +          fi | 
|  | 75 | +        done | 
0 commit comments