-
Notifications
You must be signed in to change notification settings - Fork 23
164 lines (138 loc) · 5.98 KB
/
tests.yml
File metadata and controls
164 lines (138 loc) · 5.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Run Tests
on:
- pull_request
- push
- workflow_call
- workflow_dispatch
concurrency:
group: ${{ github.workflow }}-test-${{ github.ref }}
cancel-in-progress: true
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
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') }}
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v6
- uses: FedericoCarboni/setup-ffmpeg@37062fbf7149fc5578d6c57e08aed62458b375d6 # @v3.1, with tool cache
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.9"
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: |
coverage run -m pytest
DEVELOPMENT=1 coverage run tests/test_web_api.py
coverage combine
coverage xml
- run: coverage report
- name: Make sure pre-commit hooks pass
uses: pre-commit/action@v3.0.1
- name: Automated license checking
# Make sure we don't have or introduce dependencies with incompatible licenses.
# Exclusions where auto detection and analysis do not work:
# - pympi-ling is MIT, but not auto-detected. https://github.com/dopefishh/pympi
# - text-unidecode is Artistic License or GPL (at our choice): MIT is
# compatible with the former. https://github.com/kmike/text-unidecode/
# - setuptools is MIT, but not always auto-detected.
run: licensecheck --requirements-path pyproject.toml --zero --ignore-packages pympi-ling text-unidecode setuptools
- uses: codecov/codecov-action@v5
with:
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
if grep -q -E '[0-9]{6} ' importtime.txt; then \
echo "Imports that take more than 0.1 s:" >> import-message.txt; \
grep -E 'cumulative|[0-9]{6} ' importtime.txt >> import-message.txt; \
else \
echo "No imports take more than 0.1 s." >> import-message.txt; \
fi
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@7c1a3a3e5a072270dc21c0639df39ca11e860b2b # v3.5.0
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@v6
- uses: FedericoCarboni/setup-ffmpeg@37062fbf7149fc5578d6c57e08aed62458b375d6 # @v3.1, with tool cache
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.9"
cache: "pip"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[all]
- name: Run tests on Windows
run: python run_tests.py all
- 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 tests/data/cs-ref.readalong
if (diff (cat cs.readalong) (cat tests/data/cs-ref.readalong)) { throw "Output did not match reference" }
test-heroku-env:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Read the Heroku run time env and cmd
run: |
echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV
echo "RUNTIME_CMD=$(cat Procfile | grep web: | sed 's/web: *//')" >> $GITHUB_ENV
- name: Set up Python
uses: actions/setup-python@v6
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: Install minimal test dependencies
run: pip install httpx pytest
- name: unit test the web API
run: python -m tests.test_web_api