From 99b2b0b91d1677e018a03e4bd5ad636d490c9497 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 10 Jul 2024 02:18:56 +0200 Subject: [PATCH 1/5] add pre-commit workflows --- .github/dependabot.yml | 2 +- .github/workflows/run_precommit.yml | 15 ++++++ .github/workflows/update_precommit_hooks.yml | 48 ++++++++++++++++++++ Makefile | 4 +- requirements.txt | 1 - 5 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/run_precommit.yml create mode 100644 .github/workflows/update_precommit_hooks.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b7843a1..b1bd199 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,4 +6,4 @@ updates: - package-ecosystem: github-actions directory: / schedule: - interval: weekly + interval: monthly diff --git a/.github/workflows/run_precommit.yml b/.github/workflows/run_precommit.yml new file mode 100644 index 0000000..6b7f13c --- /dev/null +++ b/.github/workflows/run_precommit.yml @@ -0,0 +1,15 @@ +--- +name: pre-commit + +on: + pull_request: + push: + branches: [main] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + - uses: pre-commit/action@v3.0.1 diff --git a/.github/workflows/update_precommit_hooks.yml b/.github/workflows/update_precommit_hooks.yml new file mode 100644 index 0000000..3204412 --- /dev/null +++ b/.github/workflows/update_precommit_hooks.yml @@ -0,0 +1,48 @@ +--- +name: Update precommit hooks + + +on: + +# Uses the cron schedule for github actions +# +# https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#scheduled-events +# +# ┌───────────── minute (0 - 59) +# │ ┌───────────── hour (0 - 23) +# │ │ ┌───────────── day of the month (1 - 31) +# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) +# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) +# │ │ │ │ │ +# │ │ │ │ │ +# │ │ │ │ │ +# * * * * * + schedule: + - cron: 0 0 * * 1 # every monday + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + update_precommit_hooks: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install pre-commit + run: pip install pre-commit + - name: Update pre-commit hooks + run: pre-commit autoupdate + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + commit-message: pre-commit hooks auto-update + base: main + token: ${{ secrets.GITHUB_TOKEN }} + delete-branch: true + title: '[BOT] update pre-commit hooks' + body: update pre-commit hooks diff --git a/Makefile b/Makefile index b1f39d1..c24ba46 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,9 @@ manual: ## create pdf of the doc .PHONY: lint coverage lint: ## lint and checks matlab code - mh_style --fix && mh_metric --ci && mh_lint + pip install pre-commit + pre-commit install + pre-commit run -a coverage: run_tests.m ## runs tests and display coverage $(MATLAB) $(MATLAB_ARG) -r "run_tests; exit()" diff --git a/requirements.txt b/requirements.txt index 2ba0e70..94d14cc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ # linting -miss_hit pre-commit # doc From 0841120601c2575500f70f7e0ff63e51d017fc39 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 10 Jul 2024 02:20:45 +0200 Subject: [PATCH 2/5] Update .github/workflows/update_precommit_hooks.yml Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- .github/workflows/update_precommit_hooks.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update_precommit_hooks.yml b/.github/workflows/update_precommit_hooks.yml index 3204412..1d2bdb8 100644 --- a/.github/workflows/update_precommit_hooks.yml +++ b/.github/workflows/update_precommit_hooks.yml @@ -18,7 +18,8 @@ on: # │ │ │ │ │ # * * * * * schedule: - - cron: 0 0 * * 1 # every monday + - cron: '0 0 * * 1' + timezone: 'Etc/UTC' # Allows you to run this workflow manually from the Actions tab workflow_dispatch: From 9d033f703731f64afe8edda5089e63d1b527d447 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2024 00:21:47 +0000 Subject: [PATCH 3/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/workflows/update_precommit_hooks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update_precommit_hooks.yml b/.github/workflows/update_precommit_hooks.yml index 1d2bdb8..b215afa 100644 --- a/.github/workflows/update_precommit_hooks.yml +++ b/.github/workflows/update_precommit_hooks.yml @@ -18,8 +18,8 @@ on: # │ │ │ │ │ # * * * * * schedule: - - cron: '0 0 * * 1' - timezone: 'Etc/UTC' + - cron: 0 0 * * 1 + timezone: Etc/UTC # Allows you to run this workflow manually from the Actions tab workflow_dispatch: From 29f05f328297bb68e09ad473cc0fae2cb156c72a Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 10 Jul 2024 02:23:56 +0200 Subject: [PATCH 4/5] change yml formatting --- .github/dependabot.yml | 8 +- .../workflows/matlab_test_and_coverage.yml | 98 ++++++++-------- .../workflows/octave_test_and_coverage.yml | 52 ++++----- .github/workflows/run_precommit.yml | 18 +-- .github/workflows/update_precommit_hooks.yml | 51 +++++---- .github/workflows/validate_cff.yml | 52 ++++----- .pre-commit-config.yaml | 106 +++++++++--------- .readthedocs.yml | 18 +-- binder/environment.yml | 10 +- 9 files changed, 206 insertions(+), 207 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b1bd199..5ab0ddf 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,7 +3,7 @@ # https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file version: 2 updates: -- package-ecosystem: github-actions - directory: / - schedule: - interval: monthly +- package-ecosystem: github-actions + directory: / + schedule: + interval: monthly diff --git a/.github/workflows/matlab_test_and_coverage.yml b/.github/workflows/matlab_test_and_coverage.yml index e85e905..e8272bf 100644 --- a/.github/workflows/matlab_test_and_coverage.yml +++ b/.github/workflows/matlab_test_and_coverage.yml @@ -11,64 +11,64 @@ name: 'MATLAB: test and coverage' # If tests pass, uploads coverage to codecov on: - push: - branches: [main] - pull_request: - branches: ['*'] + push: + branches: [main] + pull_request: + branches: ['*'] jobs: - matlab_tests: + matlab_tests: - strategy: - matrix: - os: [ubuntu-latest, windows-latest] - version: [R2021a, R2023b] - include: - - os: macos-latest - version: R2023b - fail-fast: false # Don't cancel all jobs if one fails + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + version: [R2021a, R2023b] + include: + - os: macos-latest + version: R2023b + fail-fast: false # Don't cancel all jobs if one fails - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.os }} - steps: - - name: Install MATLAB - uses: matlab-actions/setup-matlab@v2.2.0 - with: - release: ${{ matrix.version }} + steps: + - name: Install MATLAB + uses: matlab-actions/setup-matlab@v2.2.0 + with: + release: ${{ matrix.version }} - - uses: actions/checkout@v4 - with: - submodules: true - fetch-depth: 1 + - uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 1 - - name: Install Moxunit and MOcov - run: | - git clone https://github.com/MOxUnit/MOxUnit.git --depth 1 - git clone https://github.com/MOcov/MOcov.git --depth 1 + - name: Install Moxunit and MOcov + run: | + git clone https://github.com/MOxUnit/MOxUnit.git --depth 1 + git clone https://github.com/MOcov/MOcov.git --depth 1 - - name: Run tests - uses: matlab-actions/run-command@v2.1.1 - with: - command: cd(fullfile(getenv('GITHUB_WORKSPACE'), '.github', 'workflows')); run run_tests_ci; + - name: Run tests + uses: matlab-actions/run-command@v2.1.1 + with: + command: cd(fullfile(getenv('GITHUB_WORKSPACE'), '.github', 'workflows')); run run_tests_ci; - - name: Check logs unix - if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' - run: grep -q 0 test_report.log || { echo "Some tests failed. Check the 'Run tests' step to know which ones." >&2; exit 1; } - - name: Check logs windows - if: matrix.os == 'windows-latest' - run: | - if (-not (Get-Content test_report.log | Select-String -Pattern "0")) { - throw "Some tests failed. Check the 'Run tests' step to know which ones." - } + - name: Check logs unix + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' + run: grep -q 0 test_report.log || { echo "Some tests failed. Check the 'Run tests' step to know which ones." >&2; exit 1; } + - name: Check logs windows + if: matrix.os == 'windows-latest' + run: | + if (-not (Get-Content test_report.log | Select-String -Pattern "0")) { + throw "Some tests failed. Check the 'Run tests' step to know which ones." + } - - name: Code coverage - if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' + - name: Code coverage + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' # no coverage on windows as long as MOcov does not support it # see https://github.com/MOcov/MOcov/issues/28 - uses: codecov/codecov-action@v4 - with: - file: coverage.xml # optional - flags: ${{ matrix.os }}_matlab-${{ matrix.version }} - name: codecov-umbrella # optional - fail_ci_if_error: false # optional (default = false) - token: ${{ secrets.CODECOV_TOKEN }} + uses: codecov/codecov-action@v4 + with: + file: coverage.xml # optional + flags: ${{ matrix.os }}_matlab-${{ matrix.version }} + name: codecov-umbrella # optional + fail_ci_if_error: false # optional (default = false) + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/octave_test_and_coverage.yml b/.github/workflows/octave_test_and_coverage.yml index 0cd5728..4bac5c4 100644 --- a/.github/workflows/octave_test_and_coverage.yml +++ b/.github/workflows/octave_test_and_coverage.yml @@ -2,34 +2,34 @@ name: 'Octave: test and coverage' on: - push: - branches: [main] - pull_request: - branches: ['*'] + push: + branches: [main] + pull_request: + branches: ['*'] jobs: - build: - runs-on: ubuntu-latest + build: + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true - fetch-depth: 1 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 1 - - name: MOxUnit Action - uses: joergbrech/moxunit-action@v1.3.0 - with: - tests: tests - src: src - with_coverage: true - cover_xml_file: coverage.xml + - name: MOxUnit Action + uses: joergbrech/moxunit-action@v1.3.0 + with: + tests: tests + src: src + with_coverage: true + cover_xml_file: coverage.xml - - name: Code coverage - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos - file: coverage.xml # optional - flags: octave # optional - name: codecov-umbrella # optional - fail_ci_if_error: false # optional (default = false) + - name: Code coverage + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos + file: coverage.xml # optional + flags: octave # optional + name: codecov-umbrella # optional + fail_ci_if_error: false # optional (default = false) diff --git a/.github/workflows/run_precommit.yml b/.github/workflows/run_precommit.yml index 6b7f13c..e8b3e0d 100644 --- a/.github/workflows/run_precommit.yml +++ b/.github/workflows/run_precommit.yml @@ -2,14 +2,14 @@ name: pre-commit on: - pull_request: - push: - branches: [main] + pull_request: + push: + branches: [main] jobs: - pre-commit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - - uses: pre-commit/action@v3.0.1 + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + - uses: pre-commit/action@v3.0.1 diff --git a/.github/workflows/update_precommit_hooks.yml b/.github/workflows/update_precommit_hooks.yml index b215afa..3ba37af 100644 --- a/.github/workflows/update_precommit_hooks.yml +++ b/.github/workflows/update_precommit_hooks.yml @@ -17,33 +17,32 @@ on: # │ │ │ │ │ # │ │ │ │ │ # * * * * * - schedule: - - cron: 0 0 * * 1 - timezone: Etc/UTC + schedule: + - cron: 0 0 * * 1 # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: + workflow_dispatch: jobs: - update_precommit_hooks: - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - name: Install pre-commit - run: pip install pre-commit - - name: Update pre-commit hooks - run: pre-commit autoupdate - - name: Create Pull Request - uses: peter-evans/create-pull-request@v6 - with: - commit-message: pre-commit hooks auto-update - base: main - token: ${{ secrets.GITHUB_TOKEN }} - delete-branch: true - title: '[BOT] update pre-commit hooks' - body: update pre-commit hooks + update_precommit_hooks: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install pre-commit + run: pip install pre-commit + - name: Update pre-commit hooks + run: pre-commit autoupdate + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + commit-message: pre-commit hooks auto-update + base: main + token: ${{ secrets.GITHUB_TOKEN }} + delete-branch: true + title: '[BOT] update pre-commit hooks' + body: update pre-commit hooks diff --git a/.github/workflows/validate_cff.yml b/.github/workflows/validate_cff.yml index e310d39..bd7e0cb 100644 --- a/.github/workflows/validate_cff.yml +++ b/.github/workflows/validate_cff.yml @@ -2,38 +2,38 @@ name: validate CITATION.cff on: - push: - branches: ['*'] - paths: - - CITATION.cff - - .github/workflows/validate_cff.yml - pull_request: - branches: ['*'] - paths: - - CITATION.cff - - .github/workflows/validate_cff.yml + push: + branches: ['*'] + paths: + - CITATION.cff + - .github/workflows/validate_cff.yml + pull_request: + branches: ['*'] + paths: + - CITATION.cff + - .github/workflows/validate_cff.yml jobs: - validate_cff: + validate_cff: - runs-on: ubuntu-latest + runs-on: ubuntu-latest - steps: + steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 1 + - uses: actions/checkout@v4 + with: + fetch-depth: 1 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' - - name: Install dependencies - run: | - python -m pip install --upgrade pip setuptools - pip3 install cffconvert + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools + pip3 install cffconvert - - name: Validate CITATION.cff - run: cffconvert --validate + - name: Validate CITATION.cff + run: cffconvert --validate diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9bffa93..390d9bd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,56 +5,56 @@ repos: -- repo: local - - hooks: - - - id: mh_version - name: mh_version - entry: mh_style - args: [-v] - verbose: true - language: python - additional_dependencies: [miss_hit_core] - - - id: mh_style - name: mh_style - entry: mh_style - args: [--process-slx, --fix] - files: ^(.*\.(m|slx))$ - language: python - additional_dependencies: [miss_hit_core] - - - id: mh_metric - name: mh_metric - entry: mh_metric - args: [--ci] - files: ^(.*\.(m|slx))$ - language: python - additional_dependencies: [miss_hit_core] - - - id: mh_lint - name: mh_lint - entry: mh_lint - files: ^(.*\.(m|slx))$ - language: python - additional_dependencies: [miss_hit] - -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-added-large-files - -- repo: https://github.com/codespell-project/codespell - rev: v2.3.0 - hooks: - - id: codespell - -- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt - rev: 0.2.3 - hooks: - - id: yamlfmt - args: [--mapping, '2', --sequence, '2', --offset, '0'] +- repo: local + + hooks: + + - id: mh_version + name: mh_version + entry: mh_style + args: [-v] + verbose: true + language: python + additional_dependencies: [miss_hit_core] + + - id: mh_style + name: mh_style + entry: mh_style + args: [--process-slx, --fix] + files: ^(.*\.(m|slx))$ + language: python + additional_dependencies: [miss_hit_core] + + - id: mh_metric + name: mh_metric + entry: mh_metric + args: [--ci] + files: ^(.*\.(m|slx))$ + language: python + additional_dependencies: [miss_hit_core] + + - id: mh_lint + name: mh_lint + entry: mh_lint + files: ^(.*\.(m|slx))$ + language: python + additional_dependencies: [miss_hit] + +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + +- repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + +- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt + rev: 0.2.3 + hooks: + - id: yamlfmt + args: [--mapping, '4', --sequence, '4', --offset, '0'] diff --git a/.readthedocs.yml b/.readthedocs.yml index 024d283..a0b2a7b 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -6,21 +6,21 @@ version: 2 build: - os: ubuntu-22.04 - tools: - python: '3.12' + os: ubuntu-22.04 + tools: + python: '3.12' # Build documentation in the docs/ directory with Sphinx sphinx: - configuration: docs/source/conf.py - builder: html - fail_on_warning: true + configuration: docs/source/conf.py + builder: html + fail_on_warning: true # Optionally build your docs in additional formats such as PDF formats: -- pdf +- pdf # Optionally set the version of Python and requirements required to build your docs python: - install: - - requirements: requirements.txt + install: + - requirements: requirements.txt diff --git a/binder/environment.yml b/binder/environment.yml index 181d2c2..cce40d7 100644 --- a/binder/environment.yml +++ b/binder/environment.yml @@ -1,11 +1,11 @@ --- channels: -- default -- conda-forge +- default +- conda-forge dependencies: -- octave_kernel -- texinfo -- jupyterlab +- octave_kernel +- texinfo +- jupyterlab From 952fd124828dc2690320fe3d201442f6af7297b8 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 10 Jul 2024 02:25:33 +0200 Subject: [PATCH 5/5] cancel previous test runs --- .github/workflows/matlab_test_and_coverage.yml | 5 +++++ .github/workflows/octave_test_and_coverage.yml | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/matlab_test_and_coverage.yml b/.github/workflows/matlab_test_and_coverage.yml index e8272bf..978ad9f 100644 --- a/.github/workflows/matlab_test_and_coverage.yml +++ b/.github/workflows/matlab_test_and_coverage.yml @@ -16,6 +16,11 @@ on: pull_request: branches: ['*'] +# cancel previous run on that branch +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: matlab_tests: diff --git a/.github/workflows/octave_test_and_coverage.yml b/.github/workflows/octave_test_and_coverage.yml index 4bac5c4..2da1cb8 100644 --- a/.github/workflows/octave_test_and_coverage.yml +++ b/.github/workflows/octave_test_and_coverage.yml @@ -7,6 +7,11 @@ on: pull_request: branches: ['*'] +# cancel previous run on that branch +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: runs-on: ubuntu-latest