From 777f6d019a473328f13120e7ba7f1565aa0d3cd3 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Fri, 26 Jan 2024 10:31:50 +0100 Subject: [PATCH 1/8] Add black-formatting action --- .github/workflows/black-formatting.yml | 28 ++++++++++++++++++++++++++ pyproject.toml | 7 ++++++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/black-formatting.yml diff --git a/.github/workflows/black-formatting.yml b/.github/workflows/black-formatting.yml new file mode 100644 index 000000000..74ebde85d --- /dev/null +++ b/.github/workflows/black-formatting.yml @@ -0,0 +1,28 @@ +name: Black formatting + +on: + workflow_dispatch: + schedule: + - cron: "0 12 * * 0" # Weekly at noon UTC on Sundays + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Check and apply black formatting + id: black-check + uses: psf/black@stable + with: + options: "--check --verbose" + continue-on-error: true + + - name: Create PR + uses: peter-evans/create-pull-request@v5 + with: + commit-message: black formatting + title: Black formatting + body: Reformatting code with black style + branch: black-formatting diff --git a/pyproject.toml b/pyproject.toml index 8d886720c..014dc13c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,7 +84,8 @@ docs = [ dev = [ "build", - "twine" + "twine", + "black" ] igorproio = ["igor2"] @@ -125,3 +126,7 @@ all = [ "zugbruecke>=0.2; sys_platform!='win32'", ] # we do not include 'stfio' in 'all' as it is not pip installable + + +[tool.black] +line-length = 120 From c5f2726153540d3480d824ff15e438faeb037370 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Fri, 26 Jan 2024 10:34:35 +0100 Subject: [PATCH 2/8] Only create PR if black failed --- .github/workflows/black-formatting.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/black-formatting.yml b/.github/workflows/black-formatting.yml index 74ebde85d..8514e31bd 100644 --- a/.github/workflows/black-formatting.yml +++ b/.github/workflows/black-formatting.yml @@ -21,6 +21,7 @@ jobs: - name: Create PR uses: peter-evans/create-pull-request@v5 + if : ${{ steps.black-check.outcome == 'failure' }} with: commit-message: black formatting title: Black formatting From e6a497da634425ecbd8066bb4ee82c106aa8365c Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Fri, 26 Jan 2024 11:17:39 +0100 Subject: [PATCH 3/8] Fix sonpy version and print python version in action --- .github/workflows/io-test.yml | 3 +++ pyproject.toml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/io-test.yml b/.github/workflows/io-test.yml index 66690722c..b6a73d1ef 100644 --- a/.github/workflows/io-test.yml +++ b/.github/workflows/io-test.yml @@ -69,6 +69,9 @@ jobs: ${{ runner.os }}-conda-env-${{ steps.dependencies.outputs.hash }}- ${{ runner.os }}-conda-env- + - name: Python version + run: python --version + - name: Install testing dependencies # testing environment is only created from yml if no cache was found # restore-key hits should result in `cache-hit` == 'false' diff --git a/pyproject.toml b/pyproject.toml index 014dc13c1..480a183d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,7 +62,7 @@ test = [ "coverage", "coveralls", "pillow", - "sonpy", + "sonpy;python_version<'3.10'", "pynwb", "probeinterface", "zugbruecke>=0.2", From 7ef588b21e6b8b7ff605118a4e81e02a2d356c8a Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Fri, 26 Jan 2024 11:48:48 +0100 Subject: [PATCH 4/8] Move python version after conda setup --- .github/workflows/io-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/io-test.yml b/.github/workflows/io-test.yml index b6a73d1ef..68909975e 100644 --- a/.github/workflows/io-test.yml +++ b/.github/workflows/io-test.yml @@ -69,9 +69,6 @@ jobs: ${{ runner.os }}-conda-env-${{ steps.dependencies.outputs.hash }}- ${{ runner.os }}-conda-env- - - name: Python version - run: python --version - - name: Install testing dependencies # testing environment is only created from yml if no cache was found # restore-key hits should result in `cache-hit` == 'false' @@ -84,6 +81,9 @@ jobs: git config --global user.email "neo_ci@fake_mail.com" git config --global user.name "neo CI" + - name: Python version + run: python --version + - name: Install neo including dependencies # installation with dependencies is only required if no cache was found # restore-key hits should result in `cache-hit` == 'false' From c6b9b6d369040d87756e6f97270ed79c835264af Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Fri, 26 Jan 2024 11:52:10 +0100 Subject: [PATCH 5/8] Fix python version --- .github/workflows/io-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/io-test.yml b/.github/workflows/io-test.yml index 68909975e..bf19ddfc7 100644 --- a/.github/workflows/io-test.yml +++ b/.github/workflows/io-test.yml @@ -46,7 +46,7 @@ jobs: key: ${{ runner.os }}-datasets-${{ steps.ephy_testing_data.outputs.dataset_hash }} restore-keys: ${{ runner.os }}-datasets- - - uses: conda-incubator/setup-miniconda@v2.2.0 + - uses: conda-incubator/setup-miniconda@v3 with: activate-environment: neo-test-env python-version: ${{ matrix.python-version }} From 86c403ea00c3f2d2e5622e1df3afd96e0c38afb9 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Fri, 26 Jan 2024 12:10:00 +0100 Subject: [PATCH 6/8] Use correct python version in environment --- .github/workflows/io-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/io-test.yml b/.github/workflows/io-test.yml index bf19ddfc7..79cca7f82 100644 --- a/.github/workflows/io-test.yml +++ b/.github/workflows/io-test.yml @@ -74,6 +74,7 @@ jobs: # restore-key hits should result in `cache-hit` == 'false' if: steps.cache-conda-env.outputs.cache-hit != 'true' run: | + conda install python=${{ matrix.python-version }} --yes conda env update --name neo-test-env --file environment_testing.yml --prune - name: Configure git From 948a09cda4fb50caa1482a40129897636491406a Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Fri, 26 Jan 2024 15:11:35 +0100 Subject: [PATCH 7/8] Print which python --- .github/workflows/io-test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/io-test.yml b/.github/workflows/io-test.yml index 79cca7f82..e903f4d60 100644 --- a/.github/workflows/io-test.yml +++ b/.github/workflows/io-test.yml @@ -83,7 +83,9 @@ jobs: git config --global user.name "neo CI" - name: Python version - run: python --version + run: | + which python + python --version - name: Install neo including dependencies # installation with dependencies is only required if no cache was found From eb25fecdc91da0182fe0387c4fb141fff7df8315 Mon Sep 17 00:00:00 2001 From: Alessio Buccino Date: Fri, 26 Jan 2024 15:18:49 +0100 Subject: [PATCH 8/8] Add quotations to python version --- .github/workflows/io-test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/io-test.yml b/.github/workflows/io-test.yml index e903f4d60..6f6009101 100644 --- a/.github/workflows/io-test.yml +++ b/.github/workflows/io-test.yml @@ -49,7 +49,7 @@ jobs: - uses: conda-incubator/setup-miniconda@v3 with: activate-environment: neo-test-env - python-version: ${{ matrix.python-version }} + python-version: "${{ matrix.python-version }}" - name: Get current dependencies hash id: dependencies @@ -74,7 +74,6 @@ jobs: # restore-key hits should result in `cache-hit` == 'false' if: steps.cache-conda-env.outputs.cache-hit != 'true' run: | - conda install python=${{ matrix.python-version }} --yes conda env update --name neo-test-env --file environment_testing.yml --prune - name: Configure git