Test codecov #1
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: tests | ||
on: | ||
workflow_call: | ||
inputs: | ||
build-tag: | ||
required: true | ||
type: string | ||
jobs: | ||
style: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
- name: Install black | ||
run: pip install black==22.8.0 | ||
- name: Style check | ||
run : make style_check | ||
migration_check: | ||
runs-on: ubuntu-latest | ||
services: | ||
mysql: | ||
image: mysql:8.0.30 | ||
ports: | ||
- 8877:3306 | ||
# needed because the container does not provide a healthcheck | ||
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=root --entrypoint sh mysql:8.0.30 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password" | ||
steps: | ||
- name: Download artifacts (Docker images) from previous workflows | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: surface-tests | ||
path: /tmp | ||
- name: Load Docker images from previous workflows | ||
run: docker load --input /tmp/myimage.tar | ||
- name: Check for not-migrated changes in models | ||
run: | | ||
docker run --network host \ | ||
-e SURF_DATABASE_URL="mysql://root:root@127.0.0.1:8877/surface" \ | ||
ghcr.io/${{ github.repository }}:${{ inputs.build-tag }} \ | ||
sh -c './manage.py makemigrations --dry-run --check' | ||
pytest: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.9, 3.11] | ||
database: | ||
- db: mysql | ||
url: mysql://root:root@127.0.0.1:8877/surface | ||
- db: postgresql | ||
url: psql://root:root@127.0.0.1:8878/surface | ||
services: | ||
mysql: | ||
image: mysql:8.0.30 | ||
ports: | ||
- 8877:3306 | ||
# needed because the container does not provide a healthcheck | ||
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=root --entrypoint sh mysql:8.0.30 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password" | ||
postgres: | ||
image: postgres:15 | ||
env: | ||
POSTGRES_USER: root | ||
POSTGRES_PASSWORD: root | ||
POSTGRES_DB: surface | ||
ports: | ||
- 8878:5432 | ||
# needed because the postgres container does not provide a healthcheck | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Download artifacts (Docker images) from previous workflows | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: surface-tests | ||
path: /tmp | ||
- name: Load Docker images from previous workflows | ||
run: docker load --input /tmp/myimage.tar | ||
- name: run tests | ||
run: | | ||
docker run --network host \ | ||
-e SURF_DATABASE_URL=${{ matrix.database.url }} \ | ||
-v $(pwd)/cov/:/report \ | ||
ghcr.io/${{ github.repository }}:${{ inputs.build-tag }} \ | ||
sh -c 'pip install -r requirements_test.txt && pytest -n4 --cov --cov-report=xml:/report/coverage.xml' | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
# do not fail ci for now - https://github.com/codecov/codecov-action/issues/557#issuecomment-1073777427 | ||
fail_ci_if_error: false | ||
files: ./cov/coverage.xml | ||