mirror of
https://github.com/dani-garcia/vaultwarden
synced 2024-11-22 20:03:19 +00:00
34e00e1478
- Updated Rust to v1.74.0 - Updated all crates (where possible) - Changed release profile to use * fat lto * 1 codegen-unit This should optimize a bit for speed and a lot for size ~15MB smaller - Updated Github actions to use caching for the bake process - Added a schedule to clean the cache every week to prevent stale Debian/Alpine base images - During the release action, the Alpine/static binaries are added as artifects. Later we could also automatically add them to the releases maybe. - Added CODEWONERS to prevent unchecked changes to github actions workflows
197 lines
7.2 KiB
YAML
197 lines
7.2 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- ".github/workflows/build.yml"
|
|
- "src/**"
|
|
- "migrations/**"
|
|
- "Cargo.*"
|
|
- "build.rs"
|
|
- "rust-toolchain.toml"
|
|
- "rustfmt.toml"
|
|
- "diesel.toml"
|
|
- "docker/Dockerfile.j2"
|
|
- "docker/DockerSettings.yaml"
|
|
pull_request:
|
|
paths:
|
|
- ".github/workflows/build.yml"
|
|
- "src/**"
|
|
- "migrations/**"
|
|
- "Cargo.*"
|
|
- "build.rs"
|
|
- "rust-toolchain.toml"
|
|
- "rustfmt.toml"
|
|
- "diesel.toml"
|
|
- "docker/Dockerfile.j2"
|
|
- "docker/DockerSettings.yaml"
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-22.04
|
|
timeout-minutes: 120
|
|
# Make warnings errors, this is to prevent warnings slipping through.
|
|
# This is done globally to prevent rebuilds when the RUSTFLAGS env variable changes.
|
|
env:
|
|
RUSTFLAGS: "-D warnings"
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
channel:
|
|
- "rust-toolchain" # The version defined in rust-toolchain
|
|
- "msrv" # The supported MSRV
|
|
|
|
name: Build and Test ${{ matrix.channel }}
|
|
|
|
steps:
|
|
# Checkout the repo
|
|
- name: "Checkout"
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
|
|
# End Checkout the repo
|
|
|
|
|
|
# Install dependencies
|
|
- 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
|
|
# End Install dependencies
|
|
|
|
|
|
# Determine rust-toolchain version
|
|
- name: Init Variables
|
|
id: toolchain
|
|
shell: bash
|
|
run: |
|
|
if [[ "${{ matrix.channel }}" == 'rust-toolchain' ]]; then
|
|
RUST_TOOLCHAIN="$(grep -oP 'channel.*"(\K.*?)(?=")' rust-toolchain.toml)"
|
|
elif [[ "${{ matrix.channel }}" == 'msrv' ]]; then
|
|
RUST_TOOLCHAIN="$(grep -oP 'rust-version.*"(\K.*?)(?=")' Cargo.toml)"
|
|
else
|
|
RUST_TOOLCHAIN="${{ matrix.channel }}"
|
|
fi
|
|
echo "RUST_TOOLCHAIN=${RUST_TOOLCHAIN}" | tee -a "${GITHUB_OUTPUT}"
|
|
# End Determine rust-toolchain version
|
|
|
|
|
|
# Only install the clippy and rustfmt components on the default rust-toolchain
|
|
- name: "Install rust-toolchain version"
|
|
uses: dtolnay/rust-toolchain@439cf607258077187679211f12aa6f19af4a0af7 # master @ 2023-09-19 - 05:31 PM GMT+2
|
|
if: ${{ matrix.channel == 'rust-toolchain' }}
|
|
with:
|
|
toolchain: "${{steps.toolchain.outputs.RUST_TOOLCHAIN}}"
|
|
components: clippy, rustfmt
|
|
# End Uses the rust-toolchain file to determine version
|
|
|
|
|
|
# Install the any other channel to be used for which we do not execute clippy and rustfmt
|
|
- name: "Install MSRV version"
|
|
uses: dtolnay/rust-toolchain@439cf607258077187679211f12aa6f19af4a0af7 # master @ 2023-09-19 - 05:31 PM GMT+2
|
|
if: ${{ matrix.channel != 'rust-toolchain' }}
|
|
with:
|
|
toolchain: "${{steps.toolchain.outputs.RUST_TOOLCHAIN}}"
|
|
# End Install the MSRV channel to be used
|
|
|
|
# Set the current matrix toolchain version as default
|
|
- name: "Set toolchain ${{steps.toolchain.outputs.RUST_TOOLCHAIN}} as default"
|
|
run: |
|
|
# Remove the rust-toolchain.toml
|
|
rm rust-toolchain.toml
|
|
# Set the default
|
|
rustup default ${{steps.toolchain.outputs.RUST_TOOLCHAIN}}
|
|
|
|
# Show environment
|
|
- name: "Show environment"
|
|
run: |
|
|
rustc -vV
|
|
cargo -vV
|
|
# End Show environment
|
|
|
|
# Enable Rust Caching
|
|
- uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0
|
|
with:
|
|
# 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.
|
|
# Only update when really needed! Use a <year>.<month>[.<inc>] format.
|
|
prefix-key: "v2023.07-rust"
|
|
# End Enable Rust Caching
|
|
|
|
# Run cargo tests
|
|
# First test all features together, afterwards test them separately.
|
|
- name: "test features: sqlite,mysql,postgresql,enable_mimalloc"
|
|
id: test_sqlite_mysql_postgresql_mimalloc
|
|
if: $${{ always() }}
|
|
run: |
|
|
cargo test --features sqlite,mysql,postgresql,enable_mimalloc
|
|
|
|
- name: "test features: sqlite,mysql,postgresql"
|
|
id: test_sqlite_mysql_postgresql
|
|
if: $${{ always() }}
|
|
run: |
|
|
cargo test --features sqlite,mysql,postgresql
|
|
|
|
- name: "test features: sqlite"
|
|
id: test_sqlite
|
|
if: $${{ always() }}
|
|
run: |
|
|
cargo test --features sqlite
|
|
|
|
- name: "test features: mysql"
|
|
id: test_mysql
|
|
if: $${{ always() }}
|
|
run: |
|
|
cargo test --features mysql
|
|
|
|
- name: "test features: postgresql"
|
|
id: test_postgresql
|
|
if: $${{ always() }}
|
|
run: |
|
|
cargo test --features postgresql
|
|
# End Run cargo tests
|
|
|
|
|
|
# Run cargo clippy, and fail on warnings
|
|
- name: "clippy features: sqlite,mysql,postgresql,enable_mimalloc"
|
|
id: clippy
|
|
if: ${{ always() && matrix.channel == 'rust-toolchain' }}
|
|
run: |
|
|
cargo clippy --features sqlite,mysql,postgresql,enable_mimalloc -- -D warnings
|
|
# End Run cargo clippy
|
|
|
|
|
|
# Run cargo fmt (Only run on rust-toolchain defined version)
|
|
- name: "check formatting"
|
|
id: formatting
|
|
if: ${{ always() && matrix.channel == 'rust-toolchain' }}
|
|
run: |
|
|
cargo fmt --all -- --check
|
|
# End Run cargo fmt
|
|
|
|
|
|
# Check for any previous failures, if there are stop, else continue.
|
|
# This is useful so all test/clippy/fmt actions are done, and they can all be addressed
|
|
- name: "Some checks failed"
|
|
if: ${{ failure() }}
|
|
run: |
|
|
echo "### :x: Checks Failed!" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "|Job|Status|" >> $GITHUB_STEP_SUMMARY
|
|
echo "|---|------|" >> $GITHUB_STEP_SUMMARY
|
|
echo "|test (sqlite,mysql,postgresql,enable_mimalloc)|${{ steps.test_sqlite_mysql_postgresql_mimalloc.outcome }}|" >> $GITHUB_STEP_SUMMARY
|
|
echo "|test (sqlite,mysql,postgresql)|${{ steps.test_sqlite_mysql_postgresql.outcome }}|" >> $GITHUB_STEP_SUMMARY
|
|
echo "|test (sqlite)|${{ steps.test_sqlite.outcome }}|" >> $GITHUB_STEP_SUMMARY
|
|
echo "|test (mysql)|${{ steps.test_mysql.outcome }}|" >> $GITHUB_STEP_SUMMARY
|
|
echo "|test (postgresql)|${{ steps.test_postgresql.outcome }}|" >> $GITHUB_STEP_SUMMARY
|
|
echo "|clippy (sqlite,mysql,postgresql,enable_mimalloc)|${{ steps.clippy.outcome }}|" >> $GITHUB_STEP_SUMMARY
|
|
echo "|fmt|${{ steps.formatting.outcome }}|" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "Please check the failed jobs and fix where needed." >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
exit 1
|
|
|
|
|
|
# Check for any previous failures, if there are stop, else continue.
|
|
# This is useful so all test/clippy/fmt actions are done, and they can all be addressed
|
|
- name: "All checks passed"
|
|
if: ${{ success() }}
|
|
run: |
|
|
echo "### :tada: Checks Passed!" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|