Skip to content

Commit 1ec6d38

Browse files
authored
Merge pull request #387 from myoung34/goss_tests
Add goss tests
2 parents eb29a1a + 0a4919d commit 1ec6d38

File tree

9 files changed

+650
-8
lines changed

9 files changed

+650
-8
lines changed

.github/workflows/base.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,122 @@ on:
44
paths:
55
- Dockerfile.base
66
- .github/workflows/base.yml
7+
- goss*
78
branches:
89
- master
910
- develop
1011
schedule:
1112
- cron: '0 22 * * *'
1213

1314
jobs:
15+
ubuntu_base_tests:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
release: [jammy, focal, noble]
20+
platform: [linux/amd64, linux/arm64]
21+
fail-fast: false
22+
steps:
23+
- name: Copy Repo Files
24+
uses: actions/checkout@master
25+
- name: Get GitHub organization or user
26+
run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
27+
- name: Set up QEMU
28+
uses: docker/setup-qemu-action@v3
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
- name: Copy Dockerfile
32+
run: cp Dockerfile.base Dockerfile.base.ubuntu-${{ matrix.release }}; sed -i.bak 's/FROM.*/FROM ubuntu:${{ matrix.release }}/' Dockerfile.base.ubuntu-${{ matrix.release }}
33+
- name: Install Goss and dgoss
34+
run: |
35+
curl -fsSL https://goss.rocks/install | sh
36+
export PATH=$PATH:/usr/local/bin
37+
- name: Get current Git SHA
38+
id: vars
39+
run: echo "GIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
40+
- name: set testable image environment variable
41+
id: testvars
42+
run: echo "GH_RUNNER_IMAGE=ubuntu-${{ matrix.release }}-${{ env.GIT_SHA }}-${{ matrix.platform }}" >> $GITHUB_ENV
43+
- name: Login to DockerHub
44+
uses: docker/login-action@v3
45+
with:
46+
username: ${{ secrets.DOCKER_USER }}
47+
password: ${{ secrets.DOCKER_TOKEN }}
48+
- name: Build
49+
uses: docker/build-push-action@v6
50+
with:
51+
context: .
52+
file: Dockerfile.base.ubuntu-${{ matrix.release }}
53+
pull: true
54+
push: false
55+
load: true
56+
tags: ${{ env.GH_RUNNER_IMAGE }}
57+
platforms: ${{ matrix.platform }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max
60+
- name: Run goss tests
61+
run: |
62+
echo "os: ubuntu" >goss_vars_${GH_RUNNER_IMAGE}.yaml
63+
echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
64+
echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
65+
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
66+
67+
debian_base_tests:
68+
runs-on: ubuntu-latest
69+
strategy:
70+
matrix:
71+
release: [bookworm, sid]
72+
platform: [linux/amd64, linux/arm64]
73+
fail-fast: false
74+
steps:
75+
- name: Copy Repo Files
76+
uses: actions/checkout@master
77+
- name: Get GitHub organization or user
78+
run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
79+
- name: Set up QEMU
80+
uses: docker/setup-qemu-action@v3
81+
- name: Set up Docker Buildx
82+
uses: docker/setup-buildx-action@v3
83+
- name: Copy Dockerfile
84+
run: cp Dockerfile.base Dockerfile.base.debian-${{ matrix.release }}; sed -i.bak 's/FROM.*/FROM debian:${{ matrix.release }}/' Dockerfile.base.debian-${{ matrix.release }}
85+
- name: Install Goss and dgoss
86+
run: |
87+
curl -fsSL https://goss.rocks/install | sh
88+
export PATH=$PATH:/usr/local/bin
89+
- name: Get current Git SHA
90+
id: vars
91+
run: echo "GIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
92+
- name: set testable image environment variable
93+
id: testvars
94+
run: echo "GH_RUNNER_IMAGE=debian-${{ matrix.release }}-${{ env.GIT_SHA }}-${{ matrix.platform }}" >> $GITHUB_ENV
95+
- name: Login to DockerHub
96+
uses: docker/login-action@v3
97+
with:
98+
username: ${{ secrets.DOCKER_USER }}
99+
password: ${{ secrets.DOCKER_TOKEN }}
100+
- name: Build
101+
uses: docker/build-push-action@v6
102+
with:
103+
context: .
104+
file: Dockerfile.base.debian-${{ matrix.release }}
105+
pull: true
106+
push: false
107+
load: true
108+
tags: ${{ env.GH_RUNNER_IMAGE }}
109+
platforms: ${{ matrix.platform }}
110+
cache-from: type=gha
111+
cache-to: type=gha,mode=max
112+
- name: Run goss tests
113+
run: |
114+
echo "os: debian" >goss_vars_${GH_RUNNER_IMAGE}.yaml
115+
echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
116+
echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
117+
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
118+
119+
14120
ubuntu_base_latest_deploy:
15121
runs-on: ubuntu-latest
122+
needs: ubuntu_base_tests
16123
steps:
17124
- name: Copy Repo Files
18125
uses: actions/checkout@master
@@ -41,6 +148,7 @@ jobs:
41148

42149
ubuntu_base_deploy:
43150
runs-on: ubuntu-latest
151+
needs: ubuntu_base_tests
44152
strategy:
45153
matrix:
46154
release: [jammy, focal, noble]
@@ -75,6 +183,7 @@ jobs:
75183

76184
debian_base_deploy:
77185
runs-on: ubuntu-latest
186+
needs: debian_base_tests
78187
strategy:
79188
matrix:
80189
release: [bookworm, sid]

.github/workflows/deploy.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,159 @@ permissions:
1515
packages: write
1616

1717
jobs:
18+
ubuntu_tests:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
release: [jammy, focal, noble]
23+
platform: [linux/amd64, linux/arm64]
24+
fail-fast: false
25+
steps:
26+
- name: Copy Repo Files
27+
uses: actions/checkout@master
28+
- name: Get GitHub organization or user
29+
run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
30+
- name: Set up QEMU
31+
uses: docker/setup-qemu-action@v3
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
- name: Copy Dockerfile
35+
run: cp Dockerfile Dockerfile.ubuntu-${{ matrix.release }}; sed -i.bak "s/FROM.*/FROM ${ORG}\/github-runner-base:ubuntu-${{ matrix.release }}/" Dockerfile.ubuntu-${{ matrix.release }}
36+
- name: Install Goss and dgoss
37+
run: |
38+
curl -fsSL https://goss.rocks/install | sh
39+
export PATH=$PATH:/usr/local/bin
40+
- name: Get current Git SHA
41+
id: vars
42+
run: echo "GIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
43+
- name: set testable image environment variable
44+
id: testvars
45+
run: echo "GH_RUNNER_IMAGE=ubuntu-${{ matrix.release }}-${{ env.GIT_SHA }}-${{ matrix.platform }}" >> $GITHUB_ENV
46+
- name: Login to DockerHub
47+
uses: docker/login-action@v3
48+
with:
49+
username: ${{ secrets.DOCKER_USER }}
50+
password: ${{ secrets.DOCKER_TOKEN }}
51+
- name: Build
52+
uses: docker/build-push-action@v6
53+
with:
54+
context: .
55+
file: Dockerfile.ubuntu-${{ matrix.release }}
56+
pull: true
57+
push: false
58+
load: true
59+
tags: ${{ env.GH_RUNNER_IMAGE }}
60+
platforms: ${{ matrix.platform }}
61+
cache-from: type=gha
62+
cache-to: type=gha,mode=max
63+
# Tests will run against the final `${GH_RUNNER_IMAGE}` laid on top of `base-${GH_RUNNER_IMAGE}`
64+
- name: Run goss tests
65+
run: |
66+
echo "os: ubuntu" >goss_vars_${GH_RUNNER_IMAGE}.yaml
67+
echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
68+
echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
69+
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
70+
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
71+
-e DEBUG_ONLY=true \
72+
-e RUNNER_NAME=huzzah \
73+
-e REPO_URL=https://github.com/myoung34/docker-github-actions-runner \
74+
-e RUN_AS_ROOT=true \
75+
-e RUNNER_NAME_PREFIX=asdf \
76+
-e ACCESS_TOKEN=1234 \
77+
-e APP_ID=5678 \
78+
-e APP_PRIVATE_KEY=2345 \
79+
-e APP_LOGIN=SOMETHING \
80+
-e RUNNER_SCOPE=org \
81+
-e ORG_NAME=myoung34 \
82+
-e ENTERPRISE_NAME=emyoung34 \
83+
-e LABELS=blue,green \
84+
-e RUNNER_TOKEN=3456 \
85+
-e RUNNER_WORKDIR=tmp/a \
86+
-e RUNNER_GROUP=wat \
87+
-e GITHUB_HOST=github.example.com \
88+
-e DISABLE_AUTOMATIC_DEREGISTRATION=true \
89+
-e EPHEMERAL=true \
90+
-e DISABLE_AUTO_UPDATE=true \
91+
${GH_RUNNER_IMAGE} 10
92+
93+
debian_tests:
94+
runs-on: ubuntu-latest
95+
strategy:
96+
matrix:
97+
release: [bookworm, sid]
98+
platform: [linux/amd64, linux/arm64]
99+
fail-fast: false
100+
steps:
101+
- name: Copy Repo Files
102+
uses: actions/checkout@master
103+
- name: Get GitHub organization or user
104+
run: echo 'ORG='$(echo $(dirname ${GITHUB_REPOSITORY}) | awk '{print tolower($0)}') >> $GITHUB_ENV
105+
- name: Set up QEMU
106+
uses: docker/setup-qemu-action@v3
107+
- name: Set up Docker Buildx
108+
uses: docker/setup-buildx-action@v3
109+
- name: Copy Dockerfile
110+
run: cp Dockerfile Dockerfile.debian-${{ matrix.release }}; sed -i.bak "s/FROM.*/FROM ${ORG}\/github-runner-base:debian-${{ matrix.release }}/" Dockerfile.debian-${{ matrix.release }}
111+
- name: Install Goss and dgoss
112+
run: |
113+
curl -fsSL https://goss.rocks/install | sh
114+
export PATH=$PATH:/usr/local/bin
115+
- name: Get current Git SHA
116+
id: vars
117+
run: echo "GIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
118+
- name: set testable image environment variable
119+
id: testvars
120+
run: echo "GH_RUNNER_IMAGE=debian-${{ matrix.release }}-${{ env.GIT_SHA }}-${{ matrix.platform }}" >> $GITHUB_ENV
121+
- name: Login to DockerHub
122+
uses: docker/login-action@v3
123+
with:
124+
username: ${{ secrets.DOCKER_USER }}
125+
password: ${{ secrets.DOCKER_TOKEN }}
126+
- name: Build
127+
uses: docker/build-push-action@v6
128+
with:
129+
context: .
130+
file: Dockerfile.debian-${{ matrix.release }}
131+
pull: true
132+
push: false
133+
load: true
134+
tags: ${{ env.GH_RUNNER_IMAGE }}
135+
platforms: ${{ matrix.platform }}
136+
cache-from: type=gha
137+
cache-to: type=gha,mode=max
138+
# Tests will run against the final `${GH_RUNNER_IMAGE}` laid on top of `base-${GH_RUNNER_IMAGE}`
139+
- name: Run goss tests
140+
run: |
141+
echo "os: debian" >goss_vars_${GH_RUNNER_IMAGE}.yaml
142+
echo "oscodename: ${{ matrix.release }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
143+
echo "arch: ${{ matrix.platform }}" >>goss_vars_${GH_RUNNER_IMAGE}.yaml
144+
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep -e RUNNER_NAME=test -e DEBUG_ONLY=true ${GH_RUNNER_IMAGE} 10
145+
GOSS_VARS=goss_vars_${GH_RUNNER_IMAGE}.yaml GOSS_FILE=goss_full.yaml GOSS_SLEEP=1 dgoss run --entrypoint /usr/bin/sleep \
146+
-e DEBUG_ONLY=true \
147+
-e RUNNER_NAME=huzzah \
148+
-e REPO_URL=https://github.com/myoung34/docker-github-actions-runner \
149+
-e RUN_AS_ROOT=true \
150+
-e RUNNER_NAME_PREFIX=asdf \
151+
-e ACCESS_TOKEN=1234 \
152+
-e APP_ID=5678 \
153+
-e APP_PRIVATE_KEY=2345 \
154+
-e APP_LOGIN=SOMETHING \
155+
-e RUNNER_SCOPE=org \
156+
-e ORG_NAME=myoung34 \
157+
-e ENTERPRISE_NAME=emyoung34 \
158+
-e LABELS=blue,green \
159+
-e RUNNER_TOKEN=3456 \
160+
-e RUNNER_WORKDIR=tmp/a \
161+
-e RUNNER_GROUP=wat \
162+
-e GITHUB_HOST=github.example.com \
163+
-e DISABLE_AUTOMATIC_DEREGISTRATION=true \
164+
-e EPHEMERAL=true \
165+
-e DISABLE_AUTO_UPDATE=true \
166+
${GH_RUNNER_IMAGE} 10
167+
18168
ubuntu_latest_deploy:
19169
runs-on: ubuntu-latest
170+
needs: ubuntu_tests
20171
steps:
21172
- name: Copy Repo Files
22173
uses: actions/checkout@master
@@ -53,6 +204,7 @@ jobs:
53204

54205
ubuntu_deploy:
55206
runs-on: ubuntu-latest
207+
needs: ubuntu_tests
56208
strategy:
57209
matrix:
58210
release: [jammy, focal, noble]
@@ -93,6 +245,7 @@ jobs:
93245

94246
debian_deploy:
95247
runs-on: ubuntu-latest
248+
needs: debian_tests
96249
strategy:
97250
matrix:
98251
release: [bookworm, sid]

0 commit comments

Comments
 (0)