Fix various errors (#1465) #266
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: latest-build | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- develop | |
push: | |
branches: | |
- develop | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: | |
- 3.7 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
- name: Test installing development dependencies | |
working-directory: deployment/docker | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r REQUIREMENTS-dev.txt | |
- name: Run Flake8 test | |
run: flake8 . | |
test: | |
runs-on: ubuntu-latest | |
needs: | |
- lint | |
env: | |
APP_IMAGE: kartoza/projecta-uwsgi | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Build test image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: deployment/docker/Dockerfile | |
push: false | |
load: true | |
target: dev | |
tags: ${{ env.APP_IMAGE }}:dev | |
cache-from: | | |
type=gha,scope=test | |
type=gha,scope=prod | |
cache-to: type=gha,scope=test | |
- name: Build prod image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: deployment/docker/Dockerfile | |
push: false | |
load: true | |
target: dev | |
tags: ${{ env.APP_IMAGE }}:prod | |
cache-from: | | |
type=gha,scope=test | |
type=gha,scope=prod | |
cache-to: type=gha,scope=prod | |
- name: Run docker-compose services | |
working-directory: deployment | |
run: | | |
echo "Override docker-compose for testing purposes" | |
cp .env.example .env | |
cp docker-compose.test.yml docker-compose.override.yml | |
make up | |
make devweb | |
make wait-db | |
make create-test-db | |
- name: Run Coverage test | |
working-directory: deployment | |
run: | | |
cat << EOF | docker-compose exec -T devweb bash | |
python manage.py makemigrations | |
python manage.py migrate | |
python manage.py collectstatic --noinput --verbosity 0 | |
coverage run manage.py test | |
coverage xml | |
EOF | |
docker cp projecta_devweb_1:/home/web/django_project/coverage.xml ../coverage.xml | |
- name: Upload coverage to codecov | |
uses: codecov/codecov-action@v2 | |
with: | |
fail_ci_if_error: true | |
docker-builder: | |
# Only push if PR happens in the same repo | |
if: github.event.pull_request.base.repo.url == github.event.pull_request.head.repo.url | |
runs-on: ubuntu-latest | |
needs: | |
- test | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Docker meta | |
id: docker_meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: ${{ secrets.DOCKERHUB_REPO }}/projecta-uwsgi | |
tags: | | |
type=semver,pattern=\d.\d.\d | |
type=ref,event=branch | |
type=ref,event=pr | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: deployment/docker/Dockerfile | |
push: true | |
target: prod | |
tags: ${{ steps.docker_meta.outputs.tags }} | |
labels: ${{ steps.docker_meta.outputs.labels }} | |
cache-from: | | |
type=gha,scope=test | |
type=gha,scope=prod | |
cache-to: type=gha,scope=prod | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |