Skip to content

Commit ee45437

Browse files
authored
Merge branch 'master' into feat/post_bsos-STOR-423
2 parents 1999620 + f125cf6 commit ee45437

15 files changed

Lines changed: 434 additions & 48 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Setup Python Environment
2+
description: Sets up Python with Poetry dependencies
3+
4+
inputs:
5+
python-version:
6+
description: "Python version to use"
7+
required: false
8+
default: "3.12" # PYTHON_VER
9+
workspace-path:
10+
description: "The directory path to store test results"
11+
required: false
12+
default: "workflow"
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v6 # <https://github.com/actions/setup-python>
21+
with:
22+
python-version: ${{ inputs.python-version }}
23+
24+
- name: Install Poetry
25+
shell: bash
26+
run: pip install poetry
27+
28+
- name: Install Python dependencies with Poetry
29+
shell: bash
30+
run: |
31+
poetry install --with tokenserver-unit-tests,dev --no-interaction --no-ansi
32+
33+
- name: Create workspace directory
34+
shell: bash
35+
run: mkdir -p ${{ inputs.workspace-path }}
36+
37+
- name: Display Version Info
38+
shell: bash
39+
run: |
40+
if [ "$(which python)" != "" ]; then python --version; fi
41+
uname -a
42+
cat /etc/os-release
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Setup Rust Environment
2+
description: Sets up Rust
3+
4+
inputs:
5+
rust-version:
6+
description: "Rust version to install"
7+
required: false
8+
default: "1.89" # RUST_VER
9+
workspace-path:
10+
description: "The directory path to store test results"
11+
required: false
12+
default: "workflow"
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- name: Install Rust toolchain
20+
uses: dtolnay/rust-toolchain@v1 # See <https://github.com/dtolnay/rust-toolchain>
21+
with:
22+
toolchain: ${{ inputs.rust-version }}
23+
components: rustfmt, clippy
24+
25+
- name: Install cargo-audit
26+
shell: bash
27+
run: cargo install --locked cargo-audit
28+
29+
- name: Create workspace directory
30+
shell: bash
31+
run: mkdir -p ${{ inputs.workspace-path }}
32+
33+
- name: Display Version Info
34+
shell: bash
35+
run: |
36+
if [ "$(which rustc)" != "" ]; then rustc --version; fi
37+
uname -a
38+
cat /etc/os-release

.github/workflows/checks.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Checks
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
pull_request:
8+
branches:
9+
- "**"
10+
11+
jobs:
12+
python-checks:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v6
16+
17+
- uses: ./.github/actions/setup-python
18+
with:
19+
workspace-path: workflow
20+
21+
- name: Python Format Check
22+
run: make ruff-fmt-chk
23+
24+
- name: Python Lint Check
25+
run: make ruff-lint
26+
27+
rust-checks:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v6
31+
32+
- uses: ./.github/actions/setup-rust
33+
with:
34+
workspace-path: workflow
35+
36+
- name: Rust Format Check
37+
run: cargo fmt -- --check
38+
39+
- name: Cargo Audit
40+
run: cargo audit
41+
42+
- name: Rust Clippy Spanner
43+
run: make clippy_spanner
44+
45+
- name: Rust Clippy MySQL
46+
run: make clippy_mysql
47+
48+
- name: Rust Clippy Postgres
49+
run: make clippy_postgres
50+
51+
- name: Setup documentation checks
52+
run: make doc-install-deps
53+
54+
- name: Documentation checks
55+
run: make doc-test

.github/workflows/mozcloud-publish.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,29 @@ jobs:
114114
dockerfile_path: tools/postgres/Dockerfile
115115
image_build_context: tools/postgres
116116
should_tag_ghcr: true
117+
118+
build-and-push-syncstorage-rs-mysql:
119+
if: >
120+
github.event_name == 'workflow_dispatch' ||
121+
(
122+
github.event_name == 'push' &&
123+
(github.ref_name == 'master' || startsWith(github.ref, 'refs/tags/'))
124+
) ||
125+
(
126+
github.event_name == 'pull_request' &&
127+
contains(github.event.pull_request.labels.*.name, 'preview') &&
128+
github.event.pull_request.head.repo.full_name == github.repository
129+
)
130+
permissions:
131+
contents: read
132+
id-token: write
133+
packages: write
134+
uses: mozilla-it/deploy-actions/.github/workflows/build-and-push.yml@1b87069d293273436a84dff04954a8950d3ff9ca # v6.1.0
135+
with:
136+
image_name: syncstorage-rs-mysql
137+
gar_name: sync-prod
138+
project_id: moz-fx-sync-prod
139+
docker_build_args: |
140+
SYNCSTORAGE_DATABASE_BACKEND=mysql
141+
TOKENSERVER_DATABASE_BACKEND=mysql
142+
should_tag_ghcr: true

