Skip to content

Commit 8c5bb21

Browse files
jippichenrui333
andauthored
feat: add goss testing for the docker image (runatlantis#4459)
Co-authored-by: Rui Chen <[email protected]>
1 parent 821de05 commit 8c5bb21

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

.github/workflows/atlantis-image.yml

+45
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,51 @@ jobs:
148148
labels: ${{ steps.meta.outputs.labels }}
149149
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.description'] }}
150150

151+
test:
152+
needs: [changes]
153+
if: needs.changes.outputs.should-run-build == 'true'
154+
name: Test Image With Goss
155+
runs-on: ubuntu-22.04
156+
strategy:
157+
matrix:
158+
image_type: [alpine, debian]
159+
env:
160+
# Set docker repo to either the fork or the main repo where the branch exists
161+
DOCKER_REPO: ghcr.io/${{ github.repository }}
162+
163+
steps:
164+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
165+
166+
- name: Set up Docker Buildx
167+
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3
168+
# https://github.com/docker/build-push-action/issues/761#issuecomment-1575006515
169+
with:
170+
driver-opts: |
171+
image=moby/buildkit:v0.13.2
172+
173+
- name: "Build and load into Docker"
174+
if: contains(fromJson('["push", "pull_request"]'), github.event_name)
175+
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5
176+
with:
177+
cache-from: type=gha
178+
cache-to: type=gha,mode=max
179+
context: .
180+
build-args: |
181+
ATLANTIS_BASE_TAG_TYPE=${{ matrix.image_type }}
182+
push: false
183+
load: true
184+
tags: "${{ env.DOCKER_REPO }}:goss-test"
185+
target: ${{ matrix.image_type }}
186+
187+
- name: "Setup Goss"
188+
uses: e1himself/goss-installation-action@fbb6fb55d3e59c96045b2500eeb8ce0995d99ac1 # v1.2.1
189+
with:
190+
version: "v0.4.7"
191+
192+
- name: Execute Goss tests
193+
run: |
194+
dgoss run --rm ${{ env.DOCKER_REPO }}:goss-test bash -c 'while true; do sleep 1; done;'
195+
151196
skip-build:
152197
needs: [changes]
153198
if: needs.changes.outputs.should-run-build == 'false'

goss.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# See: https://github.com/goss-org/goss/blob/master/docs/gossfile.md
2+
3+
command:
4+
# ensure atlantis is available
5+
atlantis-available:
6+
exec: "atlantis version"
7+
exit-status: 0
8+
stdout: []
9+
stderr: []
10+
11+
# ensure conftest is available
12+
conftest-available:
13+
exec: "conftest -v"
14+
exit-status: 0
15+
stdout: []
16+
stderr: []
17+
18+
# ensure git-lfs is available
19+
git-lfs-available:
20+
exec: "git-lfs -v"
21+
exit-status: 0
22+
stdout: []
23+
stderr: []
24+
25+
# ensure terraform is available
26+
terraform-available:
27+
exec: "terraform version"
28+
exit-status: 0
29+
stdout: []
30+
stderr: []
31+
32+
# ensure tofu binary is available
33+
tofu-available:
34+
exec: "tofu version"
35+
exit-status: 0
36+
stdout: []
37+
stderr: []

0 commit comments

Comments
 (0)