Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Shared CI Workflows #1771

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 50 additions & 75 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches:
- main
workflow_call:
outputs:
artifact-name:
description: "Name of the uploaded artifact; use for artifact retrieval."
value: ${{ jobs.package.outputs.artifact-name }}

env:
min_python_version: "3.7"
Expand All @@ -16,81 +20,53 @@ defaults:

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4.5.0
with:
python-version: "3.X"
- uses: pre-commit/action@v3.0.0
name: Pre-commit checks
uses: beeware/.github/.github/workflows/pre-commit-run.yml@main
with:
pre-commit-source: "./core[dev]"

towncrier:
runs-on: ubuntu-latest
steps:
# Fetch main branch for comparison, then check out current branch.
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4.5.0
with:
python-version: "3.X"
- name: Install dev dependencies
run: |
# We don't actually want to install toga-core;
# we just want the dev extras so we have a known version of tox
python -m pip install ./core[dev]
- name: Run towncrier check
run: tox -e towncrier-check
name: Check towncrier
uses: beeware/.github/.github/workflows/towncrier-run.yml@main
with:
tox-source: "./core[dev]"

package:
name: Python Package
uses: beeware/.github/.github/workflows/python-package-create.yml@main
with:
tox-source: "./core[dev]"
build-subdirectory: ${{ matrix.subdir }}
distribution-path: "*/dist/*"
strategy:
matrix:
subdir: ["android", "cocoa", "core", "demo", "dummy", "gtk", "iOS", "toga",
"web", "winforms"]
runs-on: ubuntu-latest
steps:
# Fetch all refs so setuptools_scm can generate the correct version number.
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4.5.0
with:
python-version: ${{ env.min_python_version }}
- name: Install dev dependencies
run: |
# We don't actually want to install toga-core;
# we just want the dev extras so we have a known version of tox
python -m pip install ./core[dev]
- name: Build wheels
run: tox -e package -- ${{ matrix.subdir }}
- uses: actions/upload-artifact@v3
with:
name: packages
# There will only be one dist directory for each matrix sub-job, but using a
# leading wildcard preserves the directory structure.
path: "*/dist/*"
if-no-files-found: error
subdir:
- "android"
- "cocoa"
- "core"
- "demo"
- "dummy"
- "gtk"
- "iOS"
- "toga"
- "web"
- "winforms"

core:
runs-on: ${{ matrix.platform }}-latest
needs: [pre-commit, towncrier, package]
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
platform: ['macos', 'ubuntu', 'windows']
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"]
platform: [ "macos", "ubuntu", "windows" ]
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev" ]
include:
- experimental: false

- python-version: "3.12-dev"
experimental: true

