From 0cebb69e02a19ffa7140cb1fd5d5315b50a3e5e3 Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Sat, 14 Jan 2023 15:42:30 +0000 Subject: [PATCH] feat: automate generating OpenAPI specification --- .github/workflows/rust.yaml | 49 +++++++++++++++++++++++++++++++------ docker-compose.db.yml | 9 +++++++ 2 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 docker-compose.db.yml diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index 4386b19f..88afedb0 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -1,10 +1,10 @@ -name: Rust build and test +name: Rust build, test, and generate specification on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] env: CARGO_TERM_COLOR: always @@ -18,16 +18,51 @@ jobs: - name: Install latest nightly uses: actions-rs/toolchain@v1 with: - toolchain: nightly - override: true - components: rustfmt, clippy + toolchain: nightly + 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 + run: | + cp .env.example .env + + - name: Run services in background + run: | + docker-compose up -d -f docker-compose.db.yml + + - name: Start API in background + run: | + cargo run --bin revolt-delta & + + - name: Wait for API to go up + uses: nev7n/wait_for_response@v1 + with: + url: "http://localhost:8000/" + + - name: Checkout API repository + uses: actions/checkout@v3 + with: + repository: revoltchat/api + path: api + + - name: Download OpenAPI specification + run: curl http://localhost:8000/openapi.json -o api/OpenAPI.json + + - name: Commit changes + uses: EndBug/add-and-commit@v4 + with: + cwd: "api" + add: "*.json" + message: "chore: generate OpenAPI specification" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/docker-compose.db.yml b/docker-compose.db.yml new file mode 100644 index 00000000..4801e7d4 --- /dev/null +++ b/docker-compose.db.yml @@ -0,0 +1,9 @@ +version: "3.3" +services: + # MongoDB + database: + image: mongo + ports: + - "27017:27017" + volumes: + - ./.data/db:/data/db