2020-12-16 19:31:39 +01:00
|
|
|
name: Build
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2021-08-28 17:29:13 +02:00
|
|
|
paths:
|
|
|
|
- ".github/workflows/build.yml"
|
|
|
|
- "src/**"
|
|
|
|
- "migrations/**"
|
|
|
|
- "Cargo.*"
|
|
|
|
- "build.rs"
|
|
|
|
- "rust-toolchain"
|
2021-03-27 16:21:00 +01:00
|
|
|
pull_request:
|
2021-08-28 17:29:13 +02:00
|
|
|
paths:
|
|
|
|
- ".github/workflows/build.yml"
|
|
|
|
- "src/**"
|
|
|
|
- "migrations/**"
|
|
|
|
- "Cargo.*"
|
|
|
|
- "build.rs"
|
|
|
|
- "rust-toolchain"
|
2020-12-16 19:31:39 +01:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
2022-07-19 19:13:54 +02:00
|
|
|
runs-on: ubuntu-20.04
|
2022-12-15 17:15:48 +01:00
|
|
|
timeout-minutes: 120
|
2021-05-08 16:48:48 +02:00
|
|
|
# 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"
|
2020-12-16 19:31:39 +01:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
channel:
|
2022-07-19 19:13:54 +02:00
|
|
|
- "rust-toolchain" # The version defined in rust-toolchain
|
2022-09-15 16:51:52 +02:00
|
|
|
- "msrv" # The supported MSRV
|
|
|
|
include:
|
|
|
|
- channel: "msrv"
|
2023-01-09 16:49:26 +01:00
|
|
|
version: "1.61.0"
|
2022-07-19 19:13:54 +02:00
|
|
|
|
|
|
|
name: Build and Test ${{ matrix.channel }}
|
|
|
|
|
2020-12-16 19:31:39 +01:00
|
|
|
steps:
|
|
|
|
# Checkout the repo
|
2022-07-19 19:13:54 +02:00
|
|
|
- name: "Checkout"
|
2022-12-15 17:15:48 +01:00
|
|
|
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0
|
2020-12-16 19:31:39 +01:00
|
|
|
# End Checkout the repo
|
|
|
|
|
|
|
|
# Install dependencies
|
2022-07-19 19:13:54 +02:00
|
|
|
- name: "Install dependencies Ubuntu"
|
|
|
|
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends openssl sqlite build-essential libmariadb-dev-compat libpq-dev libssl-dev pkg-config
|
2020-12-16 19:31:39 +01:00
|
|
|
# End Install dependencies
|
|
|
|
|
2022-11-04 12:56:02 +01:00
|
|
|
# Determine rust-toolchain version
|
|
|
|
- name: Init Variables
|
|
|
|
id: toolchain
|
|
|
|
shell: bash
|
|
|
|
if: ${{ matrix.channel == 'rust-toolchain' }}
|
|
|
|
run: |
|
|
|
|
RUST_TOOLCHAIN="$(cat rust-toolchain)"
|
|
|
|
echo "RUST_TOOLCHAIN=${RUST_TOOLCHAIN}" | tee -a "${GITHUB_OUTPUT}"
|
|
|
|
# End Determine rust-toolchain version
|
2020-12-16 19:31:39 +01:00
|
|
|
|
|
|
|
# Uses the rust-toolchain file to determine version
|
2022-07-19 19:13:54 +02:00
|
|
|
- name: "Install rust-toolchain version"
|
2022-11-04 12:56:02 +01:00
|
|
|
uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb # master @ 2022-10-25 - 21:40 GMT+2
|
2022-07-19 19:13:54 +02:00
|
|
|
if: ${{ matrix.channel == 'rust-toolchain' }}
|
2020-12-16 19:31:39 +01:00
|
|
|
with:
|
2022-11-04 12:56:02 +01:00
|
|
|
toolchain: "${{steps.toolchain.outputs.RUST_TOOLCHAIN}}"
|
2021-03-28 17:48:45 +02:00
|
|
|
components: clippy, rustfmt
|
2020-12-16 19:31:39 +01:00
|
|
|
# End Uses the rust-toolchain file to determine version
|
|
|
|
|
|
|
|
|
2022-07-19 19:13:54 +02:00
|
|
|
# Install the MSRV channel to be used
|
|
|
|
- name: "Install MSRV version"
|
2022-11-04 12:56:02 +01:00
|
|
|
uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb # master @ 2022-10-25 - 21:40 GMT+2
|
2022-07-19 19:13:54 +02:00
|
|
|
if: ${{ matrix.channel != 'rust-toolchain' }}
|
|
|
|
with:
|
2022-09-15 16:51:52 +02:00
|
|
|
toolchain: ${{ matrix.version }}
|
2022-07-19 19:13:54 +02:00
|
|
|
# End Install the MSRV channel to be used
|
|
|
|
|
|
|
|
|
|
|
|
# Enable Rust Caching
|
2022-12-15 17:15:48 +01:00
|
|
|
- uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 # v2.2.0
|
2022-07-19 19:13:54 +02:00
|
|
|
# End Enable Rust Caching
|
|
|
|
|
|
|
|
|
|
|
|
# Show environment
|
|
|
|
- name: "Show environment"
|
|
|
|
run: |
|
|
|
|
rustc -vV
|
|
|
|
cargo -vV
|
|
|
|
# End Show environment
|
|
|
|
|
|
|
|
|
2021-03-27 16:10:00 +01:00
|
|
|
# Run cargo tests (In release mode to speed up future builds)
|
2021-05-08 16:48:48 +02:00
|
|
|
# First test all features together, afterwards test them separately.
|
2022-07-19 19:13:54 +02:00
|
|
|
- name: "test features: sqlite,mysql,postgresql,enable_mimalloc"
|
|
|
|
id: test_sqlite_mysql_postgresql_mimalloc
|
|
|
|
if: $${{ always() }}
|
2022-11-04 12:56:02 +01:00
|
|
|
run: |
|
|
|
|
cargo test --release --features sqlite,mysql,postgresql,enable_mimalloc
|
2022-07-19 19:13:54 +02:00
|
|
|
|
|
|
|
- name: "test features: sqlite,mysql,postgresql"
|
|
|
|
id: test_sqlite_mysql_postgresql
|
|
|
|
if: $${{ always() }}
|
2022-11-04 12:56:02 +01:00
|
|
|
run: |
|
|
|
|
cargo test --release --features sqlite,mysql,postgresql
|
2022-07-19 19:13:54 +02:00
|
|
|
|
|
|
|
- name: "test features: sqlite"
|
|
|
|
id: test_sqlite
|
|
|
|
if: $${{ always() }}
|
2022-11-04 12:56:02 +01:00
|
|
|
run: |
|
|
|
|
cargo test --release --features sqlite
|
2022-07-19 19:13:54 +02:00
|
|
|
|
|
|
|
- name: "test features: mysql"
|
|
|
|
id: test_mysql
|
|
|
|
if: $${{ always() }}
|
2022-11-04 12:56:02 +01:00
|
|
|
run: |
|
|
|
|
cargo test --release --features mysql
|
2022-07-19 19:13:54 +02:00
|
|
|
|
|
|
|
- name: "test features: postgresql"
|
|
|
|
id: test_postgresql
|
|
|
|
if: $${{ always() }}
|
2022-11-04 12:56:02 +01:00
|
|
|
run: |
|
|
|
|
cargo test --release --features postgresql
|
2020-12-16 19:31:39 +01:00
|
|
|
# End Run cargo tests
|
|
|
|
|
|
|
|
|
2021-05-08 16:48:48 +02:00
|
|
|
# Run cargo clippy, and fail on warnings (In release mode to speed up future builds)
|
2022-07-19 19:13:54 +02:00
|
|
|
- name: "clippy features: sqlite,mysql,postgresql,enable_mimalloc"
|
|
|
|
id: clippy
|
|
|
|
if: ${{ always() && matrix.channel == 'rust-toolchain' }}
|
2022-11-04 12:56:02 +01:00
|
|
|
run: |
|
|
|
|
cargo clippy --release --features sqlite,mysql,postgresql,enable_mimalloc -- -D warnings
|
2021-03-27 16:10:00 +01:00
|
|
|
# End Run cargo clippy
|
|
|
|
|
|
|
|
|
2022-07-19 19:13:54 +02:00
|
|
|
# Run cargo fmt (Only run on rust-toolchain defined version)
|
|
|
|
- name: "check formatting"
|
|
|
|
id: formatting
|
|
|
|
if: ${{ always() && matrix.channel == 'rust-toolchain' }}
|
2022-11-04 12:56:02 +01:00
|
|
|
run: |
|
|
|
|
cargo fmt --all -- --check
|
2021-03-28 17:48:45 +02:00
|
|
|
# End Run cargo fmt
|
|
|
|
|
|
|
|
|
2022-07-19 19:13:54 +02:00
|
|
|
# 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
|
|
|
|
|
|
|
|
|
|
|
|
# Build the binary to upload to the artifacts
|
|
|
|
- name: "build features: sqlite,mysql,postgresql"
|
|
|
|
if: ${{ matrix.channel == 'rust-toolchain' }}
|
2022-11-04 12:56:02 +01:00
|
|
|
run: |
|
|
|
|
cargo build --release --features sqlite,mysql,postgresql
|
2020-12-16 19:31:39 +01:00
|
|
|
# End Build the binary
|
|
|
|
|
|
|
|
|
|
|
|
# Upload artifact to Github Actions
|
2022-07-19 19:13:54 +02:00
|
|
|
- name: "Upload artifact"
|
2022-11-04 12:56:02 +01:00
|
|
|
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
|
2022-07-19 19:13:54 +02:00
|
|
|
if: ${{ matrix.channel == 'rust-toolchain' }}
|
2020-12-16 19:31:39 +01:00
|
|
|
with:
|
2022-07-19 19:13:54 +02:00
|
|
|
name: vaultwarden
|
2022-09-15 16:51:52 +02:00
|
|
|
path: target/release/vaultwarden
|
2020-12-16 19:31:39 +01:00
|
|
|
# End Upload artifact to Github Actions
|