Skip to content

Commit 4ce5b18

Browse files
authored
ci: modernize gateway-conformance and docker workflows (#337)
gateway-conformance.yml: - add permissions, timeout-minutes, defaults.run.shell - read Go version from go.mod instead of hardcoding - add fail-fast: false to see all backend failures - add health check after each rainbow start variant docker.yml: - add timeout-minutes - switch from local buildx cache to GHA cache - add smoke test: build amd64 image, verify --version, then push multi-platform
1 parent b76e960 commit 4ce5b18

File tree

2 files changed

+65
-23
lines changed

2 files changed

+65
-23
lines changed

.github/workflows/docker.yml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ env:
1313
jobs:
1414
build-and-push-image:
1515
runs-on: ubuntu-latest
16+
timeout-minutes: 15
1617
permissions:
1718
contents: read
1819
packages: write
@@ -28,19 +29,13 @@ jobs:
2829
- name: Set up Docker Buildx
2930
uses: docker/setup-buildx-action@v3
3031

31-
- name: Cache Docker layers
32-
uses: actions/cache@v5
33-
with:
34-
path: /tmp/.buildx-cache
35-
key: ${{ runner.os }}-buildx-${{ github.sha }}
36-
restore-keys: |
37-
${{ runner.os }}-buildx-
3832
- name: Log in to the Container registry
3933
uses: docker/login-action@v3
4034
with:
4135
registry: ${{ env.REGISTRY }}
4236
username: ${{ github.actor }}
4337
password: ${{ secrets.GITHUB_TOKEN }}
38+
4439
- name: Get tags
4540
id: tags
4641
env:
@@ -50,20 +45,32 @@ jobs:
5045
./docker/get-docker-tags.sh "$(date -u +%F)" >> $GITHUB_OUTPUT
5146
echo "EOF" >> $GITHUB_OUTPUT
5247
shell: bash
53-
- name: Build Docker image and publish to Docker Hub
48+
49+
- name: Build Docker image (amd64, for smoke test)
50+
uses: docker/build-push-action@v6
51+
with:
52+
platforms: linux/amd64
53+
context: .
54+
load: true
55+
file: ./Dockerfile
56+
tags: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:smoke-test"
57+
cache-from: type=gha
58+
cache-to: type=gha,mode=max
59+
60+
- name: Smoke-test Docker image
61+
run: |
62+
for i in {1..3}; do
63+
timeout 15s docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:smoke-test --version && break || [ $i = 3 ] && exit 1
64+
done
65+
timeout-minutes: 1
66+
67+
- name: Build and push multi-platform Docker image
5468
uses: docker/build-push-action@v6
5569
with:
5670
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
5771
context: .
5872
push: true
5973
file: ./Dockerfile
6074
tags: "${{ steps.tags.outputs.value }}"
61-
cache-from: type=local,src=/tmp/.buildx-cache
62-
cache-to: type=local,dest=/tmp/.buildx-cache-new
63-
64-
# https://github.com/docker/build-push-action/issues/252
65-
# https://github.com/moby/buildkit/issues/1896
66-
- name: Move cache to limit growth
67-
run: |
68-
rm -rf /tmp/.buildx-cache
69-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
75+
cache-from: type=gha
76+
cache-to: type=gha,mode=max

.github/workflows/gateway-conformance.yml

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,23 @@ env:
1313
GATEWAY_CONFORMANCE_TEST: true # rainbow preset for conformance testing
1414
KUBO_VER: 'v0.33.0-rc1' # kubo daemon used as no-libp2p-remote-* backend
1515

16+
permissions:
17+
contents: read
18+
1619
concurrency:
1720
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
1821
cancel-in-progress: true
1922

23+
defaults:
24+
run:
25+
shell: bash
26+
2027
jobs:
2128
test:
2229
runs-on: ubuntu-latest
30+
timeout-minutes: 10
2331
strategy:
32+
fail-fast: false
2433
matrix:
2534
backend: ["libp2p-bitswap", "remote-block-gw", "remote-car-gw"]
2635

@@ -68,15 +77,17 @@ jobs:
6877
uses: ipfs/start-ipfs-daemon-action@v1
6978

7079
# 4. Build rainbow
71-
- name: Setup Go
72-
uses: actions/setup-go@v6
73-
with:
74-
go-version: 1.26.x
75-
7680
- name: Checkout rainbow
7781
uses: actions/checkout@v6
7882
with:
7983
path: rainbow
84+
85+
- name: Setup Go
86+
uses: actions/setup-go@v6
87+
with:
88+
go-version-file: 'rainbow/go.mod'
89+
cache-dependency-path: 'rainbow/go.sum'
90+
8091
- name: Build rainbow
8192
run: go build
8293
working-directory: rainbow
@@ -94,6 +105,14 @@ jobs:
94105
./rainbow --peering=$kuboNodeMultiaddr &
95106
working-directory: rainbow
96107

108+
- name: Wait for rainbow (libp2p-bitswap)
109+
if: ${{ matrix.backend == 'libp2p-bitswap' }}
110+
run: |
111+
for i in $(seq 1 30); do
112+
curl -s http://127.0.0.1:8090 > /dev/null && break
113+
sleep 1
114+
done
115+
97116
# 5. Start rainbow variant
98117
- name: Start rainbow (no libp2p, remote block gateway)
99118
if: ${{ matrix.backend == 'remote-block-gw' }}
@@ -108,7 +127,15 @@ jobs:
108127
run: |
109128
./rainbow &
110129
working-directory: rainbow
111-
#
130+
131+
- name: Wait for rainbow (remote-block-gw)
132+
if: ${{ matrix.backend == 'remote-block-gw' }}
133+
run: |
134+
for i in $(seq 1 30); do
135+
curl -s http://127.0.0.1:8090 > /dev/null && break
136+
sleep 1
137+
done
138+
112139
# 5. Start rainbow variant
113140
- name: Start rainbow (no libp2p, remote car gateway)
114141
if: ${{ matrix.backend == 'remote-car-gw' }}
@@ -124,6 +151,14 @@ jobs:
124151
./rainbow &
125152
working-directory: rainbow
126153

154+
- name: Wait for rainbow (remote-car-gw)
155+
if: ${{ matrix.backend == 'remote-car-gw' }}
156+
run: |
157+
for i in $(seq 1 30); do
158+
curl -s http://127.0.0.1:8090 > /dev/null && break
159+
sleep 1
160+
done
161+
127162
# 6. Run the gateway-conformance tests
128163
- name: Run gateway-conformance tests
129164
uses: ipfs/gateway-conformance/.github/actions/test@v0.10

0 commit comments

Comments
 (0)