Skip to content

Commit 7be4b34

Browse files
committed
update workflow files to include dockerhub push
1 parent 6af6d5c commit 7be4b34

File tree

3 files changed

+367
-0
lines changed

3 files changed

+367
-0
lines changed

.github/workflows/mysql.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,50 @@ jobs:
211211
glob: "*.xml"
212212
parent: false
213213
process_gcloudignore: false
214+
215+
deploy-mysql:
216+
runs-on: ubuntu-latest
217+
needs: mysql-e2e-tests
218+
if: |
219+
github.ref == 'refs/heads/master' ||
220+
startsWith(github.ref, 'refs/tags/') ||
221+
startsWith(github.ref, 'refs/heads/feature.')
222+
223+
steps:
224+
- name: Download Docker image
225+
uses: actions/download-artifact@v6
226+
with:
227+
name: mysql-docker-image
228+
path: /tmp
229+
230+
- name: Load Docker image
231+
run: docker load --input /tmp/mysql-image.tar
232+
233+
- name: Log in to Docker Hub
234+
uses: docker/login-action@v3
235+
with:
236+
username: ${{ secrets.DOCKER_USER }}
237+
password: ${{ secrets.DOCKER_PASS }}
238+
239+
- name: Determine Docker tag
240+
id: docker-tag
241+
run: |
242+
if [ "${{ github.ref }}" == "refs/heads/master" ]; then
243+
DOCKER_TAG="${{ github.sha }}"
244+
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
245+
DOCKER_TAG="${{ github.ref_name }}"
246+
elif [[ "${{ github.ref }}" == refs/heads/feature.* ]]; then
247+
DOCKER_TAG="${{ github.ref_name }}"
248+
else
249+
echo "Not pushing to DockerHub for ref=${{ github.ref }}"
250+
exit 0
251+
fi
252+
echo "tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT
253+
echo "full_tag=${{ secrets.DOCKERHUB_REPO }}:${DOCKER_TAG}-mysql" >> $GITHUB_OUTPUT
254+
255+
- name: Tag and push Docker image
256+
if: steps.docker-tag.outputs.tag != ''
257+
run: |
258+
docker tag app:build ${{ steps.docker-tag.outputs.full_tag }}
259+
docker images
260+
docker push ${{ steps.docker-tag.outputs.full_tag }}

.github/workflows/postgres.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,50 @@ jobs:
218218
parent: false
219219
process_gcloudignore: false
220220

221+
deploy-postgres:
222+
runs-on: ubuntu-latest
223+
needs: postgres-e2e-tests
224+
if: |
225+
github.ref == 'refs/heads/master' ||
226+
startsWith(github.ref, 'refs/tags/') ||
227+
startsWith(github.ref, 'refs/heads/feature.')
228+
229+
steps:
230+
- name: Download Docker image
231+
uses: actions/download-artifact@v6
232+
with:
233+
name: postgres-docker-image
234+
path: /tmp
235+
236+
- name: Load Docker image
237+
run: docker load --input /tmp/postgres-image.tar
238+
239+
- name: Log in to Docker Hub
240+
uses: docker/login-action@v3
241+
with:
242+
username: ${{ secrets.DOCKER_USER }}
243+
password: ${{ secrets.DOCKER_PASS }}
244+
245+
- name: Determine Docker tag
246+
id: docker-tag
247+
run: |
248+
if [ "${{ github.ref }}" == "refs/heads/master" ]; then
249+
DOCKER_TAG="${{ github.sha }}"
250+
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
251+
DOCKER_TAG="${{ github.ref_name }}"
252+
elif [[ "${{ github.ref }}" == refs/heads/feature.* ]]; then
253+
DOCKER_TAG="${{ github.ref_name }}"
254+
else
255+
echo "Not pushing to DockerHub for ref=${{ github.ref }}"
256+
exit 0
257+
fi
258+
echo "tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT
259+
echo "full_tag=${{ secrets.DOCKERHUB_REPO }}:${DOCKER_TAG}-postgres" >> $GITHUB_OUTPUT
260+
261+
- name: Tag and push Docker image
262+
if: steps.docker-tag.outputs.tag != ''
263+
run: |
264+
docker tag app:build ${{ steps.docker-tag.outputs.full_tag }}
265+
docker images
266+
docker push ${{ steps.docker-tag.outputs.full_tag }}
267+

