From 154ba9ea9b871141f004421a51dbf1466ef02e5f Mon Sep 17 00:00:00 2001 From: Ben Orchard Date: Tue, 21 Feb 2023 16:13:42 +0000 Subject: [PATCH] CI: separate test & lint workflows --- .github/workflows/CI.yaml | 33 ++++++++++++-------------------- .github/workflows/linting.yaml | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/linting.yaml diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index fd276667..9d901589 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -1,9 +1,11 @@ name: CI + on: + # run on every push to main push: branches: - main - - main-new + # run on every push (not commit) to a PR, plus open/reopen pull_request: types: - synchronize @@ -11,27 +13,24 @@ on: - reopened jobs: - - # Run the black code checker - black: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: psf/black@stable - build: - # Build with multiple (recent) versions of python on latest OSs - name: Build (${{ matrix.python-version }} | ${{ matrix.os }}) + name: Build & test (${{ matrix.python-version }} | ${{ matrix.os }}) runs-on: ${{ matrix.os }} + strategy: + # continue testing other configurations even if a matrix job fails + fail-fast: false matrix: + # latest python on Win/Mac/Lin os: ["ubuntu-latest", "macos-latest", "windows-latest"] python-version: ["3.10"] + # test older python versions on Linux only include: - os: ubuntu-latest python-version: "3.9" - os: ubuntu-latest python-version: "3.8" + steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -42,21 +41,13 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install pylint>=2.16 mypy>=1.0 pydocstyle>=6.3 pytest + pip install mypy>=1.0 pytest python -m pip install . - - - name: Lint with pylint - if: always() - run: pylint --disable=all --enable=unused-import . - - name: mypy + - name: mypy if: always() run: mypy --strict . - - name: Check Docstrings - if: always() - run: pydocstyle --convention=numpy . - - name: Run tests if: always() run: pytest . diff --git a/.github/workflows/linting.yaml b/.github/workflows/linting.yaml new file mode 100644 index 00000000..89c65272 --- /dev/null +++ b/.github/workflows/linting.yaml @@ -0,0 +1,35 @@ +name: lint + +on: + # run on every push to main + push: + branches: + - main + # run on every push (not commit) to a PR, plus open/reopen + pull_request: + types: + - synchronize + - opened + - reopened + +jobs: + various: + name: various (Black, pylint, pydocstyle) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + - run: pip install black pylint pydocstyle + + # annotate each step with `if: always` to run all regardless + - name: Assert that code matches Black code style + if: always() + uses: psf/black@stable + - name: Lint with pylint + if: always() + run: pylint . + - name: Lint with pydocstyle + if: always() + run: pydocstyle --convention=numpy .