@@ -367,7 +367,7 @@ jobs:
367367 uses : actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5
368368 with :
369369 path : /tmp/postgres-image.tar
370- key : ${{ runner.os }}-postgres-image-${{ hashFiles('Dockerfile', 'Cargo.lock', '**/*.rs', '**/Cargo.toml') }}
370+ key : ${{ runner.os }}-postgres-image-${{ hashFiles('Dockerfile', 'Cargo.lock', '**/*.rs', '**/Cargo.toml', 'tools/**', 'scripts/**' ) }}
371371
372372 - name : Set up Docker Buildx
373373 if : steps.cache-postgres-image.outputs.cache-hit != 'true'
@@ -455,3 +455,247 @@ jobs:
455455 glob : " *.xml"
456456 parent : false
457457 process_gcloudignore : false
458+
459+ # MySQL
460+ build-and-test-mysql :
461+ runs-on : ubuntu-latest
462+ needs : [rust-env, python-env]
463+ permissions :
464+ contents : read
465+ checks : write
466+
467+ services :
468+ mysql :
469+ image : mysql:8.0
470+ env :
471+ MYSQL_ROOT_PASSWORD : password
472+ MYSQL_USER : test
473+ MYSQL_PASSWORD : test
474+ MYSQL_DATABASE : syncstorage
475+ ports :
476+ - 3306:3306
477+ options : >-
478+ --health-cmd="mysqladmin ping"
479+ --health-interval=10s
480+ --health-timeout=5s
481+ --health-retries=5
482+
483+ env :
484+ SYNC_SYNCSTORAGE__DATABASE_URL : mysql://test:test@127.0.0.1/syncstorage
485+ SYNC_TOKENSERVER__DATABASE_URL : mysql://test:test@127.0.0.1/tokenserver
486+ SYNC_TOKENSERVER__NODE_TYPE : spanner
487+ RUST_BACKTRACE : 1
488+ RUST_TEST_THREADS : 1
489+
490+ steps :
491+ - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
492+ with :
493+ persist-credentials : false
494+
495+ - name : Restore Rust toolchain
496+ uses : actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5
497+ with :
498+ path : |
499+ ~/.rustup/toolchains
500+ ~/.rustup/update-hashes
501+ key : ${{ runner.os }}-rust-toolchain-${{ env.RUST_VERSION }}
502+
503+ - name : Restore pip and Poetry virtualenv
504+ uses : actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5
505+ with :
506+ path : |
507+ ~/.cache/pip
508+ ~/.cache/pypoetry/virtualenvs
509+ key : ${{ runner.os }}-python-${{ hashFiles('pyproject.toml', 'poetry.lock') }}
510+
511+ - name : Install MySQL client
512+ run : sudo apt-get update && sudo apt-get install -y default-mysql-client
513+
514+ - name : Create Tokenserver database
515+ run : |
516+ mysql -u root -ppassword -h 127.0.0.1 -e 'CREATE DATABASE tokenserver;'
517+ mysql -u root -ppassword -h 127.0.0.1 -e "GRANT ALL ON tokenserver.* to 'test'@'%';"
518+
519+ - name : Create version.json
520+ run : |
521+ printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n' \
522+ "${GITHUB_SHA}" \
523+ "${GITHUB_REF_NAME}" \
524+ "${GITHUB_REPOSITORY_OWNER}" \
525+ "${GITHUB_REPOSITORY_NAME}" \
526+ "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" \
527+ > version.json
528+ env :
529+ GITHUB_REPOSITORY_NAME : ${{ github.event.repository.name }}
530+
531+ - name : Install cargo-nextest
532+ run : curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
533+
534+ - name : Install cargo-llvm-cov
535+ run : cargo install --locked cargo-llvm-cov
536+
537+ - name : Run unit tests with coverage
538+ run : make test_with_coverage
539+
540+ - name : Run unit tests with coverage (quota enforced)
541+ run : make test_with_coverage
542+ env :
543+ SYNC_SYNCSTORAGE__ENFORCE_QUOTA : 1
544+
545+ - name : Publish Test Report
546+ uses : dorny/test-reporter@a810f9bf83f2344124a920a7a0a85a6716e791f0
547+ if : always()
548+ with :
549+ name : MySQL Unit Tests
550+ path : workflow/test-results/*.xml
551+ reporter : java-junit
552+ fail-on-error : false
553+
554+ - name : Upload test results
555+ if : always()
556+ uses : actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
557+ with :
558+ name : mysql-test-results
559+ path : workflow/test-results/
560+
561+ # Upload to GCS on master
562+ - name : Authenticate to Google Cloud
563+ if : github.ref == 'refs/heads/master'
564+ uses : google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3
565+ with :
566+ credentials_json : ${{ secrets.ETE_GCLOUD_SERVICE_KEY }}
567+
568+ - name : Upload JUnit results to GCS
569+ if : github.ref == 'refs/heads/master'
570+ uses : google-github-actions/upload-cloud-storage@c0f6160ff80057923ff50e5e567695cea181ec23 # v2
571+ with :
572+ path : workflow/test-results
573+ destination : ecosystem-test-eng-metrics/syncstorage-rs/junit
574+ glob : " *.xml"
575+ parent : false
576+ process_gcloudignore : false
577+
578+ - name : Upload coverage results to GCS
579+ if : github.ref == 'refs/heads/master'
580+ uses : google-github-actions/upload-cloud-storage@c0f6160ff80057923ff50e5e567695cea181ec23 # v2
581+ with :
582+ path : workflow/test-results
583+ destination : ecosystem-test-eng-metrics/syncstorage-rs/coverage
584+ glob : " *.json"
585+ parent : false
586+ process_gcloudignore : false
587+
588+ build-mysql-image :
589+ runs-on : ubuntu-latest
590+ needs : [rust-env, python-env]
591+ permissions :
592+ contents : read
593+ actions : write
594+
595+ steps :
596+ - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
597+ with :
598+ persist-credentials : false
599+
600+ - name : Create version.json
601+ run : |
602+ printf '{"commit":"%s","version":"%s","source":"https://github.com/%s/%s","build":"%s"}\n' \
603+ "${GITHUB_SHA}" \
604+ "${GITHUB_REF_NAME}" \
605+ "${GITHUB_REPOSITORY_OWNER}" \
606+ "${GITHUB_REPOSITORY_NAME}" \
607+ "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" \
608+ > version.json
609+ env :
610+ GITHUB_REPOSITORY_NAME : ${{ github.event.repository.name }}
611+
612+ - name : Cache Docker image tar
613+ id : cache-mysql-image
614+ uses : actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5
615+ with :
616+ path : /tmp/mysql-image.tar
617+ key : ${{ runner.os }}-mysql-image-${{ hashFiles('Dockerfile', 'Cargo.lock', '**/*.rs', '**/Cargo.toml', 'tools/**', 'scripts/**') }}
618+ - name : Set up Docker Buildx
619+ uses : docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
620+
621+ - name : Build MySQL Docker image
622+ uses : docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
623+ with :
624+ context : .
625+ push : false
626+ tags : app:build
627+ build-args : |
628+ SYNCSTORAGE_DATABASE_BACKEND=mysql
629+ TOKENSERVER_DATABASE_BACKEND=mysql
630+ outputs : type=docker,dest=/tmp/mysql-image.tar
631+ cache-from : type=gha
632+ cache-to : type=gha,mode=max
633+
634+ - name : Upload Docker image artifact
635+ uses : actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
636+ with :
637+ name : mysql-docker-image
638+ path : /tmp/mysql-image.tar
639+ retention-days : 1
640+
641+ mysql-e2e-tests :
642+ runs-on : ubuntu-latest
643+ needs : build-mysql-image
644+ permissions :
645+ contents : read
646+ checks : write
647+
648+ steps :
649+ - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
650+ with :
651+ persist-credentials : false
652+
653+ - name : Download Docker image
654+ uses : actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6
655+ with :
656+ name : mysql-docker-image
657+ path : /tmp
658+
659+ - name : Load Docker image
660+ run : docker load --input /tmp/mysql-image.tar
661+
662+ - name : Create test results directory
663+ run : mkdir -p workflow/test-results
664+
665+ - name : Run MySQL e2e tests
666+ run : make docker_run_mysql_e2e_tests
667+ env :
668+ SYNCSTORAGE_RS_IMAGE : app:build
669+
670+ - name : Publish E2E Test Report
671+ uses : dorny/test-reporter@a810f9bf83f2344124a920a7a0a85a6716e791f0
672+ if : always()
673+ with :
674+ name : MySQL E2E Tests
675+ path : workflow/test-results/*.xml
676+ reporter : java-junit
677+ fail-on-error : false
678+
679+ - name : Upload e2e test results
680+ if : always()
681+ uses : actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
682+ with :
683+ name : mysql-e2e-test-results
684+ path : workflow/test-results/
685+
686+ # Upload to GCS on master
687+ - name : Authenticate to Google Cloud
688+ if : github.ref == 'refs/heads/master'
689+ uses : google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3
690+ with :
691+ credentials_json : ${{ secrets.ETE_GCLOUD_SERVICE_KEY }}
692+
693+ - name : Upload e2e test results to GCS
694+ if : github.ref == 'refs/heads/master'
695+ uses : google-github-actions/upload-cloud-storage@c0f6160ff80057923ff50e5e567695cea181ec23 # v2
696+ with :
697+ path : workflow/test-results
698+ destination : ecosystem-test-eng-metrics/syncstorage-rs/junit
699+ glob : " *.xml"
700+ parent : false
701+ process_gcloudignore : false
0 commit comments