From 354f8c6aff96aa163ec794bbe47f5e5e9797319a Mon Sep 17 00:00:00 2001 From: Kai Striega Date: Sun, 12 Nov 2023 11:37:49 +0800 Subject: [PATCH 1/5] MAINT: Define lint as own process This way the lint step is only run once, rather than for every possible combination of environments that is currently tested. --- .github/workflows/lint.yml | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..c140407 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,48 @@ +name: Lint + +on: + pull_request: + branches: + - main + +permissions: + contents: read # to fetch code (actions/checkout) + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + test_lint: + name: Lint + # If using act to run CI locally the github object does not exist and the usual skipping should not be enforced + if: "github.repository == 'scipy/scipy' || github.repository == ''" + runs-on: ubuntu-22.04 + strategy: + matrix: + python-version: ['3.11'] + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + submodules: recursive + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Python packages + run: | + python -m pip install --upgrade pip poetry + poetry env use ${{ matrix.python-version }} + poetry install --with=test --with=lint + + - name: Lint with flake8 + run: | + set -euo pipefail + # stop the build if there are Python syntax errors or undefined names + poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # The GitHub editor is 127 chars wide + poetry run flake8 . --ignore=F401,F403,W503,E226 --count --max-complexity=10 --max-line-length=127 --statistics \ No newline at end of file From 6007d86d143e591602da4c045a1b7609b1f0f358 Mon Sep 17 00:00:00 2001 From: Kai Striega Date: Sun, 12 Nov 2023 11:39:22 +0800 Subject: [PATCH 2/5] MAINT/TST: Remove lint section from main CI run This is no longer needed as we are running linting as a separate step --- .github/workflows/pythonpackage.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index a7cbe2a..ff67b07 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -19,13 +19,7 @@ jobs: run: | python -m pip install --upgrade pip poetry poetry env use ${{ matrix.python-version }} - poetry install --with=test --with=lint - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # The GitHub editor is 127 chars wide - poetry run flake8 . --ignore=F401,F403,W503,E226 --count --max-complexity=10 --max-line-length=127 --statistics + poetry install --with=test - name: Test with pytest run: | poetry run pytest From 9471e56605b03bb2f78c273e9bd6cf0c8b5e21ee Mon Sep 17 00:00:00 2001 From: Kai Striega Date: Sun, 12 Nov 2023 11:42:46 +0800 Subject: [PATCH 3/5] MAINT/TST: Add requirement to run linting on push/PR We want this to be noticed as early as possible --- .github/workflows/lint.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c140407..b93bdd1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,6 +4,8 @@ on: pull_request: branches: - main + - push + - pull_request permissions: contents: read # to fetch code (actions/checkout) From c4d0f519fd87c691df6c942bbd44b06d7ca686fe Mon Sep 17 00:00:00 2001 From: Kai Striega Date: Sun, 12 Nov 2023 11:45:34 +0800 Subject: [PATCH 4/5] MAINT/TST: Add requirement to run linting on push We want this to be noticed as early as possible --- .github/workflows/lint.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b93bdd1..13cd469 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,11 +1,12 @@ name: Lint on: + push: + branches: + - "*" pull_request: branches: - main - - push - - pull_request permissions: contents: read # to fetch code (actions/checkout) From 3a5b7ead48f7f3da54b3f645f14c49c3ce0962a6 Mon Sep 17 00:00:00 2001 From: Kai Striega Date: Sun, 12 Nov 2023 11:47:15 +0800 Subject: [PATCH 5/5] MAINT: Set correct repo check This was copied from SciPy's workflow, and I missed a check --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 13cd469..a819abb 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,7 +19,7 @@ jobs: test_lint: name: Lint # If using act to run CI locally the github object does not exist and the usual skipping should not be enforced - if: "github.repository == 'scipy/scipy' || github.repository == ''" + if: "github.repository == 'numpy/numpy-financial' || github.repository == ''" runs-on: ubuntu-22.04 strategy: matrix: