Skip to content

v1.0.0-alpha

v1.0.0-alpha #323

Workflow file for this run

name: Rust
on:
push:
branches: [master]
pull_request:
branches: [master, dev]
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [stable]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
target/
key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run build
run: cargo build
test:
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: laguna_dev_db
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
needs: build
strategy:
fail-fast: false
# NOTE: Only use Linux for testing
# Server will likely be deployed on linux
# GH Actions doesn't support containers on Windows
# MacOS doesn't have docker installed by default
matrix:
os: [ubuntu-latest]
rust: [stable]
runs-on: ${{ matrix.os }}
env:
SQLX_OFFLINE: true
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:5432/laguna_dev_db
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
target/
key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run tests
run: RUST_LOG=warn cargo test --all --features testx -- --nocapture
coverage:
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: laguna_dev_db
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
needs: test
# Don't coverage dependabot
if: github.actor != 'dependabot[bot]'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
rust: [stable]
env:
SQLX_OFFLINE: true
DATABASE_URL: postgres://postgres:postgres@postgres:5432/laguna_dev_db
runs-on: ${{ matrix.os }}
# TODO: Maybe use https://github.com/taiki-e/install-action so to avoid recompile of tarpaulin
container:
image: xd009642/tarpaulin
options: --security-opt seccomp=unconfined
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
target/
key: ${{ matrix.os }}-${{ matrix.rust }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Generate coverage data
run: |
RUST_LOG=warn cargo tarpaulin --workspace --timeout 120 --out xml --features testx --skip-clean --target-dir=target/coverage
- name: Upload to codecov.io
uses: codecov/codecov-action@v3 # Make sure to use v3 because it allows tokenless upload
deploy_docs:
needs: [build, test]
permissions:
contents: write
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
- name: Build Docs
run: cargo doc --no-deps --workspace --features dox
- name: Doc Index Page Redirection
run: echo '<meta http-equiv="refresh" content="0; url=laguna_backend/index.html">' > target/doc/index.html
- name: Deploy Docs
uses: peaceiris/actions-gh-pages@v3
with:
user_name: "github-actions-laguna[bot]"
user_email: "github-actions-laguna[bot]@users.noreply.github.com"
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: documentation
publish_dir: target/doc
force_orphan: true