Skip to content

Commit 78c4fd4

Browse files
committed
Add pull request workflow with smoke test
- Add smoke test that starts Augur using the Docker compose file with the images that were just built. - Update the backend CLI to accept the `AUGUR_DISABLE_COLLECTION` environment variable. Signed-off-by: John Strunk <jstrunk@redhat.com>
1 parent 5236a45 commit 78c4fd4

File tree

2 files changed

+72
-2
lines changed

2 files changed

+72
-2
lines changed

.github/workflows/build_docker.yml

+71-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
type=raw,value=devel-latest,enable=${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/dev' }}
6262
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
6363
type=raw,value=${{ github.event.release.tag_name }},enable=${{ github.event_name == 'release' }}
64+
type=raw,value=test,enable=${{ github.event_name == 'pull_request' }}
6465
6566
- name: Build and push
6667
id: push
@@ -71,8 +72,77 @@ jobs:
7172
file: ./docker/${{ matrix.image }}/Dockerfile
7273
labels: ${{ steps.meta.outputs.labels }}
7374
platforms: linux/amd64
74-
# Only push if we've tagged the image in the metadata step
75+
# Only push if we've tagged the image in the metadata step and we're not in a pull request
7576
push: ${{ github.event_name != 'pull_request' && steps.meta.outputs.tags != '' }}
7677
tags: ${{ steps.meta.outputs.tags }}
7778
cache-from: type=gha,scope=container-${{ matrix.image }}
7879
cache-to: type=gha,scope=container-${{ matrix.image }},mode=max
80+
load: true
81+
82+
- name: Export image
83+
if: github.event_name == 'pull_request'
84+
run: |
85+
docker save -o /tmp/${{ matrix.image }}-image.tar ghcr.io/${{ github.repository_owner }}/augur_${{ matrix.image }}:test
86+
87+
- name: Save image as artifact
88+
if: github.event_name == 'pull_request'
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: ${{ matrix.image }}-image
92+
path: /tmp/${{ matrix.image }}-image.tar
93+
94+
smoke-test:
95+
name: Smoke test
96+
needs: build
97+
runs-on: ubuntu-latest
98+
if: github.event_name == 'pull_request'
99+
steps:
100+
- name: Checkout repository
101+
uses: actions/checkout@v4
102+
103+
- name: Download image artifact - backend
104+
uses: actions/download-artifact@v4
105+
with:
106+
name: backend-image
107+
path: /tmp
108+
109+
- name: Download image artifact - database
110+
uses: actions/download-artifact@v4
111+
with:
112+
name: database-image
113+
path: /tmp
114+
115+
- name: Download image artifact - rabbitmq
116+
uses: actions/download-artifact@v4
117+
with:
118+
name: rabbitmq-image
119+
path: /tmp
120+
121+
- name: Load images
122+
run: |
123+
docker load -i /tmp/backend-image.tar
124+
docker load -i /tmp/database-image.tar
125+
docker load -i /tmp/rabbitmq-image.tar
126+
127+
- name: Prepare compose file
128+
run: |
129+
yq eval -i '.services.augur.image = "augur_backend:test"' docker-compose.yml
130+
yq eval -i '.services.augur.pull_policy = "never"' docker-compose.yml
131+
yq eval -i '.services.augur.restart = "no"' docker-compose.yml
132+
yq eval -i '.services.augur-db.image = "augur_database:test"' docker-compose.yml
133+
yq eval -i '.services.augur-db.pull_policy = "never"' docker-compose.yml
134+
yq eval -i '.services.augur-db.restart = "no"' docker-compose.yml
135+
yq eval -i '.services.rabbitmq.image = "augur_rabbitmq:test"' docker-compose.yml
136+
yq eval -i '.services.rabbitmq.pull_policy = "never"' docker-compose.yml
137+
yq eval -i '.services.rabbitmq.restart = "no"' docker-compose.yml
138+
yq eval -i '.services.augur.environment += ["AUGUR_DISABLE_COLLECTION=true"]' docker-compose.yml
139+
140+
- name: Start services
141+
run: docker compose -f docker-compose.yml up -d
142+
143+
- name: Wait for augur to start
144+
timeout-minutes: 3
145+
run: while ! docker ps -f name=augur-augur-1 | grep -q Up; do sleep 1; done
146+
147+
- name: Wait for expected log output
148+
run: while ! docker logs augur-augur-1 | grep -q "Sending due task"; do sleep 1; done

augur/application/cli/backend.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def cli(ctx):
4141
ctx.obj = DatabaseContext()
4242

4343
@cli.command("start")
44-
@click.option("--disable-collection", is_flag=True, default=False, help="Turns off data collection workers")
44+
@click.option("--disable-collection", is_flag=True, default=False, help="Turns off data collection workers", envvar='AUGUR_DISABLE_COLLECTION')
4545
@click.option("--development", is_flag=True, default=False, help="Enable development mode, implies --disable-collection")
4646
@click.option("--pidfile", default="main.pid", help="File to store the controlling process ID in")
4747
@click.option('--port')

0 commit comments

Comments
 (0)