diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..be5b565 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,50 @@ +name: Build + +on: + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-tests: + name: Build and Test + runs-on: ubuntu-latest + outputs: + semVer: ${{ steps.gitversion.outputs.semVer }} + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Cache pip dependencies + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run linting + run: | + pip install flake8 + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + + - name: Run tests + run: | + pip install pytest + pytest test_api.py + diff --git a/test_api.py b/test_api.py new file mode 100644 index 0000000..acb064f --- /dev/null +++ b/test_api.py @@ -0,0 +1,17 @@ +import pytest +from app import app + +@pytest.fixture +def client(): + with app.test_client() as client: + yield client + +def test_svg_response(client): + response = client.get("/28/") + + assert response.status_code == 200 + + assert response.content_type == "image/svg+xml" + + assert b"" in response.data