Created
February 3, 2023 06:33
-
-
Save andy5995/ee0b2a756dad1866a782e6431c432986 to your computer and use it in GitHub Desktop.
GitHub Actions Matrix example using containers
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
# From https://github.com/altendky/alqtendpy/blob/b375b1d9189f125828fdabbf2d329e5b1d04ff21/.github/workflows/ci.yml | |
name: CI | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- v* | |
pull_request: | |
branches: | |
- "*" | |
schedule: | |
# Daily at 07:13 | |
- cron: '13 7 * * *' | |
env: | |
QT_DEBUG_PLUGINS: 1 | |
jobs: | |
test: | |
name: ${{ matrix.task.name }} ${{ matrix.os.name }} ${{ matrix.python.name }} ${{ matrix.reactor.name }} | |
runs-on: ${{ matrix.os.runs-on }} | |
container: ${{ matrix.os.container[matrix.python.docker] }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- name: Linux | |
runs-on: ubuntu-latest | |
matrix: linux | |
container: | |
3.5: docker://python:3.5-buster | |
3.6: docker://python:3.6-buster | |
3.7: docker://python:3.7-buster | |
3.8: docker://python:3.8-buster | |
3.9: docker://python:3.9-buster | |
- name: Windows | |
runs-on: windows-latest | |
matrix: windows | |
- name: macOS | |
runs-on: macos-latest | |
matrix: macos | |
python: | |
- name: CPython 3.5 | |
tox: py35 | |
action: 3.5 | |
docker: 3.5 | |
matrix: 3.5 | |
implementation: cpython | |
major: 3 | |
- name: CPython 3.6 | |
tox: py36 | |
action: 3.6 | |
docker: 3.6 | |
matrix: 3.6 | |
implementation: cpython | |
major: 3 | |
- name: CPython 3.7 | |
tox: py37 | |
action: 3.7 | |
docker: 3.7 | |
matrix: 3.7 | |
implementation: cpython | |
major: 3 | |
- name: CPython 3.8 | |
tox: py38 | |
action: 3.8 | |
docker: 3.8 | |
matrix: 3.8 | |
implementation: cpython | |
major: 3 | |
- name: CPython 3.9 | |
tox: py39 | |
action: 3.9 | |
docker: 3.9 | |
matrix: 3.9 | |
implementation: cpython | |
major: 3 | |
task: | |
- name: Core | |
tox: core | |
- name: Twisted | |
tox: twisted | |
- name: asyncio | |
tox: asyncio | |
exclude: | |
- python: | |
matrix: 3.9 | |
- os: | |
matrix: windows | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up ${{ matrix.python.name }} | |
if: job.container == '' | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '${{ matrix.python.action }}.0-alpha - ${{ matrix.python.action }}.X' | |
architecture: x64 | |
- uses: twisted/python-info-action@v1.0.1 | |
- name: Install Linux Qt5 dependencies | |
if: matrix.os.matrix == 'linux' | |
run: | | |
apt-get update --yes | |
apt-get install --yes libgl1 libgl1-mesa-dev xvfb x11-utils libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 | |
- uses: altendky/QTBUG-88688-libxcb-util@v2 | |
if: matrix.os.matrix == 'linux' | |
- name: Install | |
run: | | |
pip install tox | |
- name: Test | |
run: | | |
tox -v -e "${{ matrix.python.tox }}-${{ matrix.task.tox }}" | |
- name: Codecov | |
run: | | |
tox -v -e codecov | |
tasks: | |
name: ${{ matrix.task.name }} ${{ matrix.os.name }} ${{ matrix.python.name }} | |
runs-on: ${{ matrix.os.runs-on }} | |
container: ${{ matrix.os.container[matrix.python.docker] }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- name: Linux | |
runs-on: ubuntu-latest | |
matrix: linux | |
container: | |
3.8: docker://python:3.8-buster | |
python: | |
- name: CPython 3.8 | |
tox: py38 | |
action: 3.8 | |
docker: 3.8 | |
implementation: cpython | |
major: 3 | |
task: | |
- name: Wheel | |
tox: wheel | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up ${{ matrix.python.name }} | |
if: job.container == '' | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '${{ matrix.python.action }}.0-alpha - ${{ matrix.python.action }}.X' | |
architecture: x64 | |
- uses: twisted/python-info-action@v1.0.1 | |
- name: Install Linux Qt5 dependencies | |
if: matrix.os.matrix == 'linux' | |
run: | | |
apt-get update --yes | |
apt-get install --yes libgl1 libgl1-mesa-dev xvfb x11-utils libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 | |
- uses: altendky/QTBUG-88688-libxcb-util@v2 | |
if: matrix.os.matrix == 'linux' | |
- name: Install | |
run: | | |
pip install tox | |
- name: Test | |
run: | | |
tox -v -e "${{ matrix.python.tox }}-${{ matrix.task.tox }}" | |
- name: Codecov | |
run: | | |
tox -v -e codecov | |
- name: Archive | |
uses: actions/upload-artifact@v2 | |
with: | |
name: artifacts | |
path: dist | |
maybe_publish: | |
name: Maybe Publish | |
runs-on: ubuntu-latest | |
container: docker://python:3.8-buster | |
needs: | |
- test | |
- tasks | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Download all wheels | |
uses: actions/download-artifact@v2 | |
with: | |
name: artifacts | |
path: dist | |
- name: Install Python packages | |
run: | | |
python -m venv venv | |
venv/bin/python -m pip install --upgrade pip setuptools twine | |
venv/bin/python -m pip install --upgrade twine | |
- name: Maybe publish | |
run: | | |
venv/bin/python twineontag.py | |
env: | |
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} | |
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} | |
all: | |
name: All | |
runs-on: ubuntu-latest | |
needs: | |
- test | |
- tasks | |
- maybe_publish | |
steps: | |
- name: This | |
shell: python | |
run: | | |
import this |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment