forked from jmug/stoatchat
feat(autumn): add /original redirect for files fix(autumn): block non-images for non-attachment tags fix(ci): use correct port for Rust test
93 lines
2.4 KiB
YAML
93 lines
2.4 KiB
YAML
name: Rust build, test, and generate specification
|
|
|
|
on:
|
|
push:
|
|
paths-ignore:
|
|
- ".github/**"
|
|
- "!.github/workflows/rust.yaml"
|
|
- ".vscode/**"
|
|
- "doc/**"
|
|
- ".gitignore"
|
|
- "LICENSE"
|
|
- "README"
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
check:
|
|
name: Rust project
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Install latest stable
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
override: true
|
|
components: rustfmt, clippy
|
|
- name: Install cargo-nextest
|
|
uses: baptiste0928/cargo-install@v1
|
|
with:
|
|
crate: cargo-nextest
|
|
locked: true
|
|
|
|
- name: Run cargo build
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
|
|
- name: Run services in background
|
|
run: |
|
|
docker compose -f compose.yml up -d
|
|
|
|
- name: Run cargo test
|
|
env:
|
|
TEST_DB: REFERENCE
|
|
run: |
|
|
cargo nextest run
|
|
|
|
- name: Run cargo test (with MongoDB)
|
|
env:
|
|
TEST_DB: MONGODB
|
|
MONGODB: mongodb://localhost
|
|
run: |
|
|
cargo nextest run
|
|
|
|
- name: Start API in background
|
|
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
|
env:
|
|
TEST_DB: REFERENCE
|
|
run: |
|
|
cargo build --bin revolt-delta && (cargo run --bin revolt-delta &)
|
|
|
|
- name: Wait for API to go up
|
|
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
|
uses: nev7n/wait_for_response@v1
|
|
with:
|
|
url: "http://localhost:14702/"
|
|
|
|
- name: Checkout API repository
|
|
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: revoltchat/api
|
|
path: api
|
|
token: ${{ secrets.PAT }}
|
|
|
|
- name: Download OpenAPI specification
|
|
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
|
run: curl http://localhost:14702/openapi.json -o api/OpenAPI.json
|
|
|
|
- name: Commit changes
|
|
if: github.event_name != 'pull_request' && github.ref_name == 'main'
|
|
uses: EndBug/add-and-commit@v4
|
|
with:
|
|
cwd: "api"
|
|
add: "*.json"
|
|
author_name: Revolt CI
|
|
author_email: revolt-ci@users.noreply.github.com
|
|
message: "chore: generate OpenAPI specification"
|