diff --git a/.github/workflows/python-checks.yml b/.github/workflows/python-checks.yml index a0f4ed2fa..ab786c527 100644 --- a/.github/workflows/python-checks.yml +++ b/.github/workflows/python-checks.yml @@ -1,4 +1,4 @@ -name: Package checks +name: CI on: push: @@ -27,40 +27,40 @@ jobs: # Maps tcp port 5432 on service container to the host - 5432:5432 - steps: # Set up cache for pip packages - - uses: actions/cache@v4 + - name: Cache pip packages ๐Ÿ“ฆ + uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- - # Checkout the code - - uses: actions/checkout@v4 + - name: Checkout ๐Ÿ›Ž + uses: actions/checkout@master # Setup python - - name: set up python 3.10 + - name: Setup python 3.10 env ๐Ÿ— uses: actions/setup-python@v5 with: python-version: "3.10" # Install dependencies - - name: Install dependencies + - name: Install dependencies ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป run: pip install -r requirements/local.txt # Collect static - - name: Collect Static + - name: Collect Static ๐Ÿ“ฆ run: ./manage.py collectstatic --noinput - - name: Tests + - name: Run tests ๐Ÿงช run: | pytest --cov uobtheatre --cov-fail-under 100 -m "not system_test" env: DATABASE_URL: postgresql://postgres:postgres@0.0.0.0:5432/uobtheatre_api - - name: System tests + - name: Run system tests โ€๐Ÿ”ฌ if: ${{ github.actor != 'dependabot[bot]' }} run: | pytest --cov uobtheatre -m "system_test" @@ -72,76 +72,140 @@ jobs: runs-on: ubuntu-latest steps: # Set up cache for pip packages - - uses: actions/cache@v4 + - name: Cache pip packages ๐Ÿ“ฆ + uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- - # Checkout the code - - uses: actions/checkout@v4 + - name: Checkout ๐Ÿ›Ž + uses: actions/checkout@master # Setup python - - name: set up python 3.10 + - name: Setup python 3.10 env ๐Ÿ— uses: actions/setup-python@v5 with: python-version: "3.10" # Install dependencies - - name: Install dependencies + - name: Install dependencies ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป run: pip install -r requirements/local.txt - - name: black - formatting + - name: Run black - formatting run: | - black uobtheatre + black uobtheatre --check - - name: isort - sort imports + - name: Run isort - sort imports run: | - isort uobtheatre + isort uobtheatre -c - - name: pylint - linting + - name: Run pylint - linting run: | pylint uobtheatre - - name: mypy - static type checking + - name: Run mypy - static type checking run: | mypy uobtheatre # Check migrations have been made - - name: Ensure migrations have been generated + - name: Ensure migrations have been generated ๐Ÿ‘€ run: python manage.py makemigrations --check + fixtures: + runs-on: ubuntu-latest + + services: + db_service: + image: postgres + env: + POSTGRES_USER: postgres + POSTGRES_DB: uobtheatre_api + POSTGRES_PASSWORD: postgres + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 5432 on service container to the host + - 5432:5432 + + steps: + # Set up cache for pip packages + - name: Cache pip packages ๐Ÿ“ฆ + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Checkout ๐Ÿ›Ž + uses: actions/checkout@master + + # Setup python + - name: Setup python 3.10 env ๐Ÿ— + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + # Install dependencies + - name: Install dependencies ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป + run: pip install -r requirements/local.txt + + # Collect static + - name: Collect Static ๐Ÿ“ฆ + run: ./manage.py collectstatic --noinput + + - name: Check example fixture data can still be loaded ๐Ÿ”„ + run: | + ./manage.py migrate + ./manage.py loaddata uobtheatre/images/fixtures.json uobtheatre/addresses/fixtures.json uobtheatre/users/fixtures.json uobtheatre/venues/fixtures.json uobtheatre/societies/fixtures.json uobtheatre/productions/fixtures.json uobtheatre/bookings/fixtures.json + env: + DATABASE_URL: postgresql://postgres:postgres@0.0.0.0:5432/uobtheatre_api + + - name: Check e2e fixture data can still be loaded ๐Ÿ”„ + run: | + ./manage.py flush --no-input + ./manage.py loaddata db.json + env: + DATABASE_URL: postgresql://postgres:postgres@0.0.0.0:5432/uobtheatre_api + schema: runs-on: ubuntu-latest steps: # Set up cache for pip packages - - uses: actions/cache@v4 + - name: Cache pip packages ๐Ÿ“ฆ + uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | ${{ runner.os }}-pip- - # Checkout the code - - uses: actions/checkout@v4 + - name: Checkout ๐Ÿ›Ž + uses: actions/checkout@master # Setup python - - name: set up python 3.10 + - name: Setup python 3.10 env ๐Ÿ— uses: actions/setup-python@v5 with: python-version: "3.10" # Install dependencies - - name: Install dependencies + - name: Install dependencies ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป run: pip install -r requirements/local.txt + # Generate schmea - - name: Generate schema + - name: Generate schema ๐Ÿค– run: | ./manage.py graphql_schema --schema uobtheatre.schema.schema --out schema.graphql # Push up the schema - - name: Commit schema + - name: Commit schema ๐Ÿ•ธ uses: EndBug/add-and-commit@v9 with: message: 'Updated schema'