name: Rust
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
env:
CARGO_TERM_COLOR: always
jobs:
build-dev:
runs-on: ubuntu-latest
if: github.ref_name == 'dev'
environment: build-and-test-for-dev
env:
DPTRAN_DEEPL_API_KEY: ${{ secrets.DPTRAN_DEEPL_API_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose
- name: Run tests
run: |
pip3 install -r requirements.txt
uvicorn dummy_api_server.main:app --reload --port 8000 &
sleep 5 # Wait for the dummy API server to start
cargo test --verbose -- --test-threads=1
build-main:
runs-on: ubuntu-latest
if: github.ref_name == 'main'
environment: build-and-test
env:
DPTRAN_DEEPL_API_KEY: ${{ secrets.DPTRAN_DEEPL_API_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose
- name: Run tests
run: |
if [ -z "$DPTRAN_DEEPL_API_KEY_PRO" ]; then
echo "Tests will run with a free DeepL API key."
else
echo "Tests will run with a Pro DeepL API key."
fi
pip3 install -r requirements.txt
uvicorn dummy_api_server.main:app --reload --port 8000 &
sleep 5 # Wait for the dummy API server to start
cargo test --verbose -- --test-threads=1