Skip to content

docs: align api/v1/langs doc to match current implementation #837

docs: align api/v1/langs doc to match current implementation

docs: align api/v1/langs doc to match current implementation #837

Workflow file for this run

name: Run Tests
on:
- pull_request
- push
- workflow_call
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@v4
- uses: FedericoCarboni/setup-ffmpeg@v2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
cache: "pip"
- name: Install Python dependencies
run: |
# Keep pip up to date
python -m pip install --upgrade pip
# Install all Python dependencies in just one pip call, including Studio itself
pip install -e .[all]
- 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: Make sure pre-commit hooks pass
uses: pre-commit/[email protected]
- name: Minimalist license check
run: |
# 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@v4
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" > import-message.txt
PR_HEAD="${{ github.event.pull_request.head.sha }}"
[[ $PR_HEAD ]] && echo "Pull Request HEAD: $PR_HEAD" >> 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'
continue-on-error: true
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@v4
- uses: FedericoCarboni/setup-ffmpeg@v2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
cache: "pip"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[all]
- 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 - - | findstr /v meta > cs.readalong
echo Output ====
cat cs.readalong
echo Reference ====
cat test/data/cs-ref.readalong
if (diff (cat cs.readalong) (cat test/data/cs-ref.readalong)) { throw "Output did not match reference" }
test-heroku-env:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Read the Heroku run time env and cmd
run: |
echo "PYTHON_VERSION=$(cat runtime.txt | sed 's/python-//')" >> $GITHUB_ENV
echo "RUNTIME_CMD=$(cat Procfile | grep web: | sed 's/web: *//')" >> $GITHUB_ENV
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "pip"
- name: Install Python dependencies the way Heroku would
run: |
pip install -r requirements.txt
bin/post_compile
- name: Launch the API via the Heroku Procfile
run: |
${{ env.RUNTIME_CMD }} &
curl --retry 20 --retry-delay 1 --retry-all-errors http://127.0.0.1:8000/api/v1/docs | grep SwaggerUIBundle
curl http://127.0.0.1:8000/api/v1/langs | grep Cree
kill %1
- name: unit test the web API
run: |
pip install -e .[dev]
python test/test_web_api.py