mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-05 18:58:53 -05:00
104 lines
2.7 KiB
YAML
104 lines
2.7 KiB
YAML
name: Tests
|
|
on:
|
|
pull_request:
|
|
push:
|
|
repository_dispatch:
|
|
types:
|
|
- dispatched_test
|
|
|
|
env:
|
|
ref: ${{ github.event.client_payload.ref || '' }}
|
|
|
|
jobs:
|
|
tox:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
python_version:
|
|
- "3.8"
|
|
tox_env:
|
|
- style
|
|
- docs
|
|
include:
|
|
- tox_env: py38
|
|
python_version: "3.8"
|
|
friendly_name: Python 3.8 - Tests
|
|
- tox_env: py39
|
|
python_version: "3.9"
|
|
friendly_name: Python 3.9 - Tests
|
|
- tox_env: py310
|
|
python_version: "3.10-dev"
|
|
friendly_name: Python 3.10-dev - Tests
|
|
- tox_env: style
|
|
friendly_name: Style
|
|
- tox_env: docs
|
|
friendly_name: Docs
|
|
fail-fast: false
|
|
name: Tox - ${{ matrix.friendly_name }}
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
ref: ${{ env.ref }}
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: ${{ matrix.python_version }}
|
|
- name: Install tox
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install 'tox<4'
|
|
- name: Tox test
|
|
env:
|
|
TOXENV: ${{ matrix.tox_env }}
|
|
run: tox
|
|
|
|
tox-postgres:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
python_version:
|
|
- "3.8"
|
|
- "3.9"
|
|
- "3.10-dev"
|
|
fail-fast: false
|
|
name: Tox - Postgres
|
|
services:
|
|
postgresql:
|
|
image: postgres:10
|
|
ports:
|
|
- 5432:5432
|
|
env:
|
|
POSTGRES_DB: red_db
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_USER: postgres
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
ref: ${{ env.ref }}
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: ${{ matrix.python_version }}
|
|
- name: Install tox
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install 'tox<4'
|
|
- name: Tox test
|
|
env:
|
|
TOXENV: postgres
|
|
PGDATABASE: red_db
|
|
PGUSER: postgres
|
|
PGPASSWORD: postgres
|
|
PGPORT: 5432
|
|
run: tox
|
|
- name: Verify no errors in PostgreSQL logs.
|
|
run: |
|
|
logs="$(docker logs "${{ job.services.postgresql.id }}" 2>&1)"
|
|
echo "---- PostgreSQL logs ----"
|
|
echo "$logs"
|
|
echo "---- PostgreSQL logs ----"
|
|
error_count="$(echo "$logs" | { grep -c 'ERROR: ' || true; })"
|
|
if [[ $error_count -gt 0 ]]; then
|
|
exit 1
|
|
fi
|