-
Notifications
You must be signed in to change notification settings - Fork 2
92 lines (79 loc) · 2.88 KB
/
docker.yml
File metadata and controls
92 lines (79 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Docker Build & Publish
on:
push:
branches: [ "main" ]
# Also trigger on semver tags, e.g., v1.0.0, v2.1.3
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]
env:
REGISTRY: ghcr.io
# This sets the image name to ghcr.io/YOUR_GITHUB_USERNAME/dolfinx-serial
IMAGE_NAME: ${{ github.repository_owner }}/dolfinx-serial
jobs:
build-test-push:
name: Build, Test, and Push
runs-on: ubuntu-24.04
# We need 'packages: write' permission to push the image to GitHub Packages
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU (for ARM64 build)
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
# Only log in if this is a push to main or a tag (skip for PRs)
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# Output 'main' or 'latest' on push to main
type=ref,event=branch
type=edge,branch=main
# Output '1.2.3' if you push a tag 'v1.2.3'
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# Output PR number on pull requests
type=ref,event=pr
# --- Phase 1: Test ---
# We build a local AMD64 image because multi-arch images cannot be loaded locally.
- name: Build local image for verification
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
load: true
tags: local-test-image:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Verify DOLFINx Import
run: |
docker run --rm local-test-image:latest python3 -c "import dolfinx; print(f'SUCCESS! DOLFINx imported cleanly. Version: {dolfinx.__version__}')"
- name: Run DOLFINx C++ Tests
run: |
docker run --rm local-test-image:latest bash -c "\
cd /dolfinx/cpp/test && \
rm -rf build && \
cmake -B build -S . -DCMAKE_BUILD_TYPE=Developer -GNinja -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx && \
cmake --build build -j 4 && \
cd build && \
ctest -VV --output-on-failure -R unittests_np_1"
- name: Run DOLFINx Python Tests
run: |
docker run --rm local-test-image:latest bash -c "\
python3 -m pip install pytest scipy && \
cd /dolfinx/python/test && \
python3 -m pytest -vs"