Skip to content

Commit b625032

Browse files
Remi-Gausourcery-ai[bot]pre-commit-ci[bot]
authored
[ENH] add pre-commit workflows (#44)
* add pre-commit workflows * Update .github/workflows/update_precommit_hooks.yml Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * change yml formatting * cancel previous test runs --------- Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent e8449fe commit b625032

11 files changed

+248
-174
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
44
version: 2
55
updates:
6-
- package-ecosystem: github-actions
7-
directory: /
8-
schedule:
9-
interval: weekly
6+
- package-ecosystem: github-actions
7+
directory: /
8+
schedule:
9+
interval: monthly

.github/workflows/matlab_test_and_coverage.yml

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,64 +11,69 @@ name: 'MATLAB: test and coverage'
1111
# If tests pass, uploads coverage to codecov
1212

1313
on:
14-
push:
15-
branches: [main]
16-
pull_request:
17-
branches: ['*']
14+
push:
15+
branches: [main]
16+
pull_request:
17+
branches: ['*']
18+
19+
# cancel previous run on that branch
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.ref }}
22+
cancel-in-progress: true
1823

1924
jobs:
20-
matlab_tests:
25+
matlab_tests:
2126

22-
strategy:
23-
matrix:
24-
os: [ubuntu-latest, windows-latest]
25-
version: [R2021a, R2023b]
26-
include:
27-
- os: macos-latest
28-
version: R2023b
29-
fail-fast: false # Don't cancel all jobs if one fails
27+
strategy:
28+
matrix:
29+
os: [ubuntu-latest, windows-latest]
30+
version: [R2021a, R2023b]
31+
include:
32+
- os: macos-latest
33+
version: R2023b
34+
fail-fast: false # Don't cancel all jobs if one fails
3035

31-
runs-on: ${{ matrix.os }}
36+
runs-on: ${{ matrix.os }}
3237

33-
steps:
34-
- name: Install MATLAB
35-
uses: matlab-actions/[email protected]
36-
with:
37-
release: ${{ matrix.version }}
38+
steps:
39+
- name: Install MATLAB
40+
uses: matlab-actions/[email protected]
41+
with:
42+
release: ${{ matrix.version }}
3843

39-
- uses: actions/checkout@v4
40-
with:
41-
submodules: true
42-
fetch-depth: 1
44+
- uses: actions/checkout@v4
45+
with:
46+
submodules: true
47+
fetch-depth: 1
4348

44-
- name: Install Moxunit and MOcov
45-
run: |
46-
git clone https://github.com/MOxUnit/MOxUnit.git --depth 1
47-
git clone https://github.com/MOcov/MOcov.git --depth 1
49+
- name: Install Moxunit and MOcov
50+
run: |
51+
git clone https://github.com/MOxUnit/MOxUnit.git --depth 1
52+
git clone https://github.com/MOcov/MOcov.git --depth 1
4853
49-
- name: Run tests
50-
uses: matlab-actions/[email protected]
51-
with:
52-
command: cd(fullfile(getenv('GITHUB_WORKSPACE'), '.github', 'workflows')); run run_tests_ci;
54+
- name: Run tests
55+
uses: matlab-actions/[email protected]
56+
with:
57+
command: cd(fullfile(getenv('GITHUB_WORKSPACE'), '.github', 'workflows')); run run_tests_ci;
5358

54-
- name: Check logs unix
55-
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
56-
run: grep -q 0 test_report.log || { echo "Some tests failed. Check the 'Run tests' step to know which ones." >&2; exit 1; }
57-
- name: Check logs windows
58-
if: matrix.os == 'windows-latest'
59-
run: |
60-
if (-not (Get-Content test_report.log | Select-String -Pattern "0")) {
61-
throw "Some tests failed. Check the 'Run tests' step to know which ones."
62-
}
59+
- name: Check logs unix
60+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
61+
run: grep -q 0 test_report.log || { echo "Some tests failed. Check the 'Run tests' step to know which ones." >&2; exit 1; }
62+
- name: Check logs windows
63+
if: matrix.os == 'windows-latest'
64+
run: |
65+
if (-not (Get-Content test_report.log | Select-String -Pattern "0")) {
66+
throw "Some tests failed. Check the 'Run tests' step to know which ones."
67+
}
6368
64-
- name: Code coverage
65-
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
69+
- name: Code coverage
70+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
6671
# no coverage on windows as long as MOcov does not support it
6772
# see https://github.com/MOcov/MOcov/issues/28
68-
uses: codecov/codecov-action@v4
69-
with:
70-
file: coverage.xml # optional
71-
flags: ${{ matrix.os }}_matlab-${{ matrix.version }}
72-
name: codecov-umbrella # optional
73-
fail_ci_if_error: false # optional (default = false)
74-
token: ${{ secrets.CODECOV_TOKEN }}
73+
uses: codecov/codecov-action@v4
74+
with:
75+
file: coverage.xml # optional
76+
flags: ${{ matrix.os }}_matlab-${{ matrix.version }}
77+
name: codecov-umbrella # optional
78+
fail_ci_if_error: false # optional (default = false)
79+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/octave_test_and_coverage.yml

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,39 @@
22
name: 'Octave: test and coverage'
33

