2020-12-16 18:31:39 +00:00
|
|
|
name: Build
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2021-08-28 15:29:13 +00:00
|
|
|
paths:
|
|
|
|
- ".github/workflows/build.yml"
|
|
|
|
- "src/**"
|
|
|
|
- "migrations/**"
|
|
|
|
- "Cargo.*"
|
|
|
|
- "build.rs"
|
|
|
|
- "rust-toolchain"
|
2021-03-27 15:21:00 +00:00
|
|
|
pull_request:
|
2021-08-28 15:29:13 +00:00
|
|
|
paths:
|
|
|
|
- ".github/workflows/build.yml"
|
|
|
|
- "src/**"
|
|
|
|
- "migrations/**"
|
|
|
|
- "Cargo.*"
|
|
|
|
- "build.rs"
|
|
|
|
- "rust-toolchain"
|
2020-12-16 18:31:39 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
2022-07-19 17:13:54 +00:00
|
|
|
runs-on: ubuntu-20.04
|
2021-05-08 14:48:48 +00: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 18:31:39 +00:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
channel:
|
2022-07-19 17:13:54 +00:00
|
|
|
- "rust-toolchain" # The version defined in rust-toolchain
|
2022-09-15 14:51:52 +00:00
|
|
|
- "msrv" # The supported MSRV
|
|
|
|
include:
|
|
|
|
- channel: "msrv"
|
|
|
|
version: "1.60.0"
|
2022-07-19 17:13:54 +00:00
|
|
|
|
|
|
|
name: Build and Test ${{ matrix.channel }}
|
|
|
|
|
2020-12-16 18:31:39 +00:00
|
|
|
steps:
|
|
|
|
# Checkout the repo
|
2022-07-19 17:13:54 +00:00
|
|
|
- name: "Checkout"
|
2022-10-21 11:21:57 +00:00
|
|
|
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
|
2020-12-16 18:31:39 +00:00
|
|
|
# End Checkout the repo
|
|
|
|
|
|
|
|
# Install dependencies
|
2022-07-19 17:13:54 +00: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 18:31:39 +00:00
|
|
|
# End Install dependencies
|
|
|
|
|
|
|
|
|
|
|
|
# Uses the rust-toolchain file to determine version
|
2022-07-19 17:13:54 +00:00
|
|
|
- name: "Install rust-toolchain version"
|
2021-09-13 10:00:52 +00:00
|
|
|
uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f # v1.0.6
|
2022-07-19 17:13:54 +00:00
|
|
|
if: ${{ matrix.channel == 'rust-toolchain' }}
|
2020-12-16 18:31:39 +00:00
|
|
|
with:
|
|
|
|
profile: minimal
|
2021-03-28 15:48:45 +00:00
|
|
|
components: clippy, rustfmt
|
2020-12-16 18:31:39 +00:00
|
|
|
# End Uses the rust-toolchain file to determine version
|
|
|
|
|
|
|
|
|
2022-07-19 17:13:54 +00:00
|
|
|
# Install the MSRV channel to be used
|
|
|
|
- name: "Install MSRV version"
|
|
|
|
uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f # v1.0.6
|
|
|
|
if: ${{ matrix.channel != 'rust-toolchain' }}
|
|
|
|
with:
|
|
|
|
profile: minimal
|
|
|
|
override: true
|
2022-09-15 14:51:52 +00:00
|
|
|
toolchain: ${{ matrix.version }}
|
2022-07-19 17:13:54 +00:00
|
|
|
# End Install the MSRV channel to be used
|
|
|
|
|
|
|
|
|
|
|
|
# Enable Rust Caching
|
2022-10-21 11:21:57 +00:00
|
|
|
- uses: Swatinem/rust-cache@22c9328bcba27aa81a32b1bef27c7e3c78052531 # v2.0.1
|
2022-07-19 17:13:54 +00:00
|
|
|
# End Enable Rust Caching
|
|
|
|
|
|
|
|
|
|
|
|
# Show environment
|
|
|
|
- name: "Show environment"
|
|
|
|
run: |
|
|
|
|
rustc -vV
|
|
|
|
cargo -vV
|
|
|
|
# End Show environment
|
|
|
|
|
|
|
|
|
2021-03-27 15:10:00 +00:00
|
|
|
# Run cargo tests (In release mode to speed up future builds)
|
2021-05-08 14:48:48 +00:00
|
|
|
# First test all features together, afterwards test them separately.
|
2022-07-19 17:13:54 +00:00
|
|
|
- name: "test features: sqlite,mysql,postgresql,enable_mimalloc"
|
|
|
|
id: test_sqlite_mysql_postgresql_mimalloc
|
2022-02-07 21:26:22 +00:00
|
|
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
|
2022-07-19 17:13:54 +00:00
|
|
|
if: $${{ always() }}
|
2021-05-08 14:48:48 +00:00
|
|
|
with:
|
|
|
|
command: test
|
2022-07-19 17:13:54 +00:00
|
|
|
args: --release --features sqlite,mysql,postgresql,enable_mimalloc
|
|
|
|
|
|
|
|
- name: "test features: sqlite,mysql,postgresql"
|
|
|
|
id: test_sqlite_mysql_postgresql
|
2022-02-07 21:26:22 +00:00
|
|
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
|
2022-07-19 17:13:54 +00:00
|
|
|
if: $${{ always() }}
|
2021-05-08 14:48:48 +00:00
|
|
|
with:
|
|
|
|
command: test
|
2022-07-19 17:13:54 +00:00
|
|
|
args: --release --features sqlite,mysql,postgresql
|
|
|
|
|
|
|
|
- name: "test features: sqlite"
|
|
|
|
id: test_sqlite
|
|
|
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
|
|
|
|
if: $${{ always() }}
|
|
|
|
with:
|
|
|
|
command: test
|
|
|
|
args: --release --features sqlite
|
|
|
|
|
|
|
|
- name: "test features: mysql"
|
|
|
|
id: test_mysql
|
2022-02-07 21:26:22 +00:00
|
|
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
|
2022-07-19 17:13:54 +00:00
|
|
|
if: $${{ always() }}
|
2021-05-08 14:48:48 +00:00
|
|
|
with:
|
|
|
|
command: test
|
2022-07-19 17:13:54 +00:00
|
|
|
args: --release --features mysql
|
|
|
|
|
|
|
|
- name: "test features: postgresql"
|
|
|
|
id: test_postgresql
|
2022-02-07 21:26:22 +00:00
|
|
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
|
2022-07-19 17:13:54 +00:00
|
|
|
if: $${{ always() }}
|
2020-12-16 18:31:39 +00:00
|
|
|
with:
|
|
|
|
command: test
|
2022-07-19 17:13:54 +00:00
|
|
|
args: --release --features postgresql
|
2020-12-16 18:31:39 +00:00
|
|
|
# End Run cargo tests
|
|
|
|
|
|
|
|
|
2021-05-08 14:48:48 +00:00
|
|
|
# Run cargo clippy, and fail on warnings (In release mode to speed up future builds)
|
2022-07-19 17:13:54 +00:00
|
|
|
- name: "clippy features: sqlite,mysql,postgresql,enable_mimalloc"
|
|
|
|
id: clippy
|
2022-02-07 21:26:22 +00:00
|
|
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
|
2022-07-19 17:13:54 +00:00
|
|
|
if: ${{ always() && matrix.channel == 'rust-toolchain' }}
|
2021-03-27 15:10:00 +00:00
|
|
|
with:
|
|
|
|
command: clippy
|
2022-07-19 17:13:54 +00:00
|
|
|
args: --release --features sqlite,mysql,postgresql,enable_mimalloc -- -D warnings
|
2021-03-27 15:10:00 +00:00
|
|
|
# End Run cargo clippy
|
|
|
|
|
|
|
|
|
2022-07-19 17:13:54 +00:00
|
|
|
# Run cargo fmt (Only run on rust-toolchain defined version)
|
|
|
|
- name: "check formatting"
|
|
|
|
id: formatting
|
2022-02-07 21:26:22 +00:00
|
|
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
|
2022-07-19 17:13:54 +00:00
|
|
|
if: ${{ always() && matrix.channel == 'rust-toolchain' }}
|
2021-03-28 15:48:45 +00:00
|
|
|
with:
|
|
|
|
command: fmt
|
|
|
|
args: --all -- --check
|
|
|
|
# End Run cargo fmt
|
|
|
|
|
|
|
|
|
2022-07-19 17:13:54 +00: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"
|
2022-02-07 21:26:22 +00:00
|
|
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
|
2022-07-19 17:13:54 +00:00
|
|
|
if: ${{ matrix.channel == 'rust-toolchain' }}
|
2020-12-16 18:31:39 +00:00
|
|
|
with:
|
|
|
|
command: build
|
2022-07-19 17:13:54 +00:00
|
|
|
args: --release --features sqlite,mysql,postgresql
|
2020-12-16 18:31:39 +00:00
|
|
|
# End Build the binary
|
|
|
|
|
|
|
|
|
|
|
|
# Upload artifact to Github Actions
|
2022-07-19 17:13:54 +00:00
|
|
|
- name: "Upload artifact"
|
2022-05-21 15:46:14 +00:00
|
|
|
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
|
2022-07-19 17:13:54 +00:00
|
|
|
if: ${{ matrix.channel == 'rust-toolchain' }}
|
2020-12-16 18:31:39 +00:00
|
|
|
with:
|
2022-07-19 17:13:54 +00:00
|
|
|
name: vaultwarden
|
2022-09-15 14:51:52 +00:00
|
|
|
path: target/release/vaultwarden
|
2020-12-16 18:31:39 +00:00
|
|
|
# End Upload artifact to Github Actions
|