Skip to content

Commit 3f5164a

Browse files
committed
Updates Docker build workflow for ARC
Refactors the Docker build workflow to improve build process and smoke test execution. The changes include: - Updates checkout and build-push-action versions. - Introduces named test stage for the main branch. - Adjusts smoke test execution for main and non-main branches using the test stage image. - Streamlines Docker Hub login and push steps for main branch builds.
1 parent e5b90e1 commit 3f5164a

File tree

1 file changed

+45
-10
lines changed

1 file changed

+45
-10
lines changed

.github/workflows/docker_build.yml

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,68 @@ jobs:
3232
large-packages: true
3333
docker-images: false
3434
swap-storage: true
35+
3536
- name: Checkout
36-
uses: actions/checkout@v2
37+
uses: actions/checkout@v5.0.0
3738

39+
- name: Set up Buildx
40+
uses: docker/setup-buildx-action@v3.11.1
41+
42+
# ----- PR and non-main branch steps -----
43+
# For PRs: Build image but do not push and run smoke tests
3844
- name: Build Docker Image (No Push)
3945
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref != 'refs/heads/main')
40-
uses: docker/build-push-action@v5.1.0
46+
uses: docker/build-push-action@v6.18.0
4147
with:
4248
context: .
4349
file: ./Dockerfile
4450
push: false
51+
load: true
52+
tags: arc:test
53+
cache-from: type=gha
54+
cache-to: type=gha,mode=max
55+
56+
- name: Run Smoke Tests
57+
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref != 'refs/heads/main')
58+
run: |
59+
docker run --rm arc:test bash -lc \
60+
"cd /home/mambauser/Code/ARC && micromamba run -n arc_env pytest dockerfiles/docker_tests/test_docker_smoke.py -m smoke -q"
61+
62+
# ----- Main branch only steps -----
63+
# For pushes to main: Build, run smoke tests, and push to Docker Hub
64+
- name: Build test stage (main)
65+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
66+
uses: docker/build-push-action@v6.18.0
67+
with:
68+
context: .
69+
file: ./Dockerfile
70+
load: true
71+
tags: arc:final-${{ github.sha }}
72+
cache-from: type=gha
73+
cache-to: type=gha,mode=max
74+
75+
- name: Run smoke (main, test stage)
76+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
77+
run: |
78+
docker run --rm arc:final-${{ github.sha }} bash -lc \
79+
"cd /home/mambauser/Code/ARC && micromamba run -n arc_env pytest dockerfiles/docker_tests/test_docker_smoke.py -m smoke -q"
4580
4681
- name: Login to Docker Hub
4782
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
48-
uses: docker/login-action@v3.0.0
83+
uses: docker/login-action@v3.5.0
4984
with:
5085
username: ${{ secrets.DOCKERHUB_USERNAME }}
5186
password: ${{ secrets.DOCKERHUB_TOKEN }}
5287

53-
- name: Set up Docker Buildx
54-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
55-
uses: docker/setup-buildx-action@v3.0.0
56-
57-
- name: Build and Push Docker Image
88+
- name: Build final and push (main)
5889
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
59-
uses: docker/build-push-action@v5.1.0
90+
uses: docker/build-push-action@v6.18.0
6091
with:
6192
context: .
6293
file: ./Dockerfile
6394
push: true
64-
tags: ${{ secrets.DOCKERHUB_USERNAME }}/arc:latest
95+
tags: |
96+
${{ secrets.DOCKERHUB_USERNAME }}/arc:latest
97+
${{ secrets.DOCKERHUB_USERNAME }}/arc:${{ github.sha }}
98+
cache-from: type=gha
99+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)