-
Notifications
You must be signed in to change notification settings - Fork 12
160 lines (130 loc) · 5.01 KB
/
lint_and_test.yml
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: Lint & Test
on:
workflow_call:
permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
lint:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Check out the code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
go-version-file: 'go.mod'
- name: Run the linters
uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae # v6.2.0
test:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Check out the code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
go-version-file: 'go.mod'
- name: Install graphviz
run: sudo apt install --no-install-recommends -y graphviz
- name: Run the tests and generate the coverage profile
run: go test ./... --coverprofile=cover.out
- name: Install gocovergate
run: go install github.com/patrickhoefler/gocovergate@latest
- name: Check the code coverage
run: gocovergate
build-native:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
needs: [lint, test]
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Check out the code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
go-version-file: 'go.mod'
- name: Build
run: make build
- name: '[macOS] Install graphviz'
if: runner.os == 'macOS'
run: brew install graphviz
- name: '[Ubuntu] Install graphviz'
if: runner.os == 'Linux'
run: sudo apt install --no-install-recommends -y graphviz
- name: '[Windows] Install graphviz'
if: runner.os == 'Windows'
run: choco install graphviz --no-progress
# Smoke tests
- name: Get the version
run: ./dockerfilegraph --version
- name: Run the binary with flags
run: ./dockerfilegraph --filename examples/dockerfiles/Dockerfile --legend --output png --dpi 200
build-images:
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Harden Runner
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Check out the code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Go
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
go-version-file: 'go.mod'
- name: Build binaries and Docker image with GoReleaser
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0
with:
version: '~> v2'
args: release --snapshot
# Smoke tests
- name: Get the version
run: |
docker run \
ghcr.io/patrickhoefler/dockerfilegraph:latest \
--version
- name: Get the version on Alpine
run: |
docker run \
ghcr.io/patrickhoefler/dockerfilegraph:alpine \
--version
- name: Run the Docker image with flags
run: |
cd examples/dockerfiles
docker run \
--user "$(id -u):$(id -g)" \
--workdir /workspace \
--volume "$(pwd)":/workspace \
ghcr.io/patrickhoefler/dockerfilegraph:latest \
--legend \
--output png \
--dpi 200
- name: Run the Alpine-based Docker image with flags
run: |
cd examples/dockerfiles
docker run \
--user "$(id -u):$(id -g)" \
--workdir /workspace \
--volume "$(pwd)":/workspace \
ghcr.io/patrickhoefler/dockerfilegraph:alpine \
--legend \
--output png \
--dpi 200