Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minimal CI validating that this repo stays Python 3.8 compatible #5

Merged
merged 4 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
cache: "pip"
- 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
14 changes: 14 additions & 0 deletions .gitlint
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[general]
# Enable conventional commit linting
contrib=contrib-title-conventional-commits

# We don't require a body, just a title, even though a body is also a good idea
ignore=body-is-missing

[contrib-title-conventional-commits]
# Specify allowed commit types. For details see: https://www.conventionalcommits.org/
# Use type pXYZ for partial work towards a commit of type XYZ that won't show up in the
# release logs. Make sure the merge commit or the commit that completes the work has
# type XYZ:, though, and consider squashing the partial commits if that makes sense.
types = fix, feat, chore, docs, style, refactor, perf, test, revert, ci, build,
pfeat, pfix, pdoc, ptest, prefactor
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
Loading