44
on:
5-
push:
6-
branches: [main]
7-
pull_request:
8-
branches: ['*']
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: ['*']
9+
10+
# cancel previous run on that branch
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
914

1015
jobs:
11-
build:
12-
runs-on: ubuntu-latest
16+
build:
17+
runs-on: ubuntu-latest
1318

14-
steps:
15-
- uses: actions/checkout@v4
16-
with:
17-
submodules: true
18-
fetch-depth: 1
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
submodules: true
23+
fetch-depth: 1
1924

20-
- name: MOxUnit Action
21-
uses: joergbrech/[email protected]
22-
with:
23-
tests: tests
24-
src: src
25-
with_coverage: true
26-
cover_xml_file: coverage.xml
25+
- name: MOxUnit Action
26+
uses: joergbrech/[email protected]
27+
with:
28+
tests: tests
29+
src: src
30+
with_coverage: true
31+
cover_xml_file: coverage.xml
2732

28-
- name: Code coverage
29-
uses: codecov/codecov-action@v4
30-
with:
31-
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
32-
file: coverage.xml # optional
33-
flags: octave # optional
34-
name: codecov-umbrella # optional
35-
fail_ci_if_error: false # optional (default = false)
33+
- name: Code coverage
34+
uses: codecov/codecov-action@v4
35+
with:
36+
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
37+
file: coverage.xml # optional
38+
flags: octave # optional
39+
name: codecov-umbrella # optional
40+
fail_ci_if_error: false # optional (default = false)

.github/workflows/run_precommit.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
name: pre-commit
3+
4+
on:
5+
pull_request:
6+
push:
7+
branches: [main]
8+
9+
jobs:
10+
pre-commit:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-python@v5
15+
- uses: pre-commit/[email protected]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
name: Update precommit hooks
3+
4+
5+
on:
6+
7+
# Uses the cron schedule for github actions
8+
#
9+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#scheduled-events
10+
#
11+
# ┌───────────── minute (0 - 59)
12+
# │ ┌───────────── hour (0 - 23)
13+
# │ │ ┌───────────── day of the month (1 - 31)
14+
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
15+
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
16+
# │ │ │ │ │
17+
# │ │ │ │ │
18+
# │ │ │ │ │
19+
# * * * * *
20+
schedule:
21+
- cron: 0 0 * * 1
22+
23+
# Allows you to run this workflow manually from the Actions tab
24+
workflow_dispatch:
25+
26+
jobs:
27+
update_precommit_hooks:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout repo
31+
uses: actions/checkout@v4
32+
- name: Set up Python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: '3.12'
36+
- name: Install pre-commit
37+
run: pip install pre-commit
38+
- name: Update pre-commit hooks
39+
run: pre-commit autoupdate
40+
- name: Create Pull Request
41+
uses: peter-evans/create-pull-request@v6
42+
with:
43+
commit-message: pre-commit hooks auto-update
44+
base: main
45+
token: ${{ secrets.GITHUB_TOKEN }}
46+
delete-branch: true
47+
title: '[BOT] update pre-commit hooks'
48+
body: update pre-commit hooks

.github/workflows/validate_cff.yml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,38 @@
22
name: validate CITATION.cff
33

44
on:
5-
push:
6-
branches: ['*']
7-
paths:
8-
- CITATION.cff
9-
- .github/workflows/validate_cff.yml
10-
pull_request:
11-
branches: ['*']
12-
paths:
13-
- CITATION.cff
14-
- .github/workflows/validate_cff.yml
5+
push:
6+
branches: ['*']
7+
paths:
8+
- CITATION.cff
9+
- .github/workflows/validate_cff.yml
10+
pull_request:
11+
branches: ['*']
12+
paths:
13+
- CITATION.cff
14+
- .github/workflows/validate_cff.yml
1515

1616
jobs:
1717

18-
validate_cff:
18+
validate_cff:
1919

20-
runs-on: ubuntu-latest
20+
runs-on: ubuntu-latest
2121

22-
steps:
22+
steps:
2323

24-
- uses: actions/checkout@v4
25-
with:
26-
fetch-depth: 1
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 1
2727

28-
- name: Set up Python
29-
uses: actions/setup-python@v5
30-
with:
31-
python-version: '3.11'
28+
- name: Set up Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.11'
3232

33-
- name: Install dependencies
34-
run: |
35-
python -m pip install --upgrade pip setuptools
36-
pip3 install cffconvert
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install --upgrade pip setuptools
36+
pip3 install cffconvert
3737
38-
- name: Validate CITATION.cff
39-
run: cffconvert --validate
38+
- name: Validate CITATION.cff
39+
run: cffconvert --validate

0 commit comments

Comments
 (0)