Sync GEO data with IFRC-GO #53
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: Python check | |
on: | |
push: | |
branches: | |
- develop | |
pull_request: | |
jobs: | |
pre_commit_checks: | |
name: ๐ด Pre-Commit checks ๐ด | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@main | |
- name: Install poetry | |
run: pipx install poetry | |
- uses: actions/setup-python@main | |
with: | |
cache: 'poetry' | |
- run: poetry install | |
- uses: pre-commit/action@main | |
test: | |
name: ๐ด Test ๐ด | |
runs-on: ubuntu-latest | |
needs: pre_commit_checks | |
steps: | |
- uses: actions/checkout@main | |
- name: ๐ณ Prepare Docker | |
id: prep | |
run: | | |
TAG=$(echo $GITHUB_SHA | head -c7) | |
IMAGE="backend" | |
echo "tagged_image=${IMAGE}:${TAG}" >> $GITHUB_OUTPUT | |
echo "tag=${TAG}" >> $GITHUB_OUTPUT | |
- name: ๐ณ Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: ๐ณ Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.ref }} | |
restore-keys: | | |
${{ runner.os }}-buildx-refs/develop | |
${{ runner.os }}-buildx- | |
- name: ๐ณ Build image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
builder: ${{ steps.buildx.outputs.name }} | |
file: Dockerfile | |
push: false | |
load: true | |
tags: ${{ steps.prep.outputs.tagged_image }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new | |
- name: ๐ฎ Validate latest graphql schema. | |
env: | |
DOCKER_IMAGE_BACKEND: ${{ steps.prep.outputs.tagged_image }} | |
run: | | |
docker-compose -f ./gh-docker-compose.yml run --rm web bash -c 'wait-for-it db:5432 && ./manage.py graphql_schema --out /ci-share/schema-latest.graphql' && | |
cmp --silent schema.graphql ./ci-share/schema-latest.graphql || { | |
echo 'The schema.graphql is not up to date with the latest changes. Please update and push latest'; | |
diff schema.graphql ./ci-share/schema-latest.graphql; | |
exit 1; | |
} | |
- name: ๐ฎ Validate if there are no pending django migrations. | |
env: | |
DOCKER_IMAGE_BACKEND: ${{ steps.prep.outputs.tagged_image }} | |
run: | | |
docker-compose -f ./gh-docker-compose.yml run --rm web bash -c 'wait-for-it db:5432 && ./manage.py makemigrations --check --dry-run' || { | |
echo 'There are some changes to be reflected in the migration. Make sure to run makemigrations'; | |
exit 1; | |
} | |
- name: ๐ค Run Test ๐งช & Publish coverage to code climate | |
env: | |
DOCKER_IMAGE_BACKEND: ${{ steps.prep.outputs.tagged_image }} | |
run: docker-compose -f gh-docker-compose.yml run --rm web /code/scripts/run_tests.sh | |
# Temp fix | |
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#github-cache | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
- name: ๐ณ Move docker cache (๐ง Hack fix) | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |