fix: introduce secondary binary for compile-and-run on Windows #199
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: starters/rest-api | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- starters/rest-api/** | |
pull_request: | |
paths: | |
- starters/rest-api/** | |
env: | |
RUST_TOOLCHAIN: stable | |
TOOLCHAIN_PROFILE: minimal | |
jobs: | |
rustfmt: | |
name: Check Style | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ env.RUST_TOOLCHAIN }} | |
components: rustfmt | |
- run: cargo fmt --all -- --check | |
working-directory: ./starters/rest-api | |
clippy: | |
name: Run Clippy | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ env.RUST_TOOLCHAIN }} | |
- name: Setup Rust cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Run cargo clippy | |
run: cargo clippy -- -W clippy::nursery -W clippy::pedantic -W rust-2018-idioms -W rust-2021-compatibility | |
working-directory: ./starters/rest-api | |
test: | |
name: Run Tests | |
needs: [rustfmt, clippy] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
db: | |
- "postgres://postgres:postgres@localhost:5432/postgres_test" | |
- "sqlite://loco_app.sqlite?mode=rwc" | |
permissions: | |
contents: read | |
services: | |
redis: | |
image: redis | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- "6379:6379" | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_DB: postgres_test | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
ports: | |
- "5432:5432" | |
# Set health checks to wait until postgres has started | |
options: --health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: ${{ env.RUST_TOOLCHAIN }} | |
- name: Setup Rust cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Install seaorm cli | |
run: cargo install sea-orm-cli | |
- name: Run cargo test | |
run: cargo loco db reset && cargo loco db entities && cargo test --all-features --all | |
working-directory: ./starters/rest-api | |
env: | |
REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}} | |
DATABASE_URL: ${{matrix.db}} | |
# generate_template: | |
# name: Generate Template | |
# needs: [test] | |
# runs-on: ubuntu-latest | |
# permissions: | |
# contents: read | |
# steps: | |
# - name: Checkout the code | |
# uses: actions/checkout@v4 | |
# - uses: dtolnay/rust-toolchain@stable | |
# with: | |
# toolchain: ${{ env.RUST_TOOLCHAIN }} | |
# - name: Setup Rust cache | |
# uses: Swatinem/rust-cache@v2 | |
# - name: Inject slug/short variables | |
# uses: rlespinasse/[email protected] | |
# - name: Generate template | |
# run: | | |
# cargo build --release --features github_ci | |
# RUST_LOG=debug LOCO_CURRENT_REPOSITORY=${{ github.event.pull_request.head.repo.html_url }} LOCO_CI_MODE=true LOCO_APP_NAME=stateless_starter LOCO_TEMPLATE=stateless LOCO_BRANCH=${{ env.GITHUB_HEAD_REF_SLUG }} ./target/release/loco new | |
# cd stateless_starter | |
# echo "Building generate template..." | |
# cargo build --release | |
# echo "Run cargo test on generated template..." | |
# cargo test | |
# working-directory: ./loco-cli |