Skip to content

Commit

Permalink
Merge pull request #1899 from webknjaz/maintenance/gha-reusable-ci-on…
Browse files Browse the repository at this point in the history
…-cron

👷 Deduplicate cron GHA through workflow reuse
  • Loading branch information
webknjaz authored Jul 4, 2023
2 parents 52698a4 + 9c87b0e commit 1db8ddd
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 116 deletions.
54 changes: 46 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ on:
branches:
- main
tags:
schedule:
# Run everyday at 03:53 UTC
- cron: 53 3 * * *
workflow_call:
inputs:
cpython-pip-version:
description: >-
A JSON string with pip versions
to test against under CPython.
required: true
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
Expand Down Expand Up @@ -48,15 +53,30 @@ jobs:
- "3.10"
- "3.9"
- "3.8"
pip-version:
- "latest"
- "previous"
pip-version: >-
${{
fromJSON(
github.job_workflow_sha
&& inputs.cpython-pip-version
|| '["latest", "previous"]'
)
}}
include:
- os: Ubuntu
python-version: 3.8
python-version: >-
${{
github.job_workflow_sha
&& '3.12-dev'
|| '3.8'
}}
pip-version: main
env:
TOXENV: pip${{ matrix.pip-version }}-coverage
TOXENV: >-
pip${{ matrix.pip-version }}${{
!github.job_workflow_sha
&& '-coverage'
|| ''
}}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }} from GitHub
Expand Down Expand Up @@ -95,6 +115,8 @@ jobs:
- name: Test pip ${{ matrix.pip-version }}
run: tox
- name: Upload coverage to Codecov
if: >-
!github.job_workflow_sha
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
Expand Down Expand Up @@ -132,6 +154,22 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
shell: bash
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Pip cache
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: >-
${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}-${{
hashFiles('pyproject.toml') }}-${{ hashFiles('tox.ini') }}-${{
hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install tox
run: pip install tox
- name: Prepare test environment
Expand Down
115 changes: 7 additions & 108 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,114 +2,13 @@ name: Cron

on:
schedule:
# Run every day at 00:00 UTC
- cron: 0 0 * * *
# Run everyday at 03:53 UTC
- cron: 53 3 * * *

jobs:
main:
name: ${{ matrix.os }} / ${{ matrix.python-version }} / ${{ matrix.pip-version }}
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os:
- Ubuntu
- Windows
- MacOS
python-version:
- "3.11"
- "3.10"
- "3.9"
- "3.8"
pip-version:
- main
include:
- os: Ubuntu
python-version: 3.12-dev
pip-version: main
env:
PY_COLORS: 1
TOXENV: pip${{ matrix.pip-version }}
TOX_PARALLEL_NO_SPINNER: 1
steps:
- uses: actions/checkout@main
- name: Set up Python ${{ matrix.python-version }} from GitHub
id: python-install
if: "!endsWith(matrix.python-version, '-dev')"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }} from deadsnakes
if: endsWith(matrix.python-version, '-dev')
uses: deadsnakes/[email protected]
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
shell: bash
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Pip cache
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: >-
${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}-${{
hashFiles('pyproject.toml') }}-${{ hashFiles('tox.ini') }}-${{
hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install test dependencies
run: python -m pip install -U tox virtualenv
- name: Prepare test environment
run: tox --notest -p auto --parallel-live
- name: Test pip ${{ matrix.pip-version }}
run: tox

pypy:
name: ${{ matrix.os }} / ${{ matrix.python-version }} / ${{ matrix.pip-version }}
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os:
- Ubuntu
- MacOS
- Windows
python-version:
- pypy-3.8
pip-version:
- latest
env:
PY_COLORS: 1
TOXENV: pip${{ matrix.pip-version }}
TOX_PARALLEL_NO_SPINNER: 1
steps:
- uses: actions/checkout@main
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
shell: bash
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Pip cache
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: >-
${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}-${{
hashFiles('pyproject.toml') }}-${{ hashFiles('tox.ini') }}-${{
hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install tox
run: pip install tox
- name: Prepare test environment
run: tox --notest -p auto --parallel-live
- name: Test pip ${{ matrix.pip-version }}
run: tox
name: CI
uses: ./.github/workflows/ci.yml
with:
cpython-pip-version: >-
["main", "latest", "previous"]

0 comments on commit 1db8ddd

Please sign in to comment.