Happy birthday Killua :D #306
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run API Tests | |
on: | |
push: | |
pull_request: | |
env: | |
RUST_BACKTRACE: full | |
MONGODB: mongodb://localhost:27017/Killua | |
API_KEY: test | |
HASH_SECRET: supersecretpassword | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
outputs: | |
api: ${{ steps.changes.outputs.api }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@v3 | |
id: changes | |
with: | |
filters: | | |
api: | |
- 'api/**/*.rs' | |
- 'api/Cargo.toml' | |
- 'api/Cargo.lock' | |
# run only if some file in 'api' folder was changed ending with .rs | |
test: | |
needs: setup | |
if: ${{ needs.setup.outputs.api == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Start MongoDB server | |
uses: supercharge/mongodb-github-action@1.11.0 | |
with: | |
mongodb-version: 'latest' | |
- name: Setup mongodb-tools | |
run: | | |
wget https://downloads.mongodb.com/compass/mongodb-mongosh_2.2.6_amd64.deb | |
sudo apt install ./mongodb-mongosh_2.2.6_amd64.deb | |
# Initialise db and collections | |
mongosh --eval "db.getSiblingDB('Killua').createCollection('api-stats')" | |
# - name: Initialise MongoDB Database and Collection | |
# run: | | |
# mongo --host localhost:27017 << EOF | |
# use Killua; | |
# db.createCollection("api-stats"); | |
# EOF | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Setup local cards | |
run: "echo '[{\"id\": 0, \"name\": \"Name\", \"description\": \"One two\", \"image\": \"/image/image.png\", \"emoji\": \":pensive\", \"rank\": \"S\", \"limit\": 10, \"type\": \"monster\", \"available\": true}]' > cards.json" | |
- name: Make update.sh executable | |
run: chmod +x scripts/update.sh | |
- name: Run clippy | |
run: cargo clippy --all --all-features --tests -- -D warnings | |
working-directory: api | |
- name: Run cargo fmt | |
run: cargo fmt --all -- --check | |
working-directory: api | |
- name: Run tests | |
run: cargo test -- --test-threads=1 | |
working-directory: api |