Skip to content

Commit

Permalink
GHA update (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Dec 17, 2022
1 parent 40fa920 commit 21ddbcc
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 57 deletions.
19 changes: 6 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,26 @@ jobs:
env:
FORCE_COLOR: 1
PY_COLORS: 1
TOXENV: packaging
TOXENV: pkg
TOX_PARALLEL_NO_SPINNER: 1

steps:
- name: Switch to using Python 3.8 by default
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install tox
run: >-
python3 -m
pip install
--user
tox
run: python3 -m pip install --user tox

- name: Check out src from Git
uses: actions/checkout@v3
with:
fetch-depth: 0 # needed by setuptools-scm

- name: Build dists
run: python -m tox
- name: Publish to test.pypi.org
if: >- # "create" workflows run separately from "push" & "pull_request"
github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.testpypi_password }}
repository_url: https://test.pypi.org/legacy/

- name: Publish to pypi.org
if: >- # "create" workflows run separately from "push" & "pull_request"
github.event_name == 'release'
Expand Down
90 changes: 50 additions & 40 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,28 @@ jobs:
python-version:
- 3.8
os:
- ubuntu-latest
- ubuntu-22.04
env:
- TOXENV: lint
- TOXENV: pkg
steps:
- uses: actions/checkout@master

- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: set PY_SHA256
run: echo "PY_SHA256=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV

- name: Pre-commit cache
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-${{ env.PY_SHA256 }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('tox.ini') }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('.pre-commit-config.yaml') }}-${{ hashFiles('pytest.ini') }}

- name: Pip cache
uses: actions/cache@v3
with:
Expand All @@ -43,16 +48,21 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install tox
run: python -m pip install --upgrade tox

- name: Log installed dists
run: python -m pip freeze --all

- name: Initialize tox envs
run: python -m tox --notest --skip-missing-interpreters false -vv
env: ${{ matrix.env }}

- name: Test with tox
run: python -m tox
env: ${{ matrix.env }}

- name: Archive logs
uses: actions/upload-artifact@v3
with:
Expand All @@ -61,67 +71,66 @@ jobs:

alpine:
name: alpine
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v1
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Run docker build
run: docker build .

unit:
name: py${{ matrix.python-version }}@${{ matrix.os }}
runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
strategy:
# fail-fast: false
# max-parallel: 5
# The matrix testing goal is to cover the *most likely* environments
# which are expected to be used by users in production. Avoid adding a
# combination unless there are good reasons to test it, like having
# proof that we failed to catch a bug by not running it. Using
# distribution should be prefferred instead of custom builds.
matrix:
os:
# https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
- ubuntu-latest # 18.04
# - windows-latest
# - windows-2016
python-version:
- "3.8"
- "3.9"
- "3.10"
include:
- os: ubuntu-latest
- name: py38
os: ubuntu-22.04
python-version: "3.8"
tox_env: py38
- name: py38 (macos)
os: macOS-latest
python-version: "3.8"
tox_env: py38
- os: ubuntu-latest
- name: py39
os: ubuntu-22.04
python-version: "3.9"
tox_env: py39
- os: ubuntu-latest
- name: py310
os: ubuntu-22.04
python-version: "3.10"
tox_env: py310
- os: ubuntu-latest
- name: py311
os: ubuntu-22.04
python-version: "3.11"
tox_env: py311
- os: macOS-latest
python-version: "3.8"
tox_env: py38
- os: macOS-latest
- name: py311 (macos)
os: macOS-latest
python-version: "3.11"
tox_env: py311
- name: py312
os: ubuntu-22.04
python-version: "3.12-dev"
tox_env: py312
steps:
- uses: actions/checkout@master
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- uses: actions/checkout@main
with:
fetch-depth: 0

- name: Set up stock Python ${{ matrix.python-version }} from GitHub
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Log the currently selected Python version info (${{ matrix.python-version }})
run: |
python --version --version
which python
- name: Pip cache
uses: actions/cache@v3
with:
Expand All @@ -130,20 +139,21 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install tox
run: |
python -m pip install -U pip
pip install tox
- name: Run tox -e ${{ matrix.tox_env }}
run: tox -e ${{ matrix.tox_env }}
- name: Run tox run -e ${{ matrix.tox_env }}
run: tox run -e ${{ matrix.tox_env }}

check: # This job does nothing and is only used for the branch protection
if: always()
needs:
- alpine
- linters
- unit
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
Expand Down
7 changes: 3 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
[tox]
minversion = 3.9.0
minversion = 4.0
envlist =
lint
packaging
pkg
deps
py

isolated_build = True

requires =
# 2020-resolver
pip >= 2.20.3
tox>=4.0.12

[testenv]
usedevelop = True
Expand Down

0 comments on commit 21ddbcc

Please sign in to comment.