|
12 | 12 | - 'main' |
13 | 13 |
|
14 | 14 | jobs: |
15 | | - docker: |
16 | | - runs-on: ubuntu-latest |
17 | | - steps: |
18 | | - - |
19 | | - name: Checkout |
20 | | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
21 | | - - |
22 | | - name: Docker meta |
23 | | - id: meta |
24 | | - uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 |
25 | | - with: |
26 | | - # list of Docker images to use as base name for tags |
27 | | - images: | |
28 | | - ${{ github.repository_owner }}/mailhog |
29 | | - ghcr.io/${{ github.repository_owner }}/mailhog |
30 | | - labels: | |
31 | | - org.opencontainers.image.authors=the pygmy stack, Ian Kent (MailHog) |
32 | | - org.opencontainers.image.description=MailHog mail testing, configured for use with the pygmy stack |
33 | | - - |
34 | | - name: Set up QEMU |
35 | | - uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0 |
36 | | - - |
37 | | - name: Set up Docker Buildx |
38 | | - uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 |
39 | | - - |
40 | | - name: Login to DockerHub |
41 | | - uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 |
42 | | - with: |
43 | | - username: ${{ secrets.DOCKERHUB_USERNAME }} |
44 | | - password: ${{ secrets.DOCKERHUB_TOKEN }} |
45 | | - - |
46 | | - name: Login to GHCR |
47 | | - uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 |
48 | | - with: |
49 | | - registry: ghcr.io |
50 | | - username: ${{ github.repository_owner }} |
51 | | - password: ${{ secrets.GITHUB_TOKEN }} |
52 | | - - |
53 | | - name: Build and push |
54 | | - uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 |
55 | | - with: |
56 | | - context: . |
57 | | - platforms: linux/amd64,linux/arm64 |
58 | | - push: true |
59 | | - tags: ${{ steps.meta.outputs.tags }} |
60 | | - labels: ${{ steps.meta.outputs.labels }} |
61 | | - |
62 | | - test: |
63 | | - needs: docker |
64 | | - runs-on: ubuntu-latest |
65 | | - steps: |
66 | | - - |
67 | | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
68 | | - # Establish some SSH keys. |
69 | | - - |
70 | | - name: Setup SSH |
71 | | - run: | |
72 | | - eval $(ssh-agent); |
73 | | - ssh-keygen -t rsa -q -f "$HOME/.ssh/id_rsa" -N ""; |
74 | | - ssh-keygen -t rsa -q -f "$HOME/.ssh/id_pwd" -N "passphrase"; |
75 | | - ssh-add; |
76 | | - ssh-add -l; |
77 | | - - |
78 | | - name: Docker meta |
79 | | - id: meta |
80 | | - uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 |
81 | | - with: |
82 | | - # list of Docker images to use as base name for tags |
83 | | - images: | |
84 | | - ghcr.io/${{ github.repository_owner }}/mailhog |
85 | | - flavor: | |
86 | | - latest=false |
87 | | - - |
88 | | - name: Set single image tag |
89 | | - id: single_tag |
90 | | - run: | |
91 | | - echo "tag=$(echo '${{ steps.meta.outputs.tags }}' | head -n1)" >> "$GITHUB_OUTPUT" |
92 | | - - |
93 | | - name: Find and Replace |
94 | | - env: |
95 | | - IMAGE_TAG: ${{ steps.single_tag.outputs.tag }} |
96 | | - run: | |
97 | | - find examples/ -type f -exec sed -i.bak "s|ghcr.io/pygmystack/mailhog:main|${IMAGE_TAG}|g" {} \; |
98 | | - find examples/ -name "*.bak" -delete |
99 | | - grep -Fn ghcr examples/* |
100 | | - - |
101 | | - name: Set up Homebrew |
102 | | - uses: Homebrew/actions/setup-homebrew@59e6b20d96df1a3c9ccb0aa402676e01a4cc6ff3 # main |
103 | | - - |
104 | | - name: Install homebrew packages |
105 | | - env: |
106 | | - HOMEBREW_NO_AUTO_UPDATE: 1 |
107 | | - HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 |
108 | | - HOMEBREW_NO_ENV_HINTS: 1 |
109 | | - run: | |
110 | | - brew install bats-core; |
111 | | - brew install dockerize; |
112 | | - brew install pygmystack/pygmy/pygmy; |
113 | | - pygmy version; |
114 | | - - |
115 | | - name: Pull image for tests |
116 | | - run: | |
117 | | - docker pull ${{ steps.single_tag.outputs.tag }} |
118 | | - docker pull uselagoon/php-8.5-fpm |
119 | | - - |
120 | | - name: Run BATS tests |
121 | | - env: |
122 | | - IMAGE_NAME: ${{ steps.single_tag.outputs.tag }} |
123 | | - PHP_FPM_IMAGE: uselagoon/php-8.5-fpm |
124 | | - run: | |
125 | | - bats --tap tests/image_structure.bats |
126 | | - bats --tap tests/runtime.bats |
127 | | - - |
128 | | - name: Switch pygmy configs from vanilla to basic |
129 | | - run: | |
130 | | - pygmy status; |
131 | | - pygmy clean; |
132 | | - pygmy --config examples/pygmy.basic.yml pull; |
133 | | - pygmy --config examples/pygmy.basic.yml up; |
134 | | - sleep 10; |
135 | | - pygmy --config examples/pygmy.basic.yml status; |
136 | | - - |
137 | | - name: Show pygmy image versions |
138 | | - run: | |
139 | | - docker ps -a --filter "label=pygmy.name" |
140 | | - - |
141 | | - name: Export and show configuration - pygmy.basic.yml |
142 | | - run: | |
143 | | - pygmy --config examples/pygmy.basic.yml export -o ./exported-config.yml |
144 | | - cat ./exported-config.yml |
145 | | - echo "Checking image references in started containers..."; |
146 | | - docker container inspect amazeeio-mailhog | jq '.[].Config.Image' | grep -F '${{ steps.single_tag.outputs.tag }}'; |
147 | | - - |
148 | | - name: Resolv file test |
149 | | - run: | |
150 | | - stat /usr/lib/systemd/resolved.conf.d/docker.amazee.io.conf; |
151 | | - grep "127.0.0.1" /usr/lib/systemd/resolved.conf.d/docker.amazee.io.conf; |
152 | | - grep "docker.amazee.io" /usr/lib/systemd/resolved.conf.d/docker.amazee.io.conf; |
153 | | - - |
154 | | - name: haproxy test |
155 | | - run: | |
156 | | - curl http://docker.amazee.io/stats | grep 'class=px' | grep 'mailhog.docker.amazee.io'; |
157 | | - curl http://docker.amazee.io/stats | grep 'HAProxy version'; |
158 | | - - |
159 | | - name: mailhog test |
160 | | - run: | |
161 | | - curl http://mailhog.docker.amazee.io | grep 'mailhog/MailHog'; |
162 | | - - |
163 | | - name: dnsmasq version |
164 | | - run: | |
165 | | - docker exec amazeeio-dnsmasq sh -c 'dnsmasq -v' | grep 'Dnsmasq version' |
166 | | - - |
167 | | - name: ssh version |
168 | | - run: | |
169 | | - docker exec amazeeio-ssh-agent sh -c 'ssh -V' |
170 | | - - |
171 | | - name: Test the amazeeio-network for expected results |
172 | | - run: | |
173 | | - docker network inspect amazeeio-network | jq '.[].Name' | grep "amazeeio-network"; |
174 | | - docker network inspect amazeeio-network | jq '.[].Containers' | jq '.[].Name' | grep "amazeeio-haproxy"; |
175 | | - docker network inspect amazeeio-network | jq '.[].Containers' | jq '.[].Name' | grep "amazeeio-mailhog"; |
176 | | - docker network inspect amazeeio-network | jq '.[].Containers' | jq '.[].IPv4Address'; |
177 | | - docker network inspect amazeeio-network | jq '.[].Containers' | jq '.[].IPv4Address' | grep "10.99.99."; |
178 | | - - |
179 | | - name: Test for configured container tags. |
180 | | - run: | |
181 | | - docker inspect amazeeio-dnsmasq | jq '.[].Config.Labels["pygmy.hocuspocus"]' | grep "42"; |
182 | | - docker inspect amazeeio-dnsmasq | jq '.[].Config.Labels["pygmy.abracadabra"]' | grep "1"; |
183 | | - docker inspect amazeeio-dnsmasq | jq '.[].Config.Labels["pygmy.opensesame"]' | grep "correct"; |
184 | | - docker inspect amazeeio-haproxy | jq '.[].Config.Labels["pygmy.hocuspocus"]' | grep "42"; |
185 | | - docker inspect amazeeio-haproxy | jq '.[].Config.Labels["pygmy.abracadabra"]' | grep "1"; |
186 | | - docker inspect amazeeio-haproxy | jq '.[].Config.Labels["pygmy.opensesame"]' | grep "correct"; |
187 | | - docker inspect amazeeio-ssh-agent | jq '.[].Config.Labels["pygmy.hocuspocus"]' | grep "42"; |
188 | | - docker inspect amazeeio-ssh-agent | jq '.[].Config.Labels["pygmy.abracadabra"]' | grep "1"; |
189 | | - docker inspect amazeeio-ssh-agent | jq '.[].Config.Labels["pygmy.opensesame"]' | grep "correct"; |
190 | | - docker inspect amazeeio-mailhog | jq '.[].Config.Labels["pygmy.hocuspocus"]' | grep "42"; |
191 | | - docker inspect amazeeio-mailhog | jq '.[].Config.Labels["pygmy.abracadabra"]' | grep "1"; |
192 | | - docker inspect amazeeio-mailhog | jq '.[].Config.Labels["pygmy.opensesame"]' | grep "correct"; |
193 | | - - |
194 | | - name: Switch pygmy configs from basic to vanilla |
195 | | - run: | |
196 | | - pygmy --config examples/pygmy.basic.yml status; |
197 | | - pygmy --config examples/pygmy.basic.yml clean; |
198 | | - pygmy --config examples/pygmy.yml pull; |
199 | | - pygmy --config examples/pygmy.yml up; |
200 | | - sleep 10; |
201 | | - pygmy --config examples/pygmy.yml status; |
202 | | - - |
203 | | - name: Export and show configuration - pygmy.yml |
204 | | - run: | |
205 | | - pygmy --config examples/pygmy.yml export -o ./exported-config-2.yml |
206 | | - cat ./exported-config-2.yml |
207 | | - echo "Checking image references in started containers..."; |
208 | | - docker container inspect amazeeio-mailhog | jq '.[].Config.Image' | grep -F '${{ steps.single_tag.outputs.tag }}'; |
209 | | - - |
210 | | - name: SSH Key test |
211 | | - run: | |
212 | | - pygmy --config examples/pygmy.yml addkey /home/runner/.ssh/id_rsa; |
213 | | - pygmy --config examples/pygmy.yml status; |
214 | | - pygmy --config examples/pygmy.yml status | grep 'RSA'; |
215 | | - docker run --rm -i --volumes-from amazeeio-ssh-agent pygmystack/ssh-agent /usr/bin/ssh-add -l | grep 'RSA'; |
216 | | - - |
217 | | - name: Clone the official examples |
218 | | - run: | |
219 | | - git clone --recurse-submodules https://github.com/uselagoon/lagoon-examples.git |
220 | | - - |
221 | | - name: "[Example] Drupal Base" |
222 | | - run: | |
223 | | - cd lagoon-examples/drupal-base; |
224 | | - docker compose -p drupal-base up -d; |
225 | | - docker compose -p drupal-base exec -T cli composer install; |
226 | | - dockerize -wait http://drupal-base.docker.amazee.io:80 -timeout 10s; |
227 | | - curl --HEAD http://drupal-base.docker.amazee.io; |
228 | | - curl --HEAD http://drupal-base.docker.amazee.io | grep -i "x-lagoon"; |
229 | | - pygmy --config examples/pygmy.yml status | grep '\- http://drupal-base.docker.amazee.io'; |
230 | | - docker compose -p drupal-base down; |
231 | | - docker compose -p drupal-base rm; |
232 | | - cd ../../; |
233 | | - - |
234 | | - name: Test the stop command |
235 | | - run: | |
236 | | - pygmy --config examples/pygmy.yml down | grep 'Successfully removed amazeeio'; |
237 | | - pygmy --config examples/pygmy.yml status | grep '\[ \] amazeeio-' | grep 'is not running'; |
238 | | - pygmy --config examples/pygmy.yml status | grep 'Running as container amazeeio-' && false || true; |
239 | | - pygmy --config examples/pygmy.yml up; |
240 | | - pygmy --config examples/pygmy.yml status | grep 'Running as container amazeeio-' && true || false; |
241 | | - - |
242 | | - name: Test the down command |
243 | | - run: | |
244 | | - pygmy --config examples/pygmy.yml stop | grep 'Successfully stopped amazeeio'; |
245 | | - pygmy --config examples/pygmy.yml status | grep '\[ \] amazeeio-' | grep 'is not running'; |
246 | | - pygmy --config examples/pygmy.yml status | grep 'Running as container amazeeio-' && false || true; |
247 | | - pygmy --config examples/pygmy.yml up; |
248 | | - pygmy --config examples/pygmy.yml status | grep 'Running as container amazeeio-' && true || false; |
249 | | - - |
250 | | - name: Cleanup pygmy |
251 | | - run: | |
252 | | - pygmy --config examples/pygmy.yml clean; |
253 | | - - |
254 | | - name: Cleanup after tests. |
255 | | - run: | |
256 | | - docker system prune --all --force |
257 | | - docker volume prune --force |
| 15 | + ci: |
| 16 | + uses: pygmystack/.github/workflows/container-build-test-publish.yml@main |
| 17 | + with: |
| 18 | + image_name: mailhog |
| 19 | + replace_source: ghcr.io/pygmystack/mailhog:main |
| 20 | + oc_authors: the pygmy stack, Ian Kent (MailHog) |
| 21 | + oc_description: MailHog mail testing, configured for use with the pygmy stack |
| 22 | + extra_pull_images: uselagoon/php-8.5-fpm |
| 23 | + secrets: inherit |
0 commit comments