239 lines
5.8 KiB
YAML
239 lines
5.8 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
types: [opened, reopened, synchronize, edited]
|
|
branches: [main]
|
|
|
|
concurrency:
|
|
group: ${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
pre-commit:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-python@v2
|
|
- uses: pre-commit/action@v2.0.3
|
|
|
|
check-shell:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-python@v2
|
|
- run: |
|
|
python -m venv venv && source venv/bin/activate
|
|
pip install gh-release-install
|
|
|
|
sudo venv/bin/gh-release-install \
|
|
koalaman/shellcheck \
|
|
shellcheck-{tag}.linux.x86_64.tar.xz --extract shellcheck-{tag}/shellcheck \
|
|
/usr/bin/shellcheck
|
|
|
|
sudo venv/bin/gh-release-install \
|
|
mvdan/sh \
|
|
shfmt_{tag}_linux_amd64 \
|
|
/usr/bin/shfmt
|
|
|
|
- run: SEVERITY=warning make shell-check
|
|
|
|
test-tools:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-python@v2
|
|
- run: make all
|
|
working-directory: tools
|
|
|
|
lint-legacy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: 7.4
|
|
- name: Lint
|
|
run: make lint
|
|
working-directory: legacy
|
|
|
|
test-legacy:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- runs-on: ubuntu-18.04
|
|
php-version: "7.2"
|
|
- runs-on: ubuntu-20.04
|
|
php-version: "7.4"
|
|
|
|
runs-on: ${{ matrix.runs-on }}
|
|
env:
|
|
ENVIRONMENT: testing
|
|
LIBRETIME_LOG_DIR: /tmp/log/libretime
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Setup PostgreSQL
|
|
run: |
|
|
sudo systemctl start postgresql.service
|
|
pg_isready
|
|
sudo -u postgres psql -c 'CREATE DATABASE libretime;'
|
|
sudo -u postgres psql -c "CREATE USER libretime WITH PASSWORD 'libretime';"
|
|
sudo -u postgres psql -c 'GRANT CONNECT ON DATABASE libretime TO libretime;'
|
|
sudo -u postgres psql -c 'ALTER USER libretime CREATEDB;'
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: ${{ matrix.php-version }}
|
|
|
|
- name: Get Composer Cache Directory
|
|
id: composer-cache
|
|
run: |
|
|
echo "::set-output name=dir::$(composer config cache-files-dir)"
|
|
|
|
- uses: actions/cache@v2
|
|
with:
|
|
path: ${{ steps.composer-cache.outputs.dir }}
|
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-composer-
|
|
|
|
- name: Run tests
|
|
run: |
|
|
sudo mkdir -p "$LIBRETIME_LOG_DIR"
|
|
sudo chown runner:runner "$LIBRETIME_LOG_DIR"
|
|
make test
|
|
working-directory: legacy
|
|
|
|
# Start lint the code without failing the entire workflow, should be merged
|
|
# into 'test' when the entire matrix succeeds.
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
context:
|
|
- analyzer
|
|
- api
|
|
- api_client
|
|
- playout
|
|
- shared
|
|
- worker
|
|
|
|
container: ghcr.io/libretime/libretime-dev:buster
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/cache@v2
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-
|
|
|
|
- name: Add annotations matchers
|
|
run: |
|
|
echo "::add-matcher::.github/annotations/pylint.json"
|
|
|
|
- name: Lint
|
|
run: make lint
|
|
working-directory: ${{ matrix.context }}
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
context:
|
|
- analyzer
|
|
- api_client
|
|
- shared
|
|
release:
|
|
- buster
|
|
- bullseye
|
|
- bionic
|
|
- focal
|
|
|
|
container: ghcr.io/libretime/libretime-dev:${{ matrix.release }}
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/cache@v2
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-pip-${{ matrix.context }}-${{ hashFiles('**/setup.py') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-${{ matrix.context }}
|
|
|
|
- name: Test
|
|
run: make test
|
|
working-directory: ${{ matrix.context }}
|
|
|
|
test-with-database:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
context:
|
|
- api
|
|
release:
|
|
- buster
|
|
- bullseye
|
|
- bionic
|
|
- focal
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres
|
|
env:
|
|
POSTGRES_PASSWORD: libretime
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
|
|
container: ghcr.io/libretime/libretime-dev:${{ matrix.release }}
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
env:
|
|
LIBRETIME_CONF_FILE: /tmp/libretime-test.conf
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/cache@v2
|
|
with:
|
|
path: ~/.cache/pip
|
|
key: ${{ runner.os }}-pip-${{ matrix.context }}-${{ hashFiles('**/setup.py') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-${{ matrix.context }}
|
|
|
|
- name: Setup libretime configuration
|
|
run: |
|
|
cat <<EOF > $LIBRETIME_CONF_FILE
|
|
[general]
|
|
api_key = test_key
|
|
[database]
|
|
host = postgres
|
|
dbname = libretime
|
|
dbuser = postgres
|
|
dbpass = libretime
|
|
EOF
|
|
cat $LIBRETIME_CONF_FILE
|
|
|
|
- name: Test
|
|
run: make test
|
|
working-directory: ${{ matrix.context }}
|