Skip to content
Open

Rust #1010

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/rust-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Rust CI

on:
push:
branches:
- master
merge_group:
pull_request:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
rust-lint:
runs-on: ubuntu-24.04
env:
TARGET: x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v6
with:
submodules: recursive

- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ env.TARGET }}

- name: Check format
run: cargo fmt --all -- --check

- name: Run clippy
run: cargo clippy --workspace --all-targets --locked

rust-test:
runs-on: ubuntu-24.04
env:
TARGET: x86_64-unknown-linux-gnu
steps:
- run: git clone https://github.com/bangumi/dev-env $HOME/dev-env --branch=gh-pages
- run: cd ~/dev-env && docker compose up -d

- uses: actions/checkout@v6
with:
submodules: recursive

- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ env.TARGET }}

- name: Install cargo-nextest
uses: taiki-e/install-action@nextest

- run: bash $HOME/dev-env/wait_mysql_ready.sh

- name: Run tests
run: cargo nextest run --workspace --locked
env:
RUST_MYSQL_DSN: mysql://user:password@127.0.0.1:3306/bangumi
MYSQL_DSN: mysql://user:password@127.0.0.1:3306/bangumi

docker:
runs-on: ubuntu-24.04
needs: [rust-lint, rust-test]
env:
TARGET: x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v6
with:
submodules: recursive

- name: Set up Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ env.TARGET }}

- name: Build release binary
run: cargo build --release --locked --target $TARGET -p app

- name: Build rust docker image
run: docker build --build-arg TARGET=$TARGET -t app-rust -f etc/Dockerfile.rust .

- name: Smoke run
run: docker run --rm app-rust --help
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ node_modules/
pnpm-lock.yaml
.task/

/target/

config.yaml
config.toml
3 changes: 3 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
max_width = 88
tab_spaces = 2
newline_style = 'Unix'
Loading