Add test case for autoimporting package listings #4684
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: Build & Test | |
on: [push, pull_request] | |
jobs: | |
pre-commit: | |
name: Run pre-commit | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: false | |
- name: Setup Python 3.8 | |
id: setup-python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.8" | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: "14" | |
- name: Get node version | |
id: node-version | |
run: echo "::set-output name=node-version::$(node --version)" | |
- uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-in-project: true | |
- name: Cache poetry venv | |
id: cache-poetry | |
uses: actions/cache@v2 | |
with: | |
path: django/.venv | |
key: "poetry-${{ runner.os }}-\ | |
${{ steps.setup-python.outputs.python-version }}-\ | |
${{ hashFiles('django/poetry.lock') }}" | |
restore-keys: | | |
poetry-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}- | |
- name: Install poetry dependencies | |
run: | | |
cd django/ | |
poetry install | |
- name: Cache pre-commit cache | |
uses: actions/cache@v2 | |
with: | |
path: ~/.cache/pre-commit | |
key: "pre-commit-${{ runner.os }}-\ | |
${{ steps.setup-python.outputs.python-version }}-\ | |
${{ steps.node-version.outputs.node-version }}-\ | |
${{ hashFiles('.pre-commit-config.yaml') }}" | |
- name: Run pre-commit | |
run: | | |
cd django/ | |
poetry run pre-commit run --show-diff-on-failure --color=always --all-files | |
build: | |
name: Build docker image | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: false | |
- name: Build Docker image | |
run: docker build --pull -t thunderstore:${GITHUB_SHA} . | |
- name: Export Docker image | |
run: docker save --output /tmp/thunderstore.tar thunderstore:${GITHUB_SHA} | |
- name: Upload Docker image | |
uses: actions/upload-artifact@v3 | |
with: | |
name: docker-image | |
path: /tmp/thunderstore.tar | |
test-pytest: | |
name: Test pytest | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
fail-fast: false | |
matrix: | |
group: [1, 2, 3, 4, 5, 6] | |
env: | |
PYTEST_SPLITS: 6 | |
PYTEST_GROUP: ${{ matrix.group }} | |
PYTEST_NUM_WORKERS: auto | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: false | |
- name: Download Docker image | |
uses: actions/download-artifact@v3 | |
with: | |
name: docker-image | |
path: /tmp | |
- name: Load Docker image | |
run: docker load --input /tmp/thunderstore.tar | |
- name: Run pytest | |
run: | | |
DJANGO_IMAGE="thunderstore:${GITHUB_SHA}" docker compose -f docker/docker-compose.pytest.yml up --exit-code-from django | |
DJANGO_IMAGE="thunderstore:${GITHUB_SHA}" docker compose -f docker/docker-compose.pytest.yml down | |
- name: Upload coverage to Codecov | |
if: always() | |
uses: codecov/codecov-action@v1 | |
with: | |
file: ./coverage_results/coverage.xml | |
test-mypy: | |
name: Test mypy | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: false | |
- name: Download Docker image | |
uses: actions/download-artifact@v3 | |
with: | |
name: docker-image | |
path: /tmp | |
- name: Load Docker image | |
run: docker load --input /tmp/thunderstore.tar | |
- name: Run mypy | |
run: > | |
docker run --rm | |
--entrypoint mypy | |
-e SECRET_KEY=hunter2 | |
--no-healthcheck | |
thunderstore:${GITHUB_SHA} | |
/app/ | |
|| : | |
test-missing-migrations: | |
name: Test missing migrations | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: false | |
- name: Download Docker image | |
uses: actions/download-artifact@v3 | |
with: | |
name: docker-image | |
path: /tmp | |
- name: Load Docker image | |
run: docker load --input /tmp/thunderstore.tar | |
- name: Check for missing migrations | |
run: > | |
docker run --rm | |
--entrypoint python | |
-e SECRET_KEY=hunter2 | |
-e DATABASE_URL=sqlite://django.db | |
--no-healthcheck | |
thunderstore:${GITHUB_SHA} | |
manage.py makemigrations --check |