.github/workflows/mysql.yml

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
name: MySQL Build and Test
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"
15+
PYTHON_VERSION: "3.12"
16+
17+
jobs:
18+
build-and-test-mysql:
19+
runs-on: ubuntu-latest
20+
21+
services:
22+
mysql:
23+
image: mysql:8.0
24+
env:
25+
MYSQL_ROOT_PASSWORD: password
26+
MYSQL_USER: test
27+
MYSQL_PASSWORD: test
28+
MYSQL_DATABASE: syncstorage
29+
ports:
30+
- 3306:3306
31+
options: >-
32+
--health-cmd="mysqladmin ping"
33+
--health-interval=10s
34+
--health-timeout=5s
35+
--health-retries=5
36+
37+
env:
38+
SYNC_SYNCSTORAGE__DATABASE_URL: mysql://test:test@127.0.0.1/syncstorage
39+
SYNC_TOKENSERVER__DATABASE_URL: mysql://test:test@127.0.0.1/tokenserver
40+
RUST_BACKTRACE: 1
41+
RUST_TEST_THREADS: 1
42+
43+
steps:
44+
- uses: actions/checkout@v6
45+
46+
- uses: ./.github/actions/setup-rust
47+
with:
48+
workspace-path: workflow/test-results
49+
50+
- uses: ./.github/actions/setup-python
51+
with:
52+
workspace-path: workflow/test-results
53+
54+
- name: Install MySQL client
55+
run: sudo apt-get update && sudo apt-get install -y default-mysql-client
56+
57+
- name: Create Tokenserver database
58+
run: |
59+
mysql -u root -ppassword -h 127.0.0.1 -e 'CREATE DATABASE tokenserver;'
60+
mysql -u root -ppassword -h 127.0.0.1 -e "GRANT ALL ON tokenserver.* to 'test'@'%';"
61+
62+
- name: Create version.json
63+
run: |
64+
printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n' \
65+
"${{ github.sha }}" \
66+
"${{ github.ref_name }}" \
67+
"${{ github.repository_owner }}" \
68+
"${{ github.event.repository.name }}" \
69+
"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
70+
> syncserver/version.json
71+
72+
- name: Install test dependencies
73+
run: cargo install --locked cargo-nextest cargo-llvm-cov
74+
75+
- name: Run unit tests with coverage
76+
run: make test_with_coverage
77+
78+
- name: Run unit tests with coverage (quota enforced)
79+
run: make test_with_coverage
80+
env:
81+
SYNC_SYNCSTORAGE__ENFORCE_QUOTA: 1
82+
83+
- name: Upload test results
84+
if: always()
85+
uses: actions/upload-artifact@v6
86+
with:
87+
name: mysql-test-results
88+
path: workflow/test-results/
89+
90+
# Upload to GCS on master
91+
- name: Authenticate to Google Cloud
92+
if: github.ref == 'refs/heads/master' && env.GCP_AUTH_KEY != ''
93+
env:
94+
GCP_AUTH_KEY: ${{ secrets.ETE_GCLOUD_SERVICE_KEY }}
95+
uses: google-github-actions/auth@v3
96+
with:
97+
credentials_json: ${{ secrets.ETE_GCLOUD_SERVICE_KEY }}
98+
99+
- name: Upload JUnit results to GCS
100+
if: github.ref == 'refs/heads/master' && env.GCP_AUTH_KEY != ''
101+
env:
102+
GCP_AUTH_KEY: ${{ secrets.ETE_GCLOUD_SERVICE_KEY }}
103+
uses: google-github-actions/upload-cloud-storage@v2
104+
with:
105+
path: workflow/test-results
106+
destination: ecosystem-test-eng-metrics/syncstorage-rs/junit
107+
glob: "*.xml"
108+
parent: false
109+
process_gcloudignore: false
110+
111+
- name: Upload coverage results to GCS
112+
if: github.ref == 'refs/heads/master' && env.GCP_AUTH_KEY != ''
113+
env:
114+
GCP_AUTH_KEY: ${{ secrets.ETE_GCLOUD_SERVICE_KEY }}
115+
uses: google-github-actions/upload-cloud-storage@v2
116+
with:
117+
path: workflow/test-results
118+
destination: ecosystem-test-eng-metrics/syncstorage-rs/coverage
119+
glob: "*.json"
120+
parent: false
121+
process_gcloudignore: false
122+
123+
build-mysql-image:
124+
runs-on: ubuntu-latest
125+
needs: build-and-test-mysql
126+
127+
steps:
128+
- uses: actions/checkout@v6
129+
130+
- name: Create version.json
131+
run: |
132+
printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n' \
133+
"${{ github.sha }}" \
134+
"${{ github.ref_name }}" \
135+
"${{ github.repository_owner }}" \
136+
"${{ github.event.repository.name }}" \
137+
"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
138+
> syncserver/version.json
139+
140+
- name: Set up Docker Buildx
141+
uses: docker/setup-buildx-action@v3
142+
143+
- name: Build MySQL Docker image
144+
uses: docker/build-push-action@v6
145+
with:
146+
context: .
147+
push: false
148+
tags: app:build
149+
build-args: |
150+
SYNCSTORAGE_DATABASE_BACKEND=mysql
151+
TOKENSERVER_DATABASE_BACKEND=mysql
152+
outputs: type=docker,dest=/tmp/mysql-image.tar
153+
cache-from: type=gha
154+
cache-to: type=gha,mode=max
155+
156+
- name: Upload Docker image artifact
157+
uses: actions/upload-artifact@v6
158+
with:
159+
name: mysql-docker-image
160+
path: /tmp/mysql-image.tar
161+
retention-days: 1
162+
163+
mysql-e2e-tests:
164+
runs-on: ubuntu-latest
165+
needs: build-mysql-image
166+
167+
steps:
168+
- uses: actions/checkout@v6
169+
170+
- name: Download Docker image
171+
uses: actions/download-artifact@v6
172+
with:
173+
name: mysql-docker-image
174+
path: /tmp
175+
176+
- name: Load Docker image
177+
run: docker load --input /tmp/mysql-image.tar
178+
179+
- name: Create test results directory
180+
run: mkdir -p workflow/test-results
181+
182+
- name: Run MySQL e2e tests
183+
run: make docker_run_mysql_e2e_tests
184+
env:
185+
SYNCSTORAGE_RS_IMAGE: app:build
186+
187+
- name: Upload e2e test results
188+
if: always()
189+
uses: actions/upload-artifact@v6
190+
with:
191+
name: mysql-e2e-test-results
192+
path: workflow/test-results/
193+
194+
# Upload to GCS on master
195+
- name: Authenticate to Google Cloud
196+
if: github.ref == 'refs/heads/master' && env.GCP_AUTH_KEY != ''
197+
env:
198+
GCP_AUTH_KEY: ${{ secrets.ETE_GCLOUD_SERVICE_KEY }}
199+
uses: google-github-actions/auth@v3
200+
with:
201+
credentials_json: ${{ secrets.ETE_GCLOUD_SERVICE_KEY }}
202+
203+
- name: Upload e2e test results to GCS
204+
if: github.ref == 'refs/heads/master' && env.GCP_AUTH_KEY != ''
205+
env:
206+
GCP_AUTH_KEY: ${{ secrets.ETE_GCLOUD_SERVICE_KEY }}
207+
uses: google-github-actions/upload-cloud-storage@v2
208+
with:
209+
path: workflow/test-results
210+
destination: ecosystem-test-eng-metrics/syncstorage-rs/junit
211+
glob: "*.xml"
212+
parent: false
213+
process_gcloudignore: false

0 commit comments

Comments
 (0)