Skip to content

Commit c27bd9e

Browse files
authored
Merge pull request #32 from m-ildefons/hadolint-240
hadolint: version bump to 2.4.0
2 parents 136c22c + 110e47c commit c27bd9e

File tree

8 files changed

+97
-9
lines changed

8 files changed

+97
-9
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,42 @@ jobs:
3939
steps:
4040
- uses: actions/checkout@v2
4141

42-
- name: Run integration test
42+
- name: Run integration test 1
4343
uses: ./
4444
with:
4545
dockerfile: testdata/Dockerfile
4646

47+
- name: Run integration test 2 - ignore a rule
48+
# This step is supposed to print out an info level rule violation
49+
# but completely ignore the two rules listed below
50+
uses: ./
51+
with:
52+
dockerfile: testdata/warning.Dockerfile
53+
ignore: DL3014 DL3008
54+
55+
- name: Run integration test 3 - set failure threshold
56+
# This step will print out an info level rule violation, but not fail
57+
# because of the high failure threshold.
58+
uses: ./
59+
with:
60+
dockerfile: testdata/info.Dockerfile
61+
failure-threshold: warning
62+
63+
- name: Run integration test 4 - output format
64+
# This step will never fail, but will print out rule violations as json.
65+
uses: ./
66+
with:
67+
dockerfile: testdata/warning.Dockerfile
68+
failure-threshold: error
69+
format: json
70+
71+
- name: Run integration test 4 - output format
72+
# This step will never fail, but will print out rule violations.
73+
uses: ./
74+
with:
75+
dockerfile: testdata/warning.Dockerfile
76+
config: testdata/hadolint.yaml
77+
4778
release:
4879
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
4980
name: Release

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM hadolint/hadolint:v2.1.0-alpine
1+
FROM hadolint/hadolint:v2.4.0-debian
22

33
COPY LICENSE README.md problem-matcher.json /
44
COPY hadolint.sh /usr/local/bin/hadolint.sh

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,25 @@ Add the following step to your workflow configuration:
1515

1616
```yml
1717
steps:
18-
- uses: hadolint/[email protected]
19-
with:
20-
dockerfile: Dockerfile
18+
- uses: hadolint/[email protected]
19+
with:
20+
dockerfile: Dockerfile
2121
```
2222
2323
## Inputs
2424
25-
| Name | Description | Default |
26-
|------------ |----------------------------------------- |-------------- |
27-
| dockerfile | The path to the Dockerfile to be tested | ./Dockerfile |
25+
| Name | Description | Default |
26+
|------------------ |------------------------------------------ |----------------- |
27+
| dockerfile | The path to the Dockerfile to be tested | ./Dockerfile |
28+
| format | The output format. One of [tty | json | | tty |
29+
| | checkstyle | codeclimate | | |
30+
| | gitlab_codeclimate] | |
31+
| ignore | Space separated list of Hadolint rules to | <none> |
32+
| | ignore. | |
33+
| config | Custom path to a Hadolint config file | ./.hadolint.yaml |
34+
| failure-threshold | Rule severity threshold for pipeline | info |
35+
| | failure. One of [error | warning | info | | |
36+
| | style | ignore] | |
2837
2938
## Hadolint Configuration
3039

action.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,42 @@ description: 'Action that runs Hadolint Dockerfile linting tool'
33
author: 'Bruno Paz'
44
inputs:
55
dockerfile:
6+
required: false
67
description: 'The path to the Dockerfile to lint'
78
default: 'Dockerfile'
9+
format:
10+
required: false
11+
description: |
12+
The output format, one of [tty (default) | json | checkstyle |
13+
codeclimate | gitlab_codeclimate ]
14+
default: 'tty'
15+
failure-threshold:
16+
required: false
17+
description: |
18+
Fail the pipeline only if rules with severity above this threshold are
19+
violated. One of [error | warning | info (default) | style | ignore]
20+
default: 'info'
21+
ignore:
22+
required: false
23+
description: 'A space separated string of rules to ignore'
24+
default:
25+
config:
26+
required: false
27+
description: 'Path to a config file'
28+
default:
29+
830
runs:
931
using: 'docker'
1032
image: 'Dockerfile'
1133
args:
34+
- -f
35+
- ${{ inputs.format }}
36+
- -t
37+
- ${{ inputs.failure-threshold }}
1238
- ${{ inputs.dockerfile }}
39+
env:
40+
HADOLINT_CONFIG: ${{ inputs.config }}
41+
HADOLINT_IGNORE: ${{ inputs.ignore }}
1342
branding:
1443
icon: 'layers'
1544
color: 'purple'

hadolint.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,13 @@ trap cleanup EXIT
1919

2020
echo "::add-matcher::${TMP_FOLDER}/problem-matcher.json"
2121

22-
hadolint "$@"
22+
if [ -n "$HADOLINT_CONFIG" ]; then
23+
HADOLINT_CONFIG="-c ${HADOLINT_CONFIG}"
24+
fi
25+
26+
for i in $HADOLINT_IGNORE; do
27+
HADOLINT_IGNORE_CMDLINE="${HADOLINT_IGNORE_CMDLINE} --ignore=${i}"
28+
done
29+
30+
# shellcheck disable=SC2086
31+
hadolint $HADOLINT_IGNORE_CMDLINE $HADOLINT_CONFIG "$@"

testdata/hadolint.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
failure-threshold: error

testdata/info.Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM debian:buster
2+
3+
# info level warning expected here:
4+
RUN echo "Hello"
5+
RUN echo "World"

testdata/warning.Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM debian:buster
2+
3+
# emits an info and a warning level violation.
4+
RUN apt-get install foo

0 commit comments

Comments
 (0)