Skip to content

Commit

Permalink
ci: minimalist initial CI workflow
Browse files Browse the repository at this point in the history
Since we say this is 3.8 compatible but everyvoice needs 3.10,
let us have CI making sure mypy from Python 3.8 can still parse the code.

Also, ctc-segmenter should accept -h as synonym for --help.
  • Loading branch information
joanise committed Jan 25, 2024
1 parent e749ed0 commit c51e265
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
51 changes: 51 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Run Tests
on:
- push
- pull_request
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 15
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Conda
uses: conda-incubator/setup-miniconda@v2
with:
python-version: "3.8"
- name: Install dependencies and package
run: pip install -e . mypy
- name: Minimal test, --help should work
run: ctc-segmenter --help
- name: Code quality test, mypy should pass
run: mypy aligner
- name: Make sure the CLI stays fast
id: cli-load-time
run: |
PYTHONPROFILEIMPORTTIME=1 ctc-segmenter -h 2> importtime.txt > /dev/null
CLI_LOAD_TIME="$((/usr/bin/time --format=%E ctc-segmenter -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: ctc-segmenter --help is too slow."; \
echo "Please run 'PYTHONPROFILEIMPORTTIME=1 ctc-segmenter -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 PR
if: github.event_name == 'pull_request'
uses: mshick/add-pr-comment@v2
with:
preformatted: true
message-path: import-message.txt
1 change: 1 addition & 0 deletions aligner/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

app = typer.Typer(
pretty_exceptions_show_locals=False,
context_settings={"help_option_names": ["-h", "--help"]},
help="An alignment tool based on CTC segmentation to split long audio into utterances",
)

Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ ensure_newline_before_comments=True

[mypy]
ignore_missing_imports = True
plugins = pydantic.mypy

[flake8]
ignore = E203, E266, E501, W503
Expand Down

0 comments on commit c51e265

Please sign in to comment.