testing if the api is working and add the test to the deployment script #62
This file contains 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: Tests for Main Merge | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
tests-on-main: | |
runs-on: ubuntu-latest | |
env: | |
# Set environment variables globally for all steps within the job | |
GOOGLE_PROJECT_ID: ${{ vars.GOOGLE_PROJECT_ID }} | |
GOOGLE_EARTH_ENGINE_SERVICE_ACCOUNT_CREDENTIALS: ${{ secrets.GOOGLE_EARTH_ENGINE_SERVICE_ACCOUNT_CREDENTIALS }} | |
GOOGLE_EARTH_ENGINE_SERVICE_ACCOUNT_EMAIL: ${{ secrets.GOOGLE_EARTH_ENGINE_SERVICE_ACCOUNT_EMAIL }} | |
ENVIRONMENT: ${{ vars.ENVIRONMENT }} | |
steps: | |
- uses: actions/checkout@v3 | |
# Build and the run the backend docker image | |
- name: Build and Run the Docker image (backend) | |
working-directory: ./backend | |
run: | | |
docker buildx build --platform linux/amd64 -t thf-climate-backend . | |
docker run -d -p 8000:8000 --name thf-climate-backend thf-climate-backend | |
- name: Wait for the application to start | |
working-directory: ./backend | |
run: | | |
timeout 30 bash -c 'until curl -s http://127.0.0.1:8000/; do sleep 1; done' | |
# Run the tests against the local application | |
- name: Install dependencies and Run tests | |
working-directory: ./backend | |
env: | |
API_BASE_URL: "http://127.0.0.1:8000" | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements-dev.txt | |
pytest |