.github/workflows/spanner.yml

Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
name: Spanner Build, Test, and Push
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
push:
7+
branches:
8+
- "master"
9+
tags:
10+
- "**"
11+
workflow_dispatch: {}
12+
13+
env:
14+
RUST_VERSION: "1.89" # RUST_VER
15+
PYTHON_VERSION: "3.12" # PY_VER
16+
17+
jobs:
18+
build-and-test-spanner:
19+
runs-on: ubuntu-latest
20+
21+
services:
22+
spanner-emulator:
23+
image: gcr.io/cloud-spanner-emulator/emulator:1.4.0
24+
ports:
25+
- 9010:9010
26+
- 9020:9020
27+
28+
env:
29+
# The code expects a spanner URL like:
30+
SYNC_SYNCSTORAGE__DATABASE_URL: spanner://projects/test-project/instances/test-instance/databases/test-database
31+
RUST_BACKTRACE: 1
32+
RUST_TEST_THREADS: 1
33+
34+
steps:
35+
- uses: actions/checkout@v6
36+
37+
- uses: ./.github/actions/setup-rust
38+
with:
39+
workspace-path: workflow/test-results
40+
41+
- uses: ./.github/actions/setup-python
42+
with:
43+
workspace-path: workflow/test-results
44+
45+
- name: Create version.json
46+
run: |
47+
printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n' \
48+
"${{ github.sha }}" \
49+
"${{ github.ref_name }}" \
50+
"${{ github.repository_owner }}" \
51+
"${{ github.event.repository.name }}" \
52+
"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
53+
> syncserver/version.json
54+
55+
- name: Install test dependencies
56+
run: cargo install --locked cargo-nextest cargo-llvm-cov
57+
58+
- name: Build workspace (spanner feature)
59+
run: |
60+
# Build with the spanner feature so any compile-time issues surface early
61+
cargo build --workspace --no-default-features --features=syncstorage-db/spanner --features=py_verifier
62+
63+
- name: Wait for Spanner Emulator to be ready
64+
run: |
65+
echo "Waiting for Spanner emulator to be ready..."
66+
for i in {1..30}; do
67+
if curl -s http://localhost:9020/ > /dev/null 2>&1; then
68+
echo "Spanner emulator is ready (REST port 9020 responding)"
69+
break
70+
fi
71+
echo "Attempt $i/30: Spanner emulator not ready yet, waiting..."
72+
sleep 2
73+
done
74+
# Verify both ports are accessible
75+
if ! curl -s http://localhost:9020/ > /dev/null 2>&1; then
76+
echo "ERROR: Cannot connect to Spanner emulator REST API at localhost:9020"
77+
exit 1
78+
fi
79+
echo "Spanner emulator is fully ready"
80+
81+
- name: Setup Spanner schema & instance (prepare-spanner.sh)
82+
env:
83+
SYNC_SYNCSTORAGE__DATABASE_URL: spanner://projects/test-project/instances/test-instance/databases/test-database
84+
SYNC_SYNCSTORAGE__SPANNER_EMULATOR_HOST: http://localhost:9020
85+
run: |
86+
# prepare-spanner.sh uses the REST API (port 9020)
87+
scripts/prepare-spanner.sh
88+
89+
- name: Run Spanner unit tests with coverage
90+
env:
91+
SYNC_SYNCSTORAGE__DATABASE_URL: spanner://projects/test-project/instances/test-instance/databases/test-database
92+
SYNC_SYNCSTORAGE__SPANNER_EMULATOR_HOST: localhost:9010
93+
RUST_TEST_THREADS: 1
94+
run: make spanner_test_with_coverage
95+
96+
- name: Upload test results
97+
if: always()
98+
uses: actions/upload-artifact@v6
99+
with:
100+
name: spanner-test-results
101+
path: workflow/test-results/
102+
103+
# Upload to GCS on master
104+
- name: Authenticate to Google Cloud
105+
if: github.ref == 'refs/heads/master' && env.GCP_AUTH_KEY != ''
106+
env:
107+
GCP_AUTH_KEY: ${{ secrets.ETE_GCLOUD_SERVICE_KEY }}
108+
uses: google-github-actions/auth@v3
109+
with:
110+
credentials_json: ${{ secrets.ETE_GCLOUD_SERVICE_KEY }}
111+
112+
- name: Upload JUnit results to GCS
113+
if: github.ref == 'refs/heads/master' && env.GCP_AUTH_KEY != ''
114+
env:
115+
GCP_AUTH_KEY: ${{ secrets.ETE_GCLOUD_SERVICE_KEY }}
116+
uses: google-github-actions/upload-cloud-storage@v2
117+
with:
118+
path: workflow/test-results
119+
destination: ecosystem-test-eng-metrics/syncstorage-rs/junit
120+
glob: "*.xml"
121+
parent: false
122+
process_gcloudignore: false
123+
124+
- name: Upload coverage results to GCS
125+
if: github.ref == 'refs/heads/master' && env.GCP_AUTH_KEY != ''
126+
env:
127+
GCP_AUTH_KEY: ${{ secrets.ETE_GCLOUD_SERVICE_KEY }}
128+
uses: google-github-actions/upload-cloud-storage@v2
129+
with:
130+
path: workflow/test-results
131+
destination: ecosystem-test-eng-metrics/syncstorage-rs/coverage
132+
glob: "*.json"
133+
parent: false
134+
process_gcloudignore: false
135+
136+
build-spanner-image:
137+
runs-on: ubuntu-latest
138+
needs: build-and-test-spanner
139+
140+
steps:
141+
- uses: actions/checkout@v6
142+
143+
- name: Create version.json
144+
run: |
145+
printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n' \
146+
"${{ github.sha }}" \
147+
"${{ github.ref_name }}" \
148+
"${{ github.repository_owner }}" \
149+
"${{ github.event.repository.name }}" \
150+
"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
151+
> syncserver/version.json
152+
153+
- name: Set up Docker Buildx
154+
uses: docker/setup-buildx-action@v3
155+
156+
- name: Build Spanner Docker image (local artifact)
157+
uses: docker/build-push-action@v6
158+
with:
159+
context: .
160+
push: false
161+
tags: app:build
162+
build-args: |
163+
SYNCSTORAGE_DATABASE_BACKEND=spanner
164+
MYSQLCLIENT_PKG=libmysqlclient-dev
165+
outputs: type=docker,dest=/tmp/spanner-image.tar
166+
cache-from: type=gha
167+
cache-to: type=gha,mode=max
168+
169+
- name: Upload Docker image artifact
170+
uses: actions/upload-artifact@v6
171+
with:
172+
name: spanner-docker-image
173+
path: /tmp/spanner-image.tar
174+
retention-days: 1
175+
176+
spanner-e2e-tests:
177+
runs-on: ubuntu-latest
178+
needs: build-spanner-image
179+
180+
steps:
181+
- uses: actions/checkout@v6
182+
183+
- name: Download Docker image
184+
uses: actions/download-artifact@v6
185+
with:
186+
name: spanner-docker-image
187+
path: /tmp
188+
189+
- name: Load Docker image
190+
run: docker load --input /tmp/spanner-image.tar
191+
192+
- name: Create test results directory
193+
run: mkdir -p workflow/test-results
194+
195+
- name: Run Spanner e2e tests
196+
run: make docker_run_spanner_e2e_tests
197+
env:
198+
SYNCSTORAGE_RS_IMAGE: app:build
199+
200+
- name: Upload e2e test results
201+
if: always()
202+
uses: actions/upload-artifact@v6
203+
with:
204+
name: spanner-e2e-test-results
205+
path: workflow/test-results/
206+
207+
# Upload to GCS on master
208+
- name: Authenticate to Google Cloud
209+
if: github.ref == 'refs/heads/master' && env.GCP_AUTH_KEY != ''
210+
env:
211+
GCP_AUTH_KEY: ${{ secrets.ETE_GCLOUD_SERVICE_KEY }}
212+
uses: google-github-actions/auth@v3
213+
with:
214+
credentials_json: ${{ secrets.ETE_GCLOUD_SERVICE_KEY }}
215+
216+
- name: Upload e2e test results to GCS
217+
if: github.ref == 'refs/heads/master' && env.GCP_AUTH_KEY != ''
218+
env:
219+
GCP_AUTH_KEY: ${{ secrets.ETE_GCLOUD_SERVICE_KEY }}
220+
uses: google-github-actions/upload-cloud-storage@v2
221+
with:
222+
path: workflow/test-results
223+
destination: ecosystem-test-eng-metrics/syncstorage-rs/junit
224+
glob: "*.xml"
225+
parent: false
226+
process_gcloudignore: false
227+
228+
deploy-spanner:
229+
runs-on: ubuntu-latest
230+
needs: spanner-e2e-tests
231+
if: |
232+
github.ref == 'refs/heads/master' ||
233+
startsWith(github.ref, 'refs/tags/') ||
234+
startsWith(github.ref, 'refs/heads/feature.')
235+
236+
steps:
237+
- name: Download Docker image
238+
uses: actions/download-artifact@v6
239+
with:
240+
name: spanner-docker-image
241+
path: /tmp
242+
243+
- name: Load Docker image
244+
run: docker load --input /tmp/spanner-image.tar
245+
246+
- name: Log in to Docker Hub
247+
uses: docker/login-action@v3
248+
with:
249+
username: ${{ secrets.DOCKER_USER }}
250+
password: ${{ secrets.DOCKER_PASS }}
251+
252+
- name: Determine Docker tag
253+
id: docker-tag
254+
run: |
255+
if [ "${{ github.ref }}" == "refs/heads/master" ]; then
256+
DOCKER_TAG="${{ github.sha }}"
257+
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
258+
DOCKER_TAG="${{ github.ref_name }}"
259+
elif [[ "${{ github.ref }}" == refs/heads/feature.* ]]; then
260+
DOCKER_TAG="${{ github.ref_name }}"
261+
else
262+
echo "Not pushing to DockerHub for ref=${{ github.ref }}"
263+
exit 0
264+
fi
265+
echo "tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT
266+
echo "full_tag=${{ secrets.DOCKERHUB_REPO }}:${DOCKER_TAG}-spanner" >> $GITHUB_OUTPUT
267+
268+
- name: Tag and push Docker image
269+
if: steps.docker-tag.outputs.tag != ''
270+
run: |
271+
docker tag app:build ${{ steps.docker-tag.outputs.full_tag }}
272+
docker images
273+
docker push ${{ steps.docker-tag.outputs.full_tag }}

0 commit comments

Comments
 (0)