forked from paradigmxyz/reth
-
Notifications
You must be signed in to change notification settings - Fork 3
168 lines (150 loc) · 5.55 KB
/
gcp-docker.yml
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
name: Google Artifact Registry
on:
push:
branches:
- main
- dev
- dockercomposeaction
tags:
- "*"
workflow_dispatch:
inputs:
force_build:
type: boolean
description: "Build image even if tests fail"
default: false
jobs:
docker-release:
name: Docker Build Test Release
runs-on: ubuntu-latest
permissions:
contents: "read"
id-token: "write"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wvm
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && github.event.base_ref == 'refs/heads/main') }}
type=raw,value=nightly,enable=${{ github.ref == 'refs/heads/dev' }}
type=ref,event=tag
type=ref,event=branch,enable=${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}
- name: Authenticate with Google Cloud
id: auth
uses: google-github-actions/auth@v2
with:
token_format: access_token
credentials_json: ${{ secrets.GCP_CREDENTIALS_JSON }}
access_token_lifetime: 1800s
- name: Configure Docker for GAR
run: |
gcloud auth configure-docker us-east1-docker.pkg.dev
echo "DOCKER_BUILDKIT=1" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug
- name: Login to Artifact Registry
uses: docker/login-action@v3
with:
registry: us-east1-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
# CHANGED: Combined build step for both local testing and registry images
- name: Build and export image
id: build
uses: docker/build-push-action@v6
with:
context: .
push: false
load: true
tags: |
wvm:local
${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=registry,ref=us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wvm:buildcache
build-args: |
BUILDKIT_INLINE_CACHE=1
- name: Verify local image
run: |
if ! docker image inspect wvm:local >/dev/null 2>&1; then
echo "Local image wvm:local not found!"
exit 1
fi
echo "Local image verified successfully"
- name: Setup test environment
run: |
mkdir -p .testnet
chmod 750 .testnet
cd .testnet
git clone --depth 1 https://github.com/weaveVM/wvm-docker-testnet.git .
echo '${{ secrets.GCP_CREDENTIALS_JSON }}' > ./execution/key.json
chmod 600 ./execution/key.json
- name: Run tests
id: test
continue-on-error: true
run: |
cd .testnet
mkdir -p logs
echo "Starting Docker Compose..."
if ! docker compose up -d; then
echo "Docker Compose failed. Collecting logs..."
docker ps -a
docker compose logs > logs/compose.log
for container in $(docker compose ps -q); do
name=$(docker inspect --format='{{.Name}}' $container)
echo "=== Logs for $name ==="
docker logs $container &> "logs/$name.log"
cat "logs/$name.log"
done
exit 1
fi
echo "Installing dependencies..."
if ! npm install; then
echo "npm install failed"
docker compose logs > logs/compose_fail.log
cat logs/compose_fail.log
exit 1
fi
echo "Running tests..."
if ! SIGNER_KEY=${{ secrets.TEST_SIGNER_KEY }} node test.js; then
echo "Tests failed"
docker compose logs > logs/compose_fail.log
cat logs/compose_fail.log
exit 1
fi
echo "Tests completed successfully"
- name: Report test status
if: always()
run: |
if [ "${{ steps.test.outcome }}" == "failure" ]; then
echo "::warning ::Tests failed but continuing due to force_build option"
echo "### ⚠️ Test Results" >> $GITHUB_STEP_SUMMARY
echo "Tests failed but build will continue as force_build is enabled." >> $GITHUB_STEP_SUMMARY
echo "Please check test logs for details." >> $GITHUB_STEP_SUMMARY
fi
- name: Cleanup test environment
if: always()
run: |
cd .testnet || true
docker compose down || true
cd ..
sudo rm -rf .testnet
# CHANGED: Modified push step to use existing image
- name: Push to registry
if: success() || github.event.inputs.force_build == 'true'
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=registry,ref=us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wvm:buildcache
cache-to: |
type=registry,ref=us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_ARTIFACT_REPO }}/wvm:buildcache,mode=max