ci: reduce usage and add Python 3.12 beta

With 3.12 beta, there are 7 Python versions to test, which is making the
test matrix too large. To reduce the amount of CI test runs that occur,
by default we will only run 2: the oldest and newest released Python
versions. To further reduce the CI test runs, we will eliminate CI runs
when a branch is pushed (only main will be tested).

The "ci" action becomes a reusable workflow, which gets called by other
possible workflows:

1. pull_request.yml: On pull request, only the 2 default Python versions
   are tested.  The "test-all-python-versions" label can be applied to
   pull requests to override this.
2. push.yml: On push to main, all Python versions are tested.
3. vmtest-build.yml: After the vmtest kernels are built
4. On manual request: the user has the option to specify

Signed-off-by: Stephen Brennan <stephen@brennan.io>
This commit is contained in:
Stephen Brennan 2023-06-01 13:45:15 -07:00 committed by Omar Sandoval
parent cff9b6185c
commit e9141fa396
4 changed files with 52 additions and 2 deletions

View File

@ -1,6 +1,20 @@
name: CI
on: [push, pull_request]
on:
workflow_dispatch:
inputs:
test_all_python_versions:
description: "Run tests on all Python versions"
type: boolean
default: false
required: true
workflow_call:
inputs:
test_all_python_versions:
description: "Run tests on all Python versions"
type: boolean
default: false
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@ -13,7 +27,9 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ['3.11', '3.10', '3.9', '3.8', '3.7', '3.6']
python-version: ${{ inputs.test_all_python_versions
&& fromJSON('["3.12", "3.11", "3.10", "3.9", "3.8", "3.7", "3.6"]')
|| fromJSON('["3.11", "3.6"]')}}
cc: [gcc, clang]
fail-fast: false
env:
@ -25,6 +41,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install dependencies
run: |
sudo apt-get update

16
.github/workflows/pull_request.yml vendored Normal file
View File

@ -0,0 +1,16 @@
name: Pull Request CI
on:
pull_request:
types:
- opened
- synchronize
- reopened
- labeled
jobs:
test:
uses: ./.github/workflows/ci.yml
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'test-all-python-versions' }}
with:
test_all_python_versions: ${{ contains(github.event.pull_request.labels.*.name, 'test-all-python-versions') }}

12
.github/workflows/push.yml vendored Normal file
View File

@ -0,0 +1,12 @@
name: Main Branch Push CI
on:
push:
branches:
- main
jobs:
test:
uses: ./.github/workflows/ci.yml
with:
test_all_python_versions: true

View File

@ -36,3 +36,8 @@ jobs:
name: kernel-build-logs
path: build/vmtest/kbuild/*.log
if-no-files-found: ignore
test:
needs: build
uses: ./.github/workflows/ci.yml
with:
test_all_python_versions: true