-
Notifications
You must be signed in to change notification settings - Fork 0
195 lines (170 loc) · 6.58 KB
/
build-push-tsan.yml
File metadata and controls
195 lines (170 loc) · 6.58 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: Build and Push TSan Image
on:
push:
branches: [main]
tags: ['v*']
paths:
- 'tsan/**'
- '.github/workflows/build-push-tsan.yml'
pull_request:
branches: [main]
paths:
- 'tsan/**'
workflow_run:
workflows: ["Build and Push Images"]
types: [completed]
branches: [main]
workflow_dispatch:
env:
DOCKER_HUB_TSAN: ${{ secrets.DOCKERHUB_USERNAME }}/ocaml-devcontainer-tsan
GHCR_TSAN: ghcr.io/${{ github.repository_owner }}/ocaml-devcontainer-tsan
GHCR_DEV: ghcr.io/${{ github.repository_owner }}/ocaml-devcontainer
jobs:
# ============================================================================
# Build TSan Images (parallel per architecture)
# ============================================================================
build-tsan-amd64:
if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Reduce ASLR entropy for TSan build
run: sudo sysctl -w vm.mmap_rnd_bits=28
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push TSan image (amd64)
uses: docker/build-push-action@v6
with:
context: ./tsan
file: ./tsan/Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.GHCR_TSAN }}:latest-amd64
${{ env.DOCKER_HUB_TSAN }}:latest-amd64
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
build-args: |
BASE_IMAGE=${{ env.GHCR_DEV }}:latest-amd64
cache-from: type=gha,scope=tsan-amd64
cache-to: type=gha,mode=max,scope=tsan-amd64
build-tsan-arm64:
if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-24.04-arm
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Reduce ASLR entropy for TSan build
run: sudo sysctl -w vm.mmap_rnd_bits=28
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push TSan image (arm64)
uses: docker/build-push-action@v6
with:
context: ./tsan
file: ./tsan/Dockerfile
platforms: linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.GHCR_TSAN }}:latest-arm64
${{ env.DOCKER_HUB_TSAN }}:latest-arm64
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
build-args: |
BASE_IMAGE=${{ env.GHCR_DEV }}:latest-arm64
cache-from: type=gha,scope=tsan-arm64
cache-to: type=gha,mode=max,scope=tsan-arm64
# ============================================================================
# Merge TSan Image Tags into Multi-Arch Manifest
# ============================================================================
merge-tsan:
needs: [build-tsan-amd64, build-tsan-arm64]
if: |
always() &&
needs.build-tsan-amd64.result == 'success' &&
needs.build-tsan-arm64.result == 'success' &&
github.event_name != 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push multi-arch manifest (GHCR)
run: |
docker buildx imagetools create -t ${{ env.GHCR_TSAN }}:latest \
${{ env.GHCR_TSAN }}:latest-amd64 \
${{ env.GHCR_TSAN }}:latest-arm64
# Add version tag if this is a release
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
docker buildx imagetools create -t ${{ env.GHCR_TSAN }}:${VERSION} \
${{ env.GHCR_TSAN }}:latest-amd64 \
${{ env.GHCR_TSAN }}:latest-arm64
fi
- name: Create and push multi-arch manifest (Docker Hub)
run: |
docker buildx imagetools create -t ${{ env.DOCKER_HUB_TSAN }}:latest \
${{ env.DOCKER_HUB_TSAN }}:latest-amd64 \
${{ env.DOCKER_HUB_TSAN }}:latest-arm64
# Add version tag if this is a release
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
docker buildx imagetools create -t ${{ env.DOCKER_HUB_TSAN }}:${VERSION} \
${{ env.DOCKER_HUB_TSAN }}:latest-amd64 \
${{ env.DOCKER_HUB_TSAN }}:latest-arm64
fi
- name: Verify multi-arch manifest
run: |
echo "=== GHCR TSan Image ==="
docker buildx imagetools inspect ${{ env.GHCR_TSAN }}:latest
echo ""
echo "=== Docker Hub TSan Image ==="
docker buildx imagetools inspect ${{ env.DOCKER_HUB_TSAN }}:latest