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:
|
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-02-07 22:26:22 +01:00
|
|
|
- stable
|
2020-12-16 19:31:39 +01:00
|
|
|
target-triple:
|
|
|
|
- x86_64-unknown-linux-gnu
|
|
|
|
include:
|
|
|
|
- target-triple: x86_64-unknown-linux-gnu
|
|
|
|
host-triple: x86_64-unknown-linux-gnu
|
2022-03-20 18:51:24 +01:00
|
|
|
features: [sqlite,mysql,postgresql,enable_mimalloc] # Remember to update the `cargo test` to match the amount of features
|
2022-02-07 22:26:22 +01:00
|
|
|
channel: stable
|
2021-09-13 12:00:52 +02:00
|
|
|
os: ubuntu-20.04
|
2021-06-19 19:22:19 +02:00
|
|
|
ext: ""
|
2020-12-16 19:31:39 +01:00
|
|
|
|
|
|
|
name: Building ${{ matrix.channel }}-${{ matrix.target-triple }}
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
|
|
|
# Checkout the repo
|
|
|
|
- name: Checkout
|
2022-05-04 21:13:05 +02:00
|
|
|
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2
|
2020-12-16 19:31:39 +01:00
|
|
|
# End Checkout the repo
|
|
|
|
|
|
|
|
|
|
|
|
# Install musl-tools when needed
|
|
|
|
- name: Install musl tools
|
|
|
|
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends musl-dev musl-tools cmake
|
|
|
|
if: matrix.target-triple == 'x86_64-unknown-linux-musl'
|
|
|
|
# End Install musl-tools when needed
|
|
|
|
|
|
|
|
|
|
|
|
# Install dependencies
|
|
|
|
- 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 pkgconf
|
|
|
|
if: startsWith( matrix.os, 'ubuntu' )
|
|
|
|
# End Install dependencies
|
|
|
|
|
|
|
|
|
|
|
|
# Enable Rust Caching
|
2021-09-13 12:00:52 +02:00
|
|
|
- uses: Swatinem/rust-cache@842ef286fff290e445b90b4002cc9807c3669641 # v1.3.0
|
2020-12-16 19:31:39 +01:00
|
|
|
# End Enable Rust Caching
|
|
|
|
|
|
|
|
|
|
|
|
# Uses the rust-toolchain file to determine version
|
|
|
|
- name: 'Install ${{ matrix.channel }}-${{ matrix.host-triple }} for target: ${{ matrix.target-triple }}'
|
2021-09-13 12:00:52 +02:00
|
|
|
uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f # v1.0.6
|
2020-12-16 19:31:39 +01:00
|
|
|
with:
|
|
|
|
profile: minimal
|
|
|
|
target: ${{ matrix.target-triple }}
|
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
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
- name: "`cargo test --release --features ${{ join(matrix.features, ',') }} --target ${{ matrix.target-triple }}`"
|
2022-02-07 22:26:22 +01:00
|
|
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
|
2021-05-08 16:48:48 +02:00
|
|
|
with:
|
|
|
|
command: test
|
|
|
|
args: --release --features ${{ join(matrix.features, ',') }} --target ${{ matrix.target-triple }}
|
|
|
|
# Test single features
|
|
|
|
# 0: sqlite
|
|
|
|
- name: "`cargo test --release --features ${{ matrix.features[0] }} --target ${{ matrix.target-triple }}`"
|
2022-02-07 22:26:22 +01:00
|
|
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
|
2021-05-08 16:48:48 +02:00
|
|
|
with:
|
|
|
|
command: test
|
|
|
|
args: --release --features ${{ matrix.features[0] }} --target ${{ matrix.target-triple }}
|
|
|
|
if: ${{ matrix.features[0] != '' }}
|
|
|
|
# 1: mysql
|
|
|
|
- name: "`cargo test --release --features ${{ matrix.features[1] }} --target ${{ matrix.target-triple }}`"
|
2022-02-07 22:26:22 +01:00
|
|
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
|
2021-05-08 16:48:48 +02:00
|
|
|
with:
|
|
|
|
command: test
|
|
|
|
args: --release --features ${{ matrix.features[1] }} --target ${{ matrix.target-triple }}
|
|
|
|
if: ${{ matrix.features[1] != '' }}
|
|
|
|
# 2: postgresql
|
|
|
|
- name: "`cargo test --release --features ${{ matrix.features[2] }} --target ${{ matrix.target-triple }}`"
|
2022-02-07 22:26:22 +01:00
|
|
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
|
2020-12-16 19:31:39 +01:00
|
|
|
with:
|
|
|
|
command: test
|
2021-05-08 16:48:48 +02:00
|
|
|
args: --release --features ${{ matrix.features[2] }} --target ${{ matrix.target-triple }}
|
|
|
|
if: ${{ matrix.features[2] != '' }}
|
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)
|
|
|
|
- name: "`cargo clippy --release --features ${{ join(matrix.features, ',') }} --target ${{ matrix.target-triple }}`"
|
2022-02-07 22:26:22 +01:00
|
|
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
|
2021-03-27 16:10:00 +01:00
|
|
|
with:
|
|
|
|
command: clippy
|
2021-05-08 16:48:48 +02:00
|
|
|
args: --release --features ${{ join(matrix.features, ',') }} --target ${{ matrix.target-triple }} -- -D warnings
|
2021-03-27 16:10:00 +01:00
|
|
|
# End Run cargo clippy
|
|
|
|
|
|
|
|
|
2021-03-28 17:48:45 +02:00
|
|
|
# Run cargo fmt
|
|
|
|
- name: '`cargo fmt`'
|
2022-02-07 22:26:22 +01:00
|
|
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
|
2021-03-28 17:48:45 +02:00
|
|
|
with:
|
|
|
|
command: fmt
|
|
|
|
args: --all -- --check
|
|
|
|
# End Run cargo fmt
|
|
|
|
|
|
|
|
|
2020-12-16 19:31:39 +01:00
|
|
|
# Build the binary
|
2021-05-08 16:48:48 +02:00
|
|
|
- name: "`cargo build --release --features ${{ join(matrix.features, ',') }} --target ${{ matrix.target-triple }}`"
|
2022-02-07 22:26:22 +01:00
|
|
|
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
|
2020-12-16 19:31:39 +01:00
|
|
|
with:
|
|
|
|
command: build
|
2021-05-08 16:48:48 +02:00
|
|
|
args: --release --features ${{ join(matrix.features, ',') }} --target ${{ matrix.target-triple }}
|
2020-12-16 19:31:39 +01:00
|
|
|
# End Build the binary
|
|
|
|
|
|
|
|
|
|
|
|
# Upload artifact to Github Actions
|
|
|
|
- name: Upload artifact
|
2022-05-21 17:46:14 +02:00
|
|
|
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
|
2020-12-16 19:31:39 +01:00
|
|
|
with:
|
2021-04-27 23:18:32 +02:00
|
|
|
name: vaultwarden-${{ matrix.target-triple }}${{ matrix.ext }}
|
|
|
|
path: target/${{ matrix.target-triple }}/release/vaultwarden${{ matrix.ext }}
|
2020-12-16 19:31:39 +01:00
|
|
|
# End Upload artifact to Github Actions
|