runs-on: ${{ matrix.platform }}-latest
continue-on-error: ${{ matrix.experimental }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3.3.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4.5.0
with:
Expand All @@ -101,9 +77,9 @@ jobs:
# we just want the dev extras so we have a known version of tox and coverage
python -m pip install ./core[dev]
- name: Get packages
uses: actions/download-artifact@v3
uses: actions/download-artifact@v3.0.2
with:
name: packages
name: ${{ needs.package.outputs.artifact-name }}
- name: Test
run: |
# The $(ls ...) shell expansion is done in the Github environment;
Expand All @@ -113,7 +89,7 @@ jobs:
cd core
mv .coverage .coverage.${{ matrix.platform }}.${{ matrix.python-version }}
- name: Store coverage data
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v3.1.2
with:
name: core-coverage-data
path: "core/.coverage.*"
Expand All @@ -124,7 +100,7 @@ jobs:
runs-on: ubuntu-latest
needs: core
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3.3.0
with:
fetch-depth: 0
- uses: actions/setup-python@v4.5.0
Expand All @@ -137,7 +113,7 @@ jobs:
# we just want the dev extras so we have a known version of coverage
python -m pip install ./core[dev]
- name: Retrieve coverage data
uses: actions/download-artifact@v3
uses: actions/download-artifact@v3.0.2
with:
name: core-coverage-data
path: core
Expand All @@ -148,17 +124,18 @@ jobs:
python -m coverage html --skip-covered --skip-empty
python -m coverage report --rcfile ../pyproject.toml # --fail-under=100
- name: Upload HTML report if check failed.
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v3.1.2
with:
name: html-coverage-report
path: core/htmlcov
if: ${{ failure() }}

backend:
needs: core
runs-on: ${{ matrix.runs-on }}
needs: [package, core]
strategy:
matrix:
backend: [android, cocoa, gtk, iOS, web, winforms]
backend: [ "android", "cocoa", "gtk", "iOS", "web", "winforms" ]
include:
- runs-on: ubuntu-latest
- python-version: "3.7" # Should be env.min_python_version (https://github.com/actions/runner/issues/480)
Expand All @@ -178,17 +155,16 @@ jobs:
# Py3.9 is the first Python version for which
# a wheel of pythonnet isn't available on PyPI.
python-version: "3.9"
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3.3.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4.5.0
with:
python-version: ${{ matrix.python-version }}
- name: Get packages
uses: actions/download-artifact@v3
uses: actions/download-artifact@v3.0.2
with:
name: packages
name: ${{ needs.package.outputs.artifact-name }}
- name: Install dev dependencies
run: |
${{ matrix.pre-command }}
Expand All @@ -203,11 +179,12 @@ jobs:
TOGA_INSTALL_COMMAND="python -m pip install ../$(ls core/dist/toga_core-*.whl)[dev] ../$(ls dummy/dist/toga_dummy-*.whl) ../$(ls ${{ matrix.backend }}/dist/toga_${{ matrix.backend }}-*.whl)" tox -e py-${{ matrix.backend }}

testbed:
runs-on: ${{ matrix.runs-on }}
needs: core
strategy:
fail-fast: false
matrix:
backend: ["macOS", "windows", "linux", "android", "iOS"]
backend: [ "macOS", "windows", "linux", "android", "iOS" ]
include:
- pre-command:
briefcase-run-prefix:
Expand All @@ -231,8 +208,6 @@ jobs:
- backend: android
runs-on: macos-12
briefcase-run-args: " -d '{\"avd\":\"beePhone\"}' --Xemulator=-no-window --Xemulator=-no-snapshot --Xemulator=-no-audio --Xemulator=-no-boot-anim --shutdown-on-exit"

runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v3.1.0
with:
Expand All @@ -250,8 +225,8 @@ jobs:
run: |
cd testbed
${{ matrix.briefcase-run-prefix }} briefcase run ${{ matrix.backend }} --test ${{ matrix.briefcase-run-args }}
- uses: actions/upload-artifact@v3
name: Upload logs
- name: Upload logs
uses: actions/upload-artifact@v3.1.2
if: failure()
with:
name: testbed-failure-logs-${{ matrix.backend }}
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ on:

jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
package: ["toga", "toga_android", "toga_cocoa", "toga_core", "toga_demo",
"toga_dummy", "toga_gtk", "toga_iOS", "toga_web", "toga_winforms"]
runs-on: ubuntu-latest
package:
- "toga"
- "toga_android"
- "toga_cocoa"
- "toga_core"
- "toga_demo"
- "toga_dummy"
- "toga_gtk"
- "toga_iOS"
- "toga_web"
- "toga_winforms"
steps:
- name: Get packages
uses: dsaltares/fetch-gh-release-asset@1.1.0
Expand All @@ -19,10 +28,12 @@ jobs:
file: ${{ github.event.repository.name }}.*
regex: true
target: packages/

- name: Extract ${{ matrix.package }}
run: |
mkdir dist
mv packages/$(echo ${{ matrix.package }} | sed 's/_/?/')-[0-9]* dist

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
31 changes: 23 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,48 @@ jobs:
- name: Set build variables
run: |
echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV

- name: Get packages
uses: actions/download-artifact@v3
uses: actions/download-artifact@v3.0.2
with:
name: packages
- uses: ncipollo/release-action@v1.12.0
name: ${{ needs.ci.outputs.artifact-name }}

- name: Create release
uses: ncipollo/release-action@v1.12.0
with:
name: ${{ env.VERSION }}
draft: true
artifacts: "*/dist/*"
artifactErrorsFailBuild: true

deploy-test:
name: Publish to TestPyPI
runs-on: ubuntu-latest
needs: release
strategy:
matrix:
package: ["toga", "toga_android", "toga_cocoa", "toga_core", "toga_demo",
"toga_dummy", "toga_gtk", "toga_iOS", "toga_web", "toga_winforms"]
runs-on: ubuntu-latest
package:
- "toga"
- "toga_android"
- "toga_cocoa"
- "toga_core"
- "toga_demo"
- "toga_dummy"
- "toga_gtk"
- "toga_iOS"
- "toga_web"
- "toga_winforms"
steps:
- name: Get packages
uses: actions/download-artifact@v3
uses: actions/download-artifact@v3.0.2
with:
name: packages
name: ${{ needs.ci.outputs.artifact-name }}

- name: Extract ${{ matrix.package }}
run: |
mkdir dist
mv */dist/$(echo ${{ matrix.package }} | sed 's/_/?/')-[0-9]* dist

- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
1 change: 1 addition & 0 deletions changes/1771.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated CI to use shared workflows from ``.github`` repository.