Skip to content

Added tests for parsing listing page from flugzeugmarkt_de + small re… #128

Added tests for parsing listing page from flugzeugmarkt_de + small re…

Added tests for parsing listing page from flugzeugmarkt_de + small re… #128

Workflow file for this run

name: CD - Backend (api, jobs)
on:
push:
branches: [ main ]
paths:
- backend/**
pull_request:
branches: [ main ]
paths:
- backend/**
workflow_dispatch:
env:
REGISTRY: ghcr.io
DOCKER_REPO: ghcr.io/lwitkowski
jobs:
build-api:
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v4
- run: |
echo "DOCKER_IMAGE=${DOCKER_REPO}/aerooffers-api:${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: 'Install dependencies'
working-directory: ./backend
run: |
pip3 install --quiet -r requirements.txt -r tests/requirements.txt
- name: 'Static analysis (Lint)'
working-directory: ./backend
run: ./run_lint.sh
- name: 'Run tests'
working-directory: ./backend
run: |
./run_tests.sh
- name: 'Check test coverage'
working-directory: ./backend
run: |
coverage report --fail-under=80
- name: 'Publish Test Results'
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
./backend/test-results.xml
- name: 'Build docker image'
working-directory: ./backend
run: |
docker build . -t ${DOCKER_IMAGE}
- name: 'Log in to the Container Registry'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 'Push image to Container Registry (ghcr)'
if: github.ref == 'refs/heads/main'
run: |
docker push ${DOCKER_IMAGE}
# only for main builds
deploy:
runs-on: ubuntu-latest
environment: production
if: github.ref == 'refs/heads/main'
needs:
- build-api
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- run: |
echo "API_DOCKER_IMAGE=${DOCKER_REPO}/aerooffers-api:${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: 'Azure Login'
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: 'Deploy API'
uses: azure/container-apps-deploy-action@v2
with:
resourceGroup: rg-aerooffers
containerAppEnvironment: cae-aerooffers-prod
containerAppName: aerooffers-api
imageToDeploy: ${{ env.API_DOCKER_IMAGE }}
disableTelemetry: true
- name: 'Deploy Job - update fx rates'
run: |
az containerapp job update \
-g rg-aerooffers \
--name update-fx-job \
--image ${{ env.API_DOCKER_IMAGE }}
- name: 'Deploy Job - update offers'
run: |
az containerapp job update \
-g rg-aerooffers \
--name update-offers-job \
--image ${{ env.API_DOCKER_IMAGE }}