Skip to content

Feature/docstrings #3434

Feature/docstrings

Feature/docstrings #3434

Workflow file for this run

name: Django Test Runner
on:
push:
branches:
- 'develop'
- 'project/**'
pull_request:
branches:
- 'develop'
- 'project/**'
env:
GITHUB_WORKFLOW: true
jobs:
build:
# Run this workflow only for PRs or push events from the same repo (exclude forks)
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: 🐳 Prepare Docker
id: prep
run: |
TAG=$(echo $GITHUB_SHA | head -c7)
IMAGE="docker.pkg.github.com/idmc-labs/helix-server"
echo "tagged_image=${IMAGE}:${TAG}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
- name: 🐳 Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: 🐳 Cache Docker layers
uses: actions/cache@v2
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@v2
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
file: api.Dockerfile
push: false # This would be set to true in a real world deployment scenario.
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_SERVER: ${{ steps.prep.outputs.tagged_image }}
run: |
docker compose -f gh-docker-compose.yml run --rm server ./manage.py graphql_schema --out schema-latest.graphql &&
cmp --silent schema.graphql schema-latest.graphql || {
echo 'The schema.graphql is not up to date with the latest changes. Please update and push latest';
diff schema.graphql schema-latest.graphql;
exit 1;
}
- name: 🕮 Validate if there are no pending django migrations.
env:
DOCKER_IMAGE_SERVER: ${{ steps.prep.outputs.tagged_image }}
run: |
docker compose -f gh-docker-compose.yml run --rm server python3 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
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_ID }}
DOCKER_IMAGE_SERVER: ${{ steps.prep.outputs.tagged_image }}
with:
coverageCommand: docker compose -f gh-docker-compose.yml run --rm server /code/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
- name: Deploy coverage to GH Pages 🚀
uses: JamesIves/[email protected]
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
with:
branch: gh-pages
folder: ./htmlcov