forked from jmug/stoatchat
75 lines
1.9 KiB
YAML
75 lines
1.9 KiB
YAML
name: Rust build, test, and generate specification
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
pull_request:
|
|
branches: [master]
|
|
|
|
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: Run cargo build
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: build
|
|
|
|
- name: Run cargo test
|
|
uses: actions-rs/cargo@v1
|
|
with:
|
|
command: test
|
|
|
|
- name: Copy .env.example
|
|
if: github.event_name != 'pull_request'
|
|
run: |
|
|
cp .env.example .env
|
|
|
|
- name: Run services in background
|
|
if: github.event_name != 'pull_request'
|
|
run: |
|
|
docker-compose -f docker-compose.db.yml up -d
|
|
|
|
- name: Start API in background
|
|
if: github.event_name != 'pull_request'
|
|
run: |
|
|
cargo run --bin revolt-delta &
|
|
|
|
- name: Wait for API to go up
|
|
if: github.event_name != 'pull_request'
|
|
uses: nev7n/wait_for_response@v1
|
|
with:
|
|
url: "http://localhost:8000/"
|
|
|
|
- name: Checkout API repository
|
|
if: github.event_name != 'pull_request'
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: revoltchat/api
|
|
path: api
|
|
token: ${{ secrets.PAT }}
|
|
|
|
- name: Download OpenAPI specification
|
|
if: github.event_name != 'pull_request'
|
|
run: curl http://localhost:8000/openapi.json -o api/OpenAPI.json
|
|
|
|
- name: Commit changes
|
|
if: github.event_name != 'pull_request'
|
|
uses: EndBug/add-and-commit@v4
|
|
with:
|
|
cwd: "api"
|
|
add: "*.json"
|
|
message: "chore: generate OpenAPI specification"
|