allow to set random range (#45) #118
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
# Credits https://github.com/seanmonstar/reqwest/blob/master/.github/workflows/ci.yml | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
env: | |
REQWEST_TEST_BODY_FULL: 1 | |
RUST_BACKTRACE: 1 | |
jobs: | |
style: | |
name: Check Style | |
runs-on: ubuntu-latest | |
env: | |
SQLX_OFFLINE: true | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt | |
# </setup> | |
- run: cargo fmt -- --check | |
- run: cargo check --all-targets | |
- run: cargo clippy -- --deny warnings | |
tests: | |
name: Tests ${{ matrix.name }} | |
needs: [style] | |
runs-on: ${{ matrix.os || 'ubuntu-latest' }} | |
timeout-minutes: 30 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- name: linux / stable | |
- name: linux / beta | |
rust: beta | |
# - name: macOS / stable | |
# os: macOS-latest | |
# TODO: Support windows | |
# - name: windows / stable-x86_64-gnu | |
# os: windows-latest | |
# rust: stable-x86_64-pc-windows-gnu | |
# target: x86_64-pc-windows-gnu | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust || 'stable' }} | |
targets: ${{ matrix.target }} | |
- name: Setup docker (missing on MacOS) | |
if: runner.os == 'macos' | |
run: | | |
brew install docker | |
brew install docker-buildx | |
- name: Test docker | |
run: docker run hello-world | |
- name: Install sqlx-cli | |
run: cargo install --version='~0.7' sqlx-cli --no-default-features --features rustls,mysql | |
- name: Migrate database | |
# linux: mysql-client, macos: brew install mysql | |
run: | | |
sudo apt-get install mysql-client -y | |
./scripts/init_db.sh | |
# </setup> | |
- name: Check | |
run: cargo check | |
# To re-sync run `cargo sqlx prepare` ref: https://github.com/launchbadge/sqlx/blob/main/sqlx-cli/README.md#enable-building-in-offline-mode-with-query | |
- name: Ensure sqlx-offline data is synced | |
run: cargo sqlx prepare --check --workspace | |
- name: Test | |
run: cargo test -- --test-threads=1 --nocapture | |
coverage: | |
name: Coverage | |
runs-on: ubuntu-latest | |
needs: [style] | |
timeout-minutes: 30 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: nightly | |
# </setup> | |
- name: Run tests | |
# TODO: consider including coverage for integration tests | |
run: cargo test --lib | |
env: | |
CARGO_INCREMENTAL: '0' | |
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' | |
RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' | |
- name: rust-grcov | |
uses: actions-rs/[email protected] | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v3 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
with: | |
verbose: true | |
fail_ci_if_error: true | |
docs: | |
name: Docs | |
runs-on: ubuntu-latest | |
env: | |
SQLX_OFFLINE: true | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
# </setup> | |
- name: Check documentation | |
run: cargo doc --no-deps --document-private-items --all-features | |
env: | |
RUSTDOCFLAGS: -D warnings | |
- name: Check README | |
run: ./scripts/check_synced_readme.py | |
docker-build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: docker/setup-buildx-action@v2 | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
load: true | |
tags: blobshare:dev | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Test image | |
run: docker run --rm blobshare:dev --help |