Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add goss testing for the docker image #4459

Merged
merged 9 commits into from
May 21, 2024
45 changes: 45 additions & 0 deletions .github/workflows/atlantis-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,51 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.description'] }}

test:
jippi marked this conversation as resolved.
Show resolved Hide resolved
needs: [changes]
if: needs.changes.outputs.should-run-build == 'true'
name: Test Image With Goss
runs-on: ubuntu-22.04
strategy:
matrix:
image_type: [alpine, debian]
env:
# Set docker repo to either the fork or the main repo where the branch exists
DOCKER_REPO: ghcr.io/${{ github.repository }}

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3
# https://github.com/docker/build-push-action/issues/761#issuecomment-1575006515
with:
driver-opts: |
image=moby/buildkit:v0.13.2

- name: "Build and load into Docker"
if: contains(fromJson('["push", "pull_request"]'), github.event_name)
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
build-args: |
ATLANTIS_BASE_TAG_TYPE=${{ matrix.image_type }}
push: false
load: true
tags: "${{ env.DOCKER_REPO }}:goss-test"
target: ${{ matrix.image_type }}

- name: "Setup Goss"
uses: e1himself/goss-installation-action@fbb6fb55d3e59c96045b2500eeb8ce0995d99ac1 # v1.2.1
with:
version: "v0.4.7"

- name: Execute Goss tests
jippi marked this conversation as resolved.
Show resolved Hide resolved
run: |
dgoss run --rm ${{ env.DOCKER_REPO }}:goss-test bash -c 'while true; do sleep 1; done;'

skip-build:
needs: [changes]
if: needs.changes.outputs.should-run-build == 'false'
Expand Down
37 changes: 37 additions & 0 deletions goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# See: https://github.com/goss-org/goss/blob/master/docs/gossfile.md

command:
# ensure atlantis is available
atlantis-available:
exec: "atlantis version"
exit-status: 0
stdout: []
stderr: []

# ensure conftest is available
conftest-available:
exec: "conftest -v"
exit-status: 0
stdout: []
stderr: []

# ensure git-lfs is available
git-lfs-available:
exec: "git-lfs -v"
exit-status: 0
stdout: []
stderr: []

# ensure terraform is available
terraform-available:
exec: "terraform version"
exit-status: 0
stdout: []
stderr: []

# ensure tofu binary is available
tofu-available:
exec: "tofu version"
exit-status: 0
stdout: []
stderr: []