ci: use docker-compose stack for pytest workflow #1
Workflow file for this run
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: pytest | ||
on: | ||
workflow_call: | ||
inputs: | ||
image_tag: | ||
required: true | ||
type: string | ||
environment: | ||
required: false | ||
type: string | ||
permissions: | ||
contents: read | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: ${{ inputs.environment || 'test' }} | ||
extract-vars: | ||
uses: ./.github/workflows/r-extract_vars.yml | ||
with: | ||
environment: ${{ inputs.environment || 'test' }} | ||
run-pytest: | ||
runs-on: ubuntu-latest | ||
needs: [extract-vars] | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Environment to .env | ||
env: | ||
API_VERSION: ${{ needs.extract-vars.outputs.api_version }} | ||
FRONTEND_MAIN_VERSION: ${{ needs.extract-vars.outputs.frontend_main_version }} | ||
FRONTEND_MAIN_URL: ${{ vars.FRONTEND_MAIN_URL }} | ||
ODK_CENTRAL_URL: ${{ vars.ODK_CENTRAL_URL }} | ||
ODK_CENTRAL_USER: ${{ vars.ODK_CENTRAL_USER }} | ||
ODK_CENTRAL_PASSWD: ${{ secrets.ODK_CENTRAL_PASSWD }} | ||
OSM_CLIENT_ID: ${{ secrets.OSM_CLIENT_ID }} | ||
OSM_CLIENT_SECRET: ${{ secrets.OSM_CLIENT_SECRET }} | ||
OSM_SECRET_KEY: ${{ secrets.OSM_SECRET_KEY }} | ||
run: | | ||
echo "APP_VERSION=${API_VERSION}" >> .env | ||
echo "API_TAG_OVERRIDE=${{ inputs.image_tag }}" >> .env | ||
echo "FRONTEND_MAIN_VERSION=${FRONTEND_MAIN_VERSION}" >> .env | ||
echo "FRONTEND_MAIN_URL=${FRONTEND_MAIN_URL}" >> .env | ||
echo "ODK_CENTRAL_URL=${ODK_CENTRAL_URL}" >> .env | ||
echo "ODK_CENTRAL_USER=${ODK_CENTRAL_USER}" >> .env | ||
echo "ODK_CENTRAL_PASSWD=${ODK_CENTRAL_PASSWD}" >> .env | ||
echo "OSM_CLIENT_ID=${OSM_CLIENT_ID}" >> .env | ||
echo "OSM_CLIENT_SECRET=${OSM_CLIENT_SECRET}" >> .env | ||
echo "OSM_SECRET_KEY=${OSM_SECRET_KEY}" >> .env | ||
- name: Start Services | ||
run: | | ||
cd src/backend | ||
docker compose up api --detach | ||
- name: Run pytest | ||
run: docker exec fmtm_api pytest |