Skip to content

Commit

Permalink
ci: more readable jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
jondot committed Oct 22, 2024
1 parent 9014f21 commit ca04bab
Show file tree
Hide file tree
Showing 9 changed files with 988 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/demo-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: "[demo:ci]"

on:
push:
branches:
- master
pull_request:

env:
RUST_TOOLCHAIN: stable
TOOLCHAIN_PROFILE: minimal

jobs:
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
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- run: cargo fmt --all -- --check
working-directory: ./examples/demo
- name: Run cargo clippy
run: cargo clippy -- -W clippy::nursery -W clippy::pedantic -W rust-2018-idioms -W rust-2021-compatibility
working-directory: ./examples/demo

test:
needs: [rustfmt, clippy]
runs-on: ubuntu-latest

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 test --all-features --all
working-directory: ./examples/demo
env:
LOCO_CI_MODE: 1
REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}}
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test
105 changes: 105 additions & 0 deletions .github/workflows/loco-cli-e2e-master.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: "[loco-cli:e2e(master)]"

on:
push:
branches:
- master
pull_request:

jobs:
# TODO: re-enable after 0.8 to check cmd spawning fix
saas-win32:
runs-on: windows-latest

permissions:
contents: read

steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
components: rustfmt
- name: Install seaorm cli
run: cargo install sea-orm-cli
- run: |
cargo install --path .
working-directory: ./loco-cli
- run: |
loco new -n saas -t saas --db sqlite --bg async --assets serverside
env:
ALLOW_IN_GIT_REPO: true
- run: |
cargo build
working-directory: ./saas
- run: |
cargo loco routes
working-directory: ./saas
- run: |
cargo loco db migrate
working-directory: ./saas
- run: |
cargo loco generate scaffold movie title:string --htmx
working-directory: ./saas
- run: |
cargo loco db migrate
working-directory: ./saas
saas:
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
- run: |
cargo install loco-cli
ALLOW_IN_GIT_REPO=true LOCO_APP_NAME=saas LOCO_TEMPLATE=saas loco new --db postgres --bg queue --assets serverside
- run: |
cargo build
working-directory: ./saas
rest-api:
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
- run: |
cargo install loco-cli
ALLOW_IN_GIT_REPO=true LOCO_APP_NAME=restapi LOCO_TEMPLATE=rest-api loco new --db postgres --bg queue
- run: |
cargo build
working-directory: ./restapi
lightweight-service:
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
override: true
- run: |
cargo install loco-cli
ALLOW_IN_GIT_REPO=true LOCO_APP_NAME=lightweight LOCO_TEMPLATE=lightweight-service loco new
- run: |
cargo build
working-directory: ./lightweight
63 changes: 63 additions & 0 deletions .github/workflows/loco-cli-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: "[loco-cli:e2e]"

on:
schedule:
- cron: 0 * * * * # every hour

jobs:
saas:
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
- run: |
cargo install loco-cli
ALLOW_IN_GIT_REPO=true loco new --template saas --name saas --db sqlite --bg async --assets serverside
- run: |
cargo build
working-directory: ./saas
rest-api:
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
- run: |
cargo install loco-cli
ALLOW_IN_GIT_REPO=true loco new --template rest-api --name restapi --db sqlite --bg async
- run: |
cargo build
working-directory: ./restapi
lightweight-service:
runs-on: ubuntu-latest

permissions:
contents: read

steps:
- name: Checkout the code
uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
- run: |
cargo install loco-cli
ALLOW_IN_GIT_REPO=true loco new --template lightweight-service --name lightweight --db sqlite --bg async
- run: |
cargo build
working-directory: ./lightweight
67 changes: 67 additions & 0 deletions .github/workflows/loco-gen-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: "[loco-gen:ci]"

on:
push:
branches:
- master
pull_request:

env:
RUST_TOOLCHAIN: stable
TOOLCHAIN_PROFILE: minimal

defaults:
run:
working-directory: ./loco-gen

jobs:
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
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features -- -D warnings -W clippy::pedantic -W clippy::nursery -W rust-2018-idioms

test:
needs: [rustfmt, 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

- run: |
cargo install --path ../loco-cli
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
Loading

0 comments on commit ca04bab

Please sign in to comment.