From 3b56b1ca0fb2d2cca0c2dc8805385f9ad83877e7 Mon Sep 17 00:00:00 2001 From: John Hennig Date: Thu, 22 Dec 2022 16:43:34 +0100 Subject: [PATCH] Separate regularly scheduled test from commit-related tests. --- .github/workflows/report_coverage.yml | 14 +++--- .github/workflows/test_commit.yml | 67 +++++++++------------------ .github/workflows/test_scheduled.yml | 31 +++++++++++++ 3 files changed, 58 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/test_scheduled.yml diff --git a/.github/workflows/report_coverage.yml b/.github/workflows/report_coverage.yml index b73e05d..33dc51b 100644 --- a/.github/workflows/report_coverage.yml +++ b/.github/workflows/report_coverage.yml @@ -1,17 +1,17 @@ -name: Report coverage +# Report code coverage to Codecov. +name: Report coverage on: [push, workflow_dispatch] jobs: - # Report code coverage to Codecov. coverage: runs-on: ubuntu-latest strategy: matrix: - python: ["3.10", "3.11"] + python: ['3.10', '3.11'] steps: - name: Check out code. @@ -22,13 +22,11 @@ jobs: with: python-version: ${{ matrix.python }} - - name: Install package. - run: | - python -m pip install --upgrade pip - pip install --editable .[dev] + - name: Install project. + run: pip install --editable .[dev] - name: Measure code coverage. - run: pytest --cov --cov-report xml + run: pytest --cov --cov-report xml - name: Upload coverage report. uses: codecov/codecov-action@v3 diff --git a/.github/workflows/test_commit.yml b/.github/workflows/test_commit.yml index 9003b05..9f3df2d 100644 --- a/.github/workflows/test_commit.yml +++ b/.github/workflows/test_commit.yml @@ -1,77 +1,52 @@ -name: Test commit - -on: - push: - pull_request: - workflow_dispatch: - schedule: - # Every day at 1 AM - - cron: '0 1 * * *' - # Every wednesday at 1 AM - - cron: '0 1 * * 3' +# Test commit on all supported platforms and Python versions. +name: Test commit -jobs: +on: [push, pull_request, workflow_dispatch] - # Test on all supported Python versions and platforms - python_platform: +jobs: - name: ${{ matrix.python }} (${{ matrix.os }}) - if: github.event_name != 'schedule' || github.event.schedule == '0 1 * * 3' - runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.optional || false }} + # Test on all three platforms. + platform: strategy: - matrix: - os: ['ubuntu-latest'] - python: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"] - include: - - - os: windows-latest - python: '3.x' + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] - - os: macos-latest - python: '3.x' - - - python: '3.12-dev' - os: ubuntu-latest - optional: true + runs-on: ${{ matrix.os }} steps: - name: Check out code. uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python }}. + - name: Set up Python. uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python }} + python-version: '3.10' - - name: Install package. + - name: Install project. run: pip install .[dev] - name: Run tests. run: pytest - # Test against Flake8 main - flake8_main: - name: Flake8 main - if: github.event_name != 'schedule' || github.event.schedule == '0 1 * * *' - runs-on: ubuntu-latest + # Test on all supported Python versions. + Python: - # Uncomment to prevent failure from blocking - # continue-on-error: True + strategy: + matrix: + python: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11'] + + runs-on: ubuntu-latest steps: - name: Check out code. uses: actions/checkout@v3 - - name: Set up latest stable Python. + - name: Set up Python ${{ matrix.python }}. uses: actions/setup-python@v4 with: - python-version: "3.x" - - - name: Install flake8 main - run: pip install git+https://github.com/PyCQA/flake8.git + python-version: ${{ matrix.python }} - name: Install package. run: pip install .[dev] diff --git a/.github/workflows/test_scheduled.yml b/.github/workflows/test_scheduled.yml new file mode 100644 index 0000000..cc3bf6c --- /dev/null +++ b/.github/workflows/test_scheduled.yml @@ -0,0 +1,31 @@ +# Regular tests against the current Flake8 main branch. +name: Test nightly + +on: + schedule: + # Every day at 1 a.m. + - cron: '0 1 * * *' + +jobs: + + flake8_main: + + runs-on: ubuntu-latest + + steps: + - name: Check out code. + uses: actions/checkout@v3 + + - name: Set up latest stable Python. + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install current Flake8 main branch. + run: pip install git+https://github.com/PyCQA/flake8.git + + - name: Install project. + run: pip install .[dev] + + - name: Run tests. + run: pytest