Fix GitHub workflow (#14) #29
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
# Tomorrow Now GAP. | |
name: Tests | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
flake8_py3: | |
name: Python Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Python | |
uses: actions/setup-python@v1 | |
with: | |
python-version: 3.7 | |
architecture: x64 | |
- name: Checkout PyTorch | |
uses: actions/checkout@master | |
- name: Install flake8 | |
run: pip install flake8 | |
- name: Install flake8-docstrings | |
run: pip install flake8-docstrings | |
- name: Run flake8 | |
uses: suo/flake8-github-action@releases/v1 | |
with: | |
checkName: 'Python Lint' # NOTE: this needs to be the same as the job name | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
django_app_test: | |
needs: flake8_py3 | |
name: 'Django App' | |
runs-on: ubuntu-latest | |
env: | |
APP_IMAGE: kartoza/tomorrownow_gap | |
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: Run docker-compose services | |
working-directory: deployment | |
run: | | |
echo "Override docker-compose for testing purposes" | |
cp docker-compose.test.yml docker-compose.override.yml | |
cp .template.env .env | |
cd ../ | |
make dev | |
make wait-db | |
make sleep | |
make migrate | |
make npm-install | |
make build-react | |
make dev-runserver | |
make dev-load-demo-data | |
make sleep | |
# TODO: | |
# Fix this after we have the tests | |
# - name: Test django endpoint | |
# run: | | |
# curl http://localhost:5000/ | |
# if [ $? -ne 0 ]; then | |
# echo "Curl command failed" | |
# exit 1 | |
# fi | |
# | |
# - name: Test E2E | |
# working-directory: ./playwright/ci-test | |
# run: | | |
# npm install | |
# npm ci | |
# npx playwright install --with-deps | |
# npx playwright test --workers 1 | |
# - uses: actions/upload-artifact@v3 | |
# if: always() | |
# with: | |
# name: playwright-report | |
# path: playwright/ci-test/playwright-report/ | |
# retention-days: 30 | |
- name: Run Coverage test | |
working-directory: deployment | |
run: | | |
cat << EOF | docker-compose exec -T dev bash | |
python manage.py collectstatic --noinput --verbosity 0 | |
export DJANGO_SETTINGS_MODULE=core.settings.dev && coverage run manage.py test && coverage xml | |
EOF | |
docker cp dev:/home/web/django_project/coverage.xml ../coverage.xml | |
- name: Show Coverage | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: orgoro/coverage@v3 | |
with: | |
coverageFile: coverage.xml | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload coverage to codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: true |