Skip to content

Commit

Permalink
ci(pytest): simplify image caching and loading
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Oct 19, 2023
1 parent 293f2df commit 995f7f7
Showing 1 changed file with 18 additions and 43 deletions.
61 changes: 18 additions & 43 deletions .github/workflows/r-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,63 +14,38 @@ permissions:
contents: read

jobs:
cache-img-postgis:
uses: hotosm/gh-workflows/.github/workflows/image_cache.yml@main
with:
image_name: postgis/postgis:14-3.3-alpine
cache_key: img-postgis

cache-img-odk:
uses: hotosm/gh-workflows/.github/workflows/image_cache.yml@main
with:
image_name: ghcr.io/hotosm/fmtm/odkcentral:v2023.2.1
cache_key: img-odk

cache-img-odk-proxy:
uses: hotosm/gh-workflows/.github/workflows/image_cache.yml@main
with:
image_name: ghcr.io/hotosm/fmtm/odkcentral-proxy:latest
cache_key: img-odk-proxy

run-pytest:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.environment || 'test' }}
needs:
- cache-img-postgis
- cache-img-odk
- cache-img-odk-proxy

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Download Postgis Img
uses: actions/download-artifact@v3
with:
name: ${{ needs.cache-img-postgis.outputs.cache_key }}
path: /tmp/${{ needs.cache-img-postgis.outputs.cache_key }}.tar
# continue-on-error: true

- name: Download ODK Img
- id: images
name: Download image cache
uses: actions/download-artifact@v3
with:
name: ${{ needs.cache-img-odk.outputs.cache_key }}
path: /tmp/${{ needs.cache-img-odk.outputs.cache_key }}.tar
# continue-on-error: true

- name: Download ODK Proxy Img
uses: actions/download-artifact@v3
with:
name: ${{ needs.cache-img-odk-proxy.outputs.cache_key }}
path: /tmp/${{ needs.cache-img-odk-proxy.outputs.cache_key }}.tar
# continue-on-error: true
name: image-cache
path: /tmp/images
continue-on-error: true

- name: Load Cached Imgs
if: images.outputs.download_path == '/tmp/images'
run: |
docker image load --input /tmp/${{ needs.cache-img-postgis.outputs.cache_key }}.tar || true
docker image load --input /tmp/${{ needs.cache-img-odk.outputs.cache_key }}.tar || true
docker image load --input /tmp/${{ needs.cache-img-odk-proxy.outputs.cache_key }}.tar || true
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:
Expand Down

0 comments on commit 995f7f7

Please sign in to comment.