From c51e265525b074e4923f1fcb7c95a3020c8a7ba3 Mon Sep 17 00:00:00 2001 From: Eric Joanis Date: Wed, 24 Jan 2024 18:47:54 -0500 Subject: [PATCH 1/4] ci: minimalist initial CI workflow 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. --- .github/workflows/test.yml | 51 ++++++++++++++++++++++++++++++++++++++ aligner/cli.py | 1 + setup.cfg | 1 - 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..a784718 --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/aligner/cli.py b/aligner/cli.py index ba669c9..2996c82 100644 --- a/aligner/cli.py +++ b/aligner/cli.py @@ -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", ) diff --git a/setup.cfg b/setup.cfg index 8c6e724..0b2cb08 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,7 +9,6 @@ ensure_newline_before_comments=True [mypy] ignore_missing_imports = True -plugins = pydantic.mypy [flake8] ignore = E203, E266, E501, W503 From fa2c2b78cbe9543aa01b234373f66c5d05454fa7 Mon Sep 17 00:00:00 2001 From: Eric Joanis Date: Thu, 25 Jan 2024 10:43:09 -0500 Subject: [PATCH 2/4] ci: use setup python instead of conda --- .github/workflows/test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a784718..d1acf5e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,10 +15,11 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Set up Conda - uses: conda-incubator/setup-miniconda@v2 + - name: Set up Python + uses: actions/setup-python@v4 with: python-version: "3.8" + cache: "pip" - name: Install dependencies and package run: pip install -e . mypy - name: Minimal test, --help should work From 5b72112dca12eacfd71f474f0d34eb0973f623f9 Mon Sep 17 00:00:00 2001 From: Eric Joanis Date: Thu, 25 Jan 2024 10:51:18 -0500 Subject: [PATCH 3/4] style: configure gitlint --- .gitlint | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .gitlint diff --git a/.gitlint b/.gitlint new file mode 100644 index 0000000..6af560c --- /dev/null +++ b/.gitlint @@ -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 From 33c0b0ea7b4e27d5e63fb1319205adb7d829f261 Mon Sep 17 00:00:00 2001 From: Eric Joanis Date: Thu, 25 Jan 2024 11:10:17 -0500 Subject: [PATCH 4/4] ci: bump actions to their Node 20 versions since Node 16 is EOL --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d1acf5e..ebc6b46 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,9 +14,9 @@ jobs: shell: bash -l {0} steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.8" cache: "pip"