From 65eef13c3b9d1dec7ff0b55de362d33f97df998c Mon Sep 17 00:00:00 2001 From: Trangar Date: Tue, 18 Oct 2022 14:03:34 +0200 Subject: [PATCH] Added CI (#5) * Added CI * Install sqlx and setup the sqlite database * Added `rustls` to the sqlx installer * Switched to `cargo-install` so the binaries can be cached between builds * Updated dependabot to also update the github-actions * Fixed wrong cargo package being installed --- .github/dependabot.yml | 6 +++- .github/workflows/lints.yml | 63 +++++++++++++++++++++++++++++++++++++ .github/workflows/rust.yml | 40 +++++++++++++++++++++++ 3 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/lints.yml create mode 100644 .github/workflows/rust.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5cde165..0dd88db 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,4 +4,8 @@ updates: directory: "/" schedule: interval: daily - open-pull-requests-limit: 10 + +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/lints.yml b/.github/workflows/lints.yml new file mode 100644 index 0000000..ad3a9d8 --- /dev/null +++ b/.github/workflows/lints.yml @@ -0,0 +1,63 @@ +on: [push] + +name: Lint & clippy + +jobs: + lints: + name: Lints + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: rustfmt + + - name: Run cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + clippy: + name: Clippy + runs-on: ubuntu-latest + strategy: + matrix: + runtime: [async-std] + front: [terminal] + + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: clippy + + - name: Install sqlx + uses: baptiste0928/cargo-install@v1 + with: + crate: sqlx-cli + version: 0.6 + features: sqlite,rustls + args: --no-default-features + + - name: Setup database + run: | + echo "DATABASE_URL=sqlite://database.db" >> .env + sqlx database setup --source data/sqlite/migrations + + - name: Run cargo clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: --features runtime-${{ matrix.runtime }},data-sqlite,front-${{ matrix.front }} -- -D warnings diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..24f5a48 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,40 @@ +on: [push] + +name: build + +jobs: + test: + name: Test + runs-on: ubuntu-latest + + strategy: + matrix: + runtime: [async-std] + front: [terminal] + + steps: + - uses: actions/checkout@v2 + - name: Install latest stable + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Install sqlx + uses: baptiste0928/cargo-install@v1 + with: + crate: sqlx-cli + version: 0.6 + features: sqlite,rustls + args: --no-default-features + + - name: Setup database + run: | + echo "DATABASE_URL=sqlite://database.db" >> .env + sqlx database setup --source data/sqlite/migrations + + - name: Test + uses: actions-rs/cargo@v1 + with: + command: test + args: --features runtime-${{ matrix.runtime }},data-sqlite,front-${{ matrix.front }}