forked from shaka-project/shaka-streamer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Test PRs automatically across platforms and Python versions
- Loading branch information
1 parent
7bb46d4
commit a8bfa8b
Showing
4 changed files
with
115 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,8 @@ name: Build and Test PR | |
# | ||
# Can also be run manually for debugging purposes. | ||
on: | ||
# TODO: re-enable pull_request trigger | ||
#pull_request: | ||
# types: [opened, synchronize, reopened] | ||
pull_request_target: | ||
types: [opened, synchronize, reopened] | ||
workflow_dispatch: | ||
inputs: | ||
ref: | ||
|
@@ -21,38 +20,75 @@ defaults: | |
shell: bash | ||
|
||
jobs: | ||
# Configure the build matrix based on repo variables. The list of objects in | ||
# the build matrix contents can't be changed by conditionals, but it can be | ||
# computed by another job and deserialized. This uses | ||
# vars.ENABLE_SELF_HOSTED to determine the build matrix, based on the | ||
# metadata in build-matrix.json. | ||
matrix_config: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
MATRIX: ${{ steps.configure.outputs.MATRIX }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
path: repo-src | ||
ref: ${{ github.event.inputs.ref || github.event.pull_request.merge_commit_sha || github.event.push.head }} | ||
|
||
- name: Configure Build Matrix | ||
id: configure | ||
shell: node {0} | ||
run: | | ||
const fs = require('fs'); | ||
const enableDebug = "${{ vars.ENABLE_DEBUG }}" != ''; | ||
const enableSelfHosted = "${{ vars.ENABLE_SELF_HOSTED }}" != ''; | ||
// Use ENABLE_SELF_HOSTED to decide what the build matrix below | ||
// should include. | ||
const {hosted, selfHosted, pythonVersions} = require("${{ github.workspace }}/repo-src/build-matrix.json"); | ||
const devices = enableSelfHosted ? hosted.concat(selfHosted) : hosted; | ||
const matrix = []; | ||
for (const device of devices) { | ||
for (const version of pythonVersions) { | ||
// Clone device, add "python" field, push onto the matrix. | ||
matrix.push(Object.assign({}, device, {python_version: version})); | ||
} | ||
} | ||
// Output a JSON object consumed by the build matrix below. | ||
fs.appendFileSync( | ||
process.env['GITHUB_OUTPUT'], | ||
`MATRIX=${ JSON.stringify(matrix) }\n`); | ||
// Output the debug flag directly. | ||
fs.appendFileSync( | ||
process.env['GITHUB_OUTPUT'], | ||
`ENABLE_DEBUG=${ enableDebug }\n`); | ||
// Log the outputs, for the sake of debugging this script. | ||
console.log({enableDebug, enableSelfHosted, matrix}); | ||
build_and_test: | ||
needs: matrix_config | ||
strategy: | ||
# Let other matrix entries complete, so we have all results on failure | ||
# instead of just the first failure. | ||
fail-fast: false | ||
matrix: | ||
# TODO: enable arm64 | ||
os: ["ubuntu-latest", "macos-latest", "windows-latest"] | ||
# Our minimum supported version of Python is currently 3.6. | ||
python_version: ["3.6", "3.7", "3.8", "3.9"] | ||
include: | ||
- os: ubuntu-latest | ||
os_name: linux | ||
target_arch: x64 | ||
- os: macos-latest | ||
os_name: osx | ||
target_arch: x64 | ||
- os: windows-latest | ||
os_name: win | ||
target_arch: x64 | ||
include: ${{ fromJSON(needs.matrix_config.outputs.MATRIX) }} | ||
|
||
name: Build and test ${{ matrix.os_name }} ${{ matrix.target_arch }} Python ${{ matrix.python_version }} | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.inputs.ref || github.ref }} | ||
|
||
- name: Set Python version | ||
uses: actions/setup-python@v2 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python_version }} | ||
|
||
|
@@ -61,17 +97,16 @@ jobs: | |
|
||
- name: Install Python deps | ||
run: | | ||
python3 -m pip install --upgrade pyyaml sphinx flask mypy==0.812 wheel | ||
if [[ '${{ runner.os }}' == 'Windows' ]]; then | ||
python3 -m pip install --upgrade pywin32 | ||
fi | ||
python3 -m pip install -r requirements.txt | ||
python3 -m pip install -r optional_requirements.txt | ||
- name: Download binaries | ||
run: | | ||
# Fetch binaries locally instead of installing the release version of | ||
# the binary package. This lets us test changes to the binary package | ||
# before it is released. | ||
python3 binaries/build_wheels.py | ||
# In case of network flake, try it three times. This is arbitrary. | ||
python3 binaries/build_wheels.py || python3 binaries/build_wheels.py || python3 binaries/build_wheels.py | ||
if [[ '${{ runner.os }}' == 'Windows' ]]; then | ||
echo "PYTHONPATH=$GITHUB_WORKSPACE\\binaries;$PYTHONPATH" >> $GITHUB_ENV | ||
else | ||
|
@@ -93,6 +128,8 @@ jobs: | |
# Use the "spec" reporter for clearer logs in GitHub Actions | ||
$WRAPPER python3 run_end_to_end_tests.py --reporters spec | ||
#- name: Debug on failure | ||
# uses: mxschmitt/action-tmate@v3 | ||
# if: ${{ failure() }} | ||
- name: Debug on failure | ||
uses: mxschmitt/[email protected] | ||
with: | ||
limit-access-to-actor: true | ||
if: failure() && vars.ENABLE_DEBUG != '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"comment0": "The minimum supported version of Python is currently 3.9.", | ||
"pythonVersions": [ | ||
"3.9", | ||
"3.10", | ||
"3.11", | ||
"3.12" | ||
], | ||
|
||
"comment1": "runners hosted by GitHub, always enabled", | ||
"hosted": [ | ||
{ | ||
"os": "ubuntu-24.04", | ||
"os_name": "linux", | ||
"target_arch": "x64" | ||
}, | ||
{ | ||
"comment": "Explicit macOS version 13 is required for explicit x64 CPU.", | ||
"os": "macos-13", | ||
"os_name": "osx", | ||
"target_arch": "x64" | ||
}, | ||
{ | ||
"comment": "Latest macOS version is arm64 CPU.", | ||
"os": "macos-latest", | ||
"os_name": "osx", | ||
"target_arch": "arm64" | ||
}, | ||
{ | ||
"os": "windows-latest", | ||
"os_name": "win", | ||
"target_arch": "x64" | ||
} | ||
], | ||
|
||
"comment2": "runners hosted by the owner, enabled by the ENABLE_SELF_HOSTED variable being set on the repo", | ||
"selfHosted": [ | ||
{ | ||
"os": "self-hosted-linux-arm64", | ||
"os_name": "linux", | ||
"target_arch": "arm64" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
flask==3 | ||
mypy==1 | ||
setuptools>=75 | ||
sphinx==8 | ||
wheel>=0.44,<1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pyyaml==6 | ||
pywin32>=308; platform_system == "Windows" |