Skip to content

wip explaining config crate #751

wip explaining config crate

wip explaining config crate #751

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request: {}
schedule:
- cron: '0 3 * * *' # daily, at 3am
jobs:
rustfmt:
name: "Rust Format"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
- name: fmt
run: cargo fmt --all --check
clippy:
name: "Clippy"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
- name: clippy
env:
RUSTFLAGS: "-D missing-docs"
run: cargo clippy --all-targets -- -D warnings
test:
name: "Test"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: test
run: cargo test
generate-full:
name: Generate full example app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: generate
run: cargo run -- --full my-app
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
include-hidden-files: true
name: my-app-full
path: my-app
if-no-files-found: error
retention-days: 1
test-generated-full:
name: "Test generated full example app"
runs-on: ubuntu-latest
needs: generate-full
services:
postgres:
image: postgres
env:
POSTGRES_DB: my_app
POSTGRES_USER: my_app
POSTGRES_PASSWORD: my_app
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
postgres_test:
image: postgres
env:
POSTGRES_DB: my_app_test
POSTGRES_USER: my_app_test
POSTGRES_PASSWORD: my_app_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5433:5432
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: my-app-full
path: my-app
- name: migrate
run: |
cd my-app
cargo db reset
cargo db reset -e test
- name: test
run: |
cd my-app
cargo test --all
fmt-generated-full:
name: "Validate format of generated full example app"
runs-on: ubuntu-latest
needs: generate-full
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: my-app-full
path: my-app
- name: fmt-generated
run: |
cd my-app
cargo fmt --all -- --check
clippy-generated-full:
name: "Run Clippy on generated full example app"
runs-on: ubuntu-latest
needs: generate-full
services:
postgres:
image: postgres
env:
POSTGRES_DB: my_app
POSTGRES_USER: my_app
POSTGRES_PASSWORD: my_app
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: my-app-full
path: my-app
- name: migrate
run: |
cd my-app
cargo db reset
- name: clippy-generated
env:
RUSTFLAGS: "-D missing-docs"
run: |
cd my-app
cargo clippy --all-targets -- -D warnings
doc-generated-full:
name: "Build docs for generated full example app"
runs-on: ubuntu-latest
needs: generate-full
services:
postgres:
image: postgres
env:
POSTGRES_DB: my_app
POSTGRES_USER: my_app
POSTGRES_PASSWORD: my_app
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: my-app-full
path: my-app
- name: migrate
run: |
cd my-app
cargo db reset
- name: doc-generated
run: |
cd my-app
cargo doc --workspace --all-features --no-deps
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
include-hidden-files: true
name: docs-full
path: my-app/target/doc
if-no-files-found: error
retention-days: 3
run-generated-full:
name: "Run generated full example app"
runs-on: ubuntu-latest
needs: generate-full
services:
postgres:
image: postgres
env:
POSTGRES_DB: my_app
POSTGRES_USER: my_app
POSTGRES_PASSWORD: my_app
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: my-app-full
path: my-app
- name: migrate
run: |
cd my-app
cargo db reset
cargo db seed
- name: run-generated
run: |
cd my-app
cargo run & (timeout 120 sh -c 'until nc -z $0 $1; do sleep 1; done' localhost 3000)
curl -X POST localhost:3000/tasks -H 'Authorization: 9974812642a36dbee625fa06b2463dbff832e17dcce3836dbb' -H 'Content-Type: application/json' -d '{"description": "do something"}'
curl -X PUT localhost:3000/tasks -H 'Authorization: 9974812642a36dbee625fa06b2463dbff832e17dcce3836dbb' -H 'Content-Type: application/json' -d '[{"description": "do something else"}, {"description": "…and do another thing"}]'
curl localhost:3000/tasks
generate-default:
name: Generate default example app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: generate
run: cargo run my-app
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
include-hidden-files: true
name: my-app-default
path: my-app
if-no-files-found: error
retention-days: 1
test-generated-default:
name: "Test generated default example app"
runs-on: ubuntu-latest
needs: generate-default
services:
postgres:
image: postgres
env:
POSTGRES_DB: my_app
POSTGRES_USER: my_app
POSTGRES_PASSWORD: my_app
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
postgres_test:
image: postgres
env:
POSTGRES_DB: my_app_test
POSTGRES_USER: my_app_test
POSTGRES_PASSWORD: my_app_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5433:5432
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: my-app-default
path: my-app
- name: test
run: |
cd my-app
cargo test --all
fmt-generated-default:
name: "Validate format of generated default example app"
runs-on: ubuntu-latest
needs: generate-default
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: my-app-default
path: my-app
- name: fmt-generated
run: |
cd my-app
cargo fmt --all -- --check
doc-generated-default:
name: "Build docs for generated default example app"
runs-on: ubuntu-latest
needs: generate-default
services:
postgres:
image: postgres
env:
POSTGRES_DB: my_app
POSTGRES_USER: my_app
POSTGRES_PASSWORD: my_app
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: my-app-default
path: my-app
- name: migrate
run: |
cd my-app
cargo db reset
- name: doc-generated
run: |
cd my-app
cargo doc --workspace --all-features --no-deps
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
include-hidden-files: true
name: docs-default
path: my-app/target/doc
if-no-files-found: error
retention-days: 3
run-generators-with-generated-default:
name: "Run generators on generated default example app"
runs-on: ubuntu-latest
needs: generate-default
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: my-app-default
path: my-app
- name: generate-migration
run: |
cd my-app
cargo generate migration CreatePeopleTable
- name: generate-entity
run: |
cd my-app
cargo generate entity Person
- name: generate-entity-test-helper
run: |
cd my-app
cargo generate entity-test-helper Person
- name: generate-middleware
run: |
cd my-app
cargo generate middleware rate-limit
- name: generate-controller
run: |
cd my-app
cargo generate controller message
- name: generate-crud-controller
run: |
cd my-app
cargo generate crud-controller people
# check the generators didn't produce mal-formatted code (ignoring order of module declarations
# since we don't control that and it depends on the exact names we use for the generated items)
- name: fmt-generated
run: |
cd my-app
cargo fmt --all -- --config reorder_modules=false --check
clippy-generated-default:
name: "Run Clippy on generated default example app"
runs-on: ubuntu-latest
needs: generate-default
services:
postgres:
image: postgres
env:
POSTGRES_DB: my_app
POSTGRES_USER: my_app
POSTGRES_PASSWORD: my_app
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: my-app-default
path: my-app
- name: clippy-generated
env:
RUSTFLAGS: "-D missing-docs"
run: |
cd my-app
cargo clippy --all-targets -- -D warnings
run-generated-default:
name: "Run generated default example app"
runs-on: ubuntu-latest
needs: generate-default
services:
postgres:
image: postgres
env:
POSTGRES_DB: my_app
POSTGRES_USER: my_app
POSTGRES_PASSWORD: my_app
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: my-app-default
path: my-app
- name: run-generated
run: |
cd my-app
cargo run & (timeout 120 sh -c 'until nc -z $0 $1; do sleep 1; done' localhost 3000)
generate-minimal:
name: Generate minimal example app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: generate
run: cargo run -- --minimal my-app
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
include-hidden-files: true
name: my-app-minimal
path: my-app
if-no-files-found: error
retention-days: 1
test-generated-minimal:
name: "Test generated minimal example app"
runs-on: ubuntu-latest
needs: generate-minimal
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: my-app-minimal
path: my-app
- name: test
run: |
cd my-app
cargo test --all
fmt-generated-minimal:
name: "Validate format of generated minimal example app"
runs-on: ubuntu-latest
needs: generate-minimal
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: my-app-minimal
path: my-app
- name: fmt-generated
run: |
cd my-app
cargo fmt --all -- --check
doc-generated-minimal:
name: "Build docs for generated minimal example app"
runs-on: ubuntu-latest
needs: generate-minimal
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: my-app-minimal
path: my-app
- name: doc-generated
run: |
cd my-app
cargo doc --workspace --no-deps
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4
with:
include-hidden-files: true
name: docs-minimal
path: my-app/target/doc
if-no-files-found: error
retention-days: 3
clippy-generated-minimal:
name: "Run Clippy on generated minimal example app"
runs-on: ubuntu-latest
needs: generate-minimal
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: my-app-minimal
path: my-app
- name: clippy-generated
env:
RUSTFLAGS: "-D missing-docs"
run: |
cd my-app
cargo clippy --all-targets -- -D warnings
run-generated-minimal:
name: "Run generated minimal example app"
runs-on: ubuntu-latest
needs: generate-minimal
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: my-app-minimal
path: my-app
- name: run-generated
run: |
cd my-app
cargo run & (timeout 120 sh -c 'until nc -z $0 $1; do sleep 1; done' localhost 3000)
curl localhost:3000/greet