mirror of
https://github.com/dani-garcia/vaultwarden.wiki.git
synced 2026-11-14 01:26:07 +02:00
Speed up the Build workflow
- Pass the MariaDB client library to mysqlclient-sys through its environment variables, so a cached build no longer recompiles mysqlclient-sys, diesel and diesel_migrations in every MySQL build. The cache prefix changes once, because the old caches would keep rebuilding it. - Drop the sqlite,mysql,postgresql,enable_mimalloc test: enable_mimalloc is still tested on and off. - Test and lint unsafe_test_mode in the all-features runs instead of separate SQLite-only ones: it only adds the test seeder. - Only save caches on main, in the Build and SDK live tests workflows, to save cache space.
This commit is contained in:
2 files changed
+31
-34
No files matched your search
+27
-33
@@ -57,7 +57,23 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
- name: "Install dependencies Ubuntu"
|
- name: "Install dependencies Ubuntu"
|
||||||
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends openssl build-essential libmariadb-dev-compat libpq-dev libssl-dev pkg-config
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y --no-install-recommends openssl build-essential libmariadb-dev-compat libpq-dev libssl-dev pkg-config
|
||||||
|
|
||||||
|
# Pass the MariaDB client library to mysqlclient-sys through its environment variables.
|
||||||
|
# When it finds the library with pkg-config, its build script makes cargo rerun it whenever
|
||||||
|
# anything in the library directory changes, and the install above changes that directory on
|
||||||
|
# every run. So every MySQL build recompiled mysqlclient-sys, diesel and diesel_migrations,
|
||||||
|
# even with a cached build. Cargo compares environment variables by their value instead.
|
||||||
|
lib_dir="$(pkg-config --variable=libdir mysqlclient)"
|
||||||
|
version="$(pkg-config --modversion mysqlclient)"
|
||||||
|
{
|
||||||
|
echo "MYSQLCLIENT_NO_PKG_CONFIG=1"
|
||||||
|
echo "LIBMARIADB_NO_PKG_CONFIG=1"
|
||||||
|
echo "MYSQLCLIENT_LIB_DIR=${lib_dir}"
|
||||||
|
echo "MYSQLCLIENT_VERSION=${version}"
|
||||||
|
} | tee -a "${GITHUB_ENV}"
|
||||||
# End Install dependencies
|
# End Install dependencies
|
||||||
|
|
||||||
# Checkout the repo
|
# Checkout the repo
|
||||||
@@ -118,22 +134,19 @@ jobs:
|
|||||||
# Use a custom prefix-key to force a fresh start. This is sometimes needed with bigger changes.
|
# Use a custom prefix-key to force a fresh start. This is sometimes needed with bigger changes.
|
||||||
# Like changing the build host from Ubuntu 20.04 to 22.04 for example.
|
# Like changing the build host from Ubuntu 20.04 to 22.04 for example.
|
||||||
# Only update when really needed! Use a <year>.<month>[.<inc>] format.
|
# Only update when really needed! Use a <year>.<month>[.<inc>] format.
|
||||||
prefix-key: "v2025.09-rust"
|
prefix-key: "v2026.11-rust"
|
||||||
|
# Only save caches on main to save cache space.
|
||||||
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
||||||
# End Enable Rust Caching
|
# End Enable Rust Caching
|
||||||
|
|
||||||
# Run cargo tests
|
# Run cargo tests
|
||||||
# First test all features together, afterwards test them separately.
|
# First test all features together, afterwards test them separately.
|
||||||
- name: "test features: sqlite,mysql,postgresql,enable_mimalloc,s3"
|
# enable_mimalloc and unsafe_test_mode are additive, so we test them once here.
|
||||||
|
- name: "test features: sqlite,mysql,postgresql,enable_mimalloc,s3,unsafe_test_mode"
|
||||||
id: test_sqlite_mysql_postgresql_mimalloc_s3
|
id: test_sqlite_mysql_postgresql_mimalloc_s3
|
||||||
if: ${{ !cancelled() }}
|
if: ${{ !cancelled() }}
|
||||||
run: |
|
run: |
|
||||||
cargo test --profile ci --features sqlite,mysql,postgresql,enable_mimalloc,s3
|
cargo test --profile ci --features sqlite,mysql,postgresql,enable_mimalloc,s3,unsafe_test_mode
|
||||||
|
|
||||||
- name: "test features: sqlite,mysql,postgresql,enable_mimalloc"
|
|
||||||
id: test_sqlite_mysql_postgresql_mimalloc
|
|
||||||
if: ${{ !cancelled() }}
|
|
||||||
run: |
|
|
||||||
cargo test --profile ci --features sqlite,mysql,postgresql,enable_mimalloc
|
|
||||||
|
|
||||||
- name: "test features: sqlite,mysql,postgresql"
|
- name: "test features: sqlite,mysql,postgresql"
|
||||||
id: test_sqlite_mysql_postgresql
|
id: test_sqlite_mysql_postgresql
|
||||||
@@ -158,28 +171,15 @@ jobs:
|
|||||||
if: ${{ !cancelled() }}
|
if: ${{ !cancelled() }}
|
||||||
run: |
|
run: |
|
||||||
cargo test --profile ci --features postgresql
|
cargo test --profile ci --features postgresql
|
||||||
|
|
||||||
# The test seeder only exists with this feature, which no release build has
|
|
||||||
- name: "test features: sqlite,unsafe_test_mode"
|
|
||||||
id: test_unsafe_test_mode
|
|
||||||
if: ${{ !cancelled() }}
|
|
||||||
run: |
|
|
||||||
cargo test --profile ci --features sqlite,unsafe_test_mode
|
|
||||||
# End Run cargo tests
|
# End Run cargo tests
|
||||||
|
|
||||||
|
|
||||||
# Run cargo clippy, and fail on warnings
|
# Run cargo clippy, and fail on warnings
|
||||||
- name: "clippy features: sqlite,mysql,postgresql,enable_mimalloc,s3"
|
- name: "clippy features: sqlite,mysql,postgresql,enable_mimalloc,s3,unsafe_test_mode"
|
||||||
id: clippy
|
id: clippy
|
||||||
if: ${{ !cancelled() && matrix.channel == 'rust-toolchain' }}
|
if: ${{ !cancelled() && matrix.channel == 'rust-toolchain' }}
|
||||||
run: |
|
run: |
|
||||||
cargo clippy --profile ci --features sqlite,mysql,postgresql,enable_mimalloc,s3
|
cargo clippy --profile ci --features sqlite,mysql,postgresql,enable_mimalloc,s3,unsafe_test_mode
|
||||||
|
|
||||||
- name: "clippy features: sqlite,unsafe_test_mode"
|
|
||||||
id: clippy_unsafe_test_mode
|
|
||||||
if: ${{ !cancelled() && matrix.channel == 'rust-toolchain' }}
|
|
||||||
run: |
|
|
||||||
cargo clippy --profile ci --features sqlite,unsafe_test_mode
|
|
||||||
# End Run cargo clippy
|
# End Run cargo clippy
|
||||||
|
|
||||||
|
|
||||||
@@ -198,29 +198,23 @@ jobs:
|
|||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
env:
|
env:
|
||||||
TEST_DB_M_S3: ${{ steps.test_sqlite_mysql_postgresql_mimalloc_s3.outcome }}
|
TEST_DB_M_S3: ${{ steps.test_sqlite_mysql_postgresql_mimalloc_s3.outcome }}
|
||||||
TEST_DB_M: ${{ steps.test_sqlite_mysql_postgresql_mimalloc.outcome }}
|
|
||||||
TEST_DB: ${{ steps.test_sqlite_mysql_postgresql.outcome }}
|
TEST_DB: ${{ steps.test_sqlite_mysql_postgresql.outcome }}
|
||||||
TEST_SQLITE: ${{ steps.test_sqlite.outcome }}
|
TEST_SQLITE: ${{ steps.test_sqlite.outcome }}
|
||||||
TEST_MYSQL: ${{ steps.test_mysql.outcome }}
|
TEST_MYSQL: ${{ steps.test_mysql.outcome }}
|
||||||
TEST_POSTGRESQL: ${{ steps.test_postgresql.outcome }}
|
TEST_POSTGRESQL: ${{ steps.test_postgresql.outcome }}
|
||||||
TEST_UNSAFE_TEST_MODE: ${{ steps.test_unsafe_test_mode.outcome }}
|
|
||||||
CLIPPY: ${{ steps.clippy.outcome }}
|
CLIPPY: ${{ steps.clippy.outcome }}
|
||||||
CLIPPY_UNSAFE_TEST_MODE: ${{ steps.clippy_unsafe_test_mode.outcome }}
|
|
||||||
FMT: ${{ steps.formatting.outcome }}
|
FMT: ${{ steps.formatting.outcome }}
|
||||||
run: |
|
run: |
|
||||||
echo "### :x: Checks Failed!" >> "${GITHUB_STEP_SUMMARY}"
|
echo "### :x: Checks Failed!" >> "${GITHUB_STEP_SUMMARY}"
|
||||||
echo "" >> "${GITHUB_STEP_SUMMARY}"
|
echo "" >> "${GITHUB_STEP_SUMMARY}"
|
||||||
echo "|Job|Status|" >> "${GITHUB_STEP_SUMMARY}"
|
echo "|Job|Status|" >> "${GITHUB_STEP_SUMMARY}"
|
||||||
echo "|---|------|" >> "${GITHUB_STEP_SUMMARY}"
|
echo "|---|------|" >> "${GITHUB_STEP_SUMMARY}"
|
||||||
echo "|test (sqlite,mysql,postgresql,enable_mimalloc,s3)|${TEST_DB_M_S3}|" >> "${GITHUB_STEP_SUMMARY}"
|
echo "|test (sqlite,mysql,postgresql,enable_mimalloc,s3,unsafe_test_mode)|${TEST_DB_M_S3}|" >> "${GITHUB_STEP_SUMMARY}"
|
||||||
echo "|test (sqlite,mysql,postgresql,enable_mimalloc)|${TEST_DB_M}|" >> "${GITHUB_STEP_SUMMARY}"
|
|
||||||
echo "|test (sqlite,mysql,postgresql)|${TEST_DB}|" >> "${GITHUB_STEP_SUMMARY}"
|
echo "|test (sqlite,mysql,postgresql)|${TEST_DB}|" >> "${GITHUB_STEP_SUMMARY}"
|
||||||
echo "|test (sqlite)|${TEST_SQLITE}|" >> "${GITHUB_STEP_SUMMARY}"
|
echo "|test (sqlite)|${TEST_SQLITE}|" >> "${GITHUB_STEP_SUMMARY}"
|
||||||
echo "|test (mysql)|${TEST_MYSQL}|" >> "${GITHUB_STEP_SUMMARY}"
|
echo "|test (mysql)|${TEST_MYSQL}|" >> "${GITHUB_STEP_SUMMARY}"
|
||||||
echo "|test (postgresql)|${TEST_POSTGRESQL}|" >> "${GITHUB_STEP_SUMMARY}"
|
echo "|test (postgresql)|${TEST_POSTGRESQL}|" >> "${GITHUB_STEP_SUMMARY}"
|
||||||
echo "|test (sqlite,unsafe_test_mode)|${TEST_UNSAFE_TEST_MODE}|" >> "${GITHUB_STEP_SUMMARY}"
|
echo "|clippy (sqlite,mysql,postgresql,enable_mimalloc,s3,unsafe_test_mode)|${CLIPPY}|" >> "${GITHUB_STEP_SUMMARY}"
|
||||||
echo "|clippy (sqlite,mysql,postgresql,enable_mimalloc,s3)|${CLIPPY}|" >> "${GITHUB_STEP_SUMMARY}"
|
|
||||||
echo "|clippy (sqlite,unsafe_test_mode)|${CLIPPY_UNSAFE_TEST_MODE}|" >> "${GITHUB_STEP_SUMMARY}"
|
|
||||||
echo "|fmt|${FMT}|" >> "${GITHUB_STEP_SUMMARY}"
|
echo "|fmt|${FMT}|" >> "${GITHUB_STEP_SUMMARY}"
|
||||||
echo "" >> "${GITHUB_STEP_SUMMARY}"
|
echo "" >> "${GITHUB_STEP_SUMMARY}"
|
||||||
echo "Please check the failed jobs and fix where needed." >> "${GITHUB_STEP_SUMMARY}"
|
echo "Please check the failed jobs and fix where needed." >> "${GITHUB_STEP_SUMMARY}"
|
||||||
|
|||||||
@@ -105,7 +105,8 @@ jobs:
|
|||||||
rustup component add rust-src
|
rustup component add rust-src
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# One cache per SDK source, so that neither restores the other's
|
# One cache per SDK source, so that neither restores the other's.
|
||||||
|
# Only save caches on main to save cache space.
|
||||||
- name: "Cache Rust builds"
|
- name: "Cache Rust builds"
|
||||||
if: ${{ steps.sdk.outputs.source == 'npm' }}
|
if: ${{ steps.sdk.outputs.source == 'npm' }}
|
||||||
uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
|
uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
|
||||||
@@ -113,6 +114,7 @@ jobs:
|
|||||||
key: sdk-live-tests-npm
|
key: sdk-live-tests-npm
|
||||||
add-job-id-key: false
|
add-job-id-key: false
|
||||||
workspaces: ". -> target"
|
workspaces: ". -> target"
|
||||||
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
||||||
|
|
||||||
- name: "Cache Rust builds (with the SDK)"
|
- name: "Cache Rust builds (with the SDK)"
|
||||||
if: ${{ steps.sdk.outputs.source == 'git' }}
|
if: ${{ steps.sdk.outputs.source == 'git' }}
|
||||||
@@ -123,6 +125,7 @@ jobs:
|
|||||||
workspaces: |
|
workspaces: |
|
||||||
. -> target
|
. -> target
|
||||||
sdk-internal -> target
|
sdk-internal -> target
|
||||||
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
||||||
|
|
||||||
- name: "Setup Node"
|
- name: "Setup Node"
|
||||||
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||||
|
|||||||
Reference in new issue
Block a user