Skip to content

Miscelaneous changes #512

Miscelaneous changes

Miscelaneous changes #512

Workflow file for this run

name: Run Tests
on:
- pull_request
- push
jobs:
test:
runs-on: ubuntu-latest
# #no-ci in the commit log flags commit we don't want CI-validated
if: ${{ !contains(github.event.head_commit.message, '#no-ci') }}
steps:
- uses: actions/checkout@v3
- uses: FedericoCarboni/setup-ffmpeg@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
cache: "pip"
- name: Install Python dependencies
run: |
# Keep pip up to date
python -m pip install --upgrade pip
# Some dependencies are built using wheel
pip install wheel
# Install all Python dependencies in just one pip call, including Studio itself
pip install -r requirements.txt \
-r requirements.dev.txt \
-r requirements.ci.txt \
-e .
- name: Run tests
run: |
cd test
coverage run --parallel-mode run.py prod
DEVELOPMENT=1 coverage run --parallel-mode test_web_api.py
coverage combine
coverage xml
- name: Nitpicking
run: |
# coding style: we want black compliance
find . -name \*.py | xargs black --check
# Legal check: make sure we don't have or introduce GPL dependencies
if pip-licenses | grep -v 'Artistic License' | grep -v LGPL | grep GNU; then echo 'Please avoid introducing *GPL dependencies'; false; fi
- uses: codecov/codecov-action@v3
with:
directory: ./test
token: ${{ secrets.CODECOV_TOKEN }} # optional but apparently makes upload more reliable
fail_ci_if_error: false # too many upload errors to keep "true"
- name: Make sure the CLI stays fast
id: cli-load-time
run: |
PYTHONPROFILEIMPORTTIME=1 readalongs -h 2> importtime.txt > /dev/null
CLI_LOAD_TIME="$((/usr/bin/time --format=%E readalongs -h > /dev/null) 2>&1)"
echo "CLI load time: $CLI_LOAD_TIME"
echo "CLI load time: $CLI_LOAD_TIME" > import-message.txt
echo "PR head ${{ github.event.pull_request.head.sha }}" >> import-message.txt
echo "Imports that take more than 0.1 s:" >> import-message.txt
grep -E 'cumulative|[0-9]{6} ' importtime.txt >> import-message.txt
cat import-message.txt
echo "Full import time log:"
cat importtime.txt
if [[ "$CLI_LOAD_TIME" > "0:01.00" ]]; then \
echo "ERROR: readalongs --help is too slow."; \
echo "Please run 'PYTHONPROFILEIMPORTTIME=1 readalongs -h 2> importtime.txt; tuna importtime.txt' and tuck away expensive imports so that the CLI doesn't load them until it uses them."; \
false; \
fi
- name: Report help speed in a PR comment
if: github.event_name == 'pull_request'
uses: mshick/add-pr-comment@v2
with:
preformatted: true
message-path: import-message.txt
test-on-windows:
runs-on: windows-latest
if: ${{ !contains(github.event.head_commit.message, '#no-ci') }}
steps:
- uses: actions/checkout@v3
- uses: FedericoCarboni/setup-ffmpeg@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
cache: "pip"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r requirements.txt `
-r requirements.dev.txt `
-r requirements.ci.txt `
-e .
- name: Run tests on Windows
run: cd test && python run.py prod
- name: Make sure the CLI outputs utf8 on Windows
# Note: we're checking something CLI specific, from a prompt, so we don't want to run
# in from a testing harness or framework, we want direct CLI.
# This test will fail if the output encoding is cp1252
# Warning: the diff line below is PowerShell syntax, not bash!
run: |
echo ćś | readalongs make-xml -l fra - - > cs.readalong
if (diff (cat cs.readalong) (cat test/data/cs-ref.readalong)) { throw "Output did not match reference" }