Skip to content

ci(pytest): simplify image caching and loading #5

ci(pytest): simplify image caching and loading

ci(pytest): simplify image caching and loading #5

Workflow file for this run

name: pytest
on:
workflow_call:
inputs:
image_tag:
required: true
type: string
environment:
required: false
type: string
permissions:
contents: read
jobs:
run-pytest:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.environment || 'test' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- id: images
name: Download image cache
uses: actions/download-artifact@v3
with:
name: image-cache
path: /tmp/images
continue-on-error: true
- name: Load Cached Imgs
if: images.outputs.download_path == '/tmp/images'
run: |
for image_tar in /tmp/images/*; do
docker image load --input $image_tar || true
done
- if: images.outputs.download_path != '/tmp/images'
uses: hotosm/gh-workflows/.github/workflows/image_cache.yml@main
with:
image_names: |
postgis/postgis:14-3.3-alpine
ghcr.io/hotosm/fmtm/odkcentral:v2023.2.1
ghcr.io/hotosm/fmtm/odkcentral-proxy:latest
cache_key: image-cache
- name: Environment to .env
env:
DEBUG: True
LOG_LEVEL: DEBUG
API_TAG_OVERRIDE: "${{ inputs.image_tag }}"
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 }}"
S3_ACCESS_KEY: "fmtm"
S3_SECRET_KEY: "somelongpassword"
run: |
echo "DEBUG=${DEBUG}" >> .env
echo "LOG_LEVEL=${LOG_LEVEL}" >> .env
echo "API_TAG_OVERRIDE=${API_TAG_OVERRIDE}" >> .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
echo "S3_ACCESS_KEY=${S3_ACCESS_KEY}" >> .env
echo "S3_SECRET_KEY=${S3_SECRET_KEY}" >> .env
- name: Run PyTest
run: |
docker compose run api \
wait-for-it fmtm-db:5432 --strict \
-- wait-for-it central:8383 --strict \
-- pytest