Browse Source

fix: GitHub Action can now be used on ubuntu-18.04 runner (#606)

* chore: add tests for the GitHub Action

* fix: GitHub Action can be used on ubuntu-18.04

Always install nox with python3.10 in order to allow
using the action with an ubuntu-18.04 runner.
pull/601/head
Matthieu Darbois 2 months ago committed by GitHub
parent
commit
6430a3481b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      .github/workflows/action.yml
  2. 3
      action.yml
  3. 28
      noxfile.py

22
.github/workflows/action.yml

@ -0,0 +1,22 @@
name: Action
on:
push:
branches:
- 'main'
- '**action**'
pull_request:
paths:
- '.github/workflows/action.yml'
- 'action.yml'
env:
FORCE_COLOR: "1"
jobs:
action-default-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, windows-2019, windows-2022, macos-10.15, macos-11, macos-12]
steps:
- uses: actions/checkout@v3
- uses: ./
- run: nox --non-interactive --error-on-missing-interpreter --session github_actions_default_tests

3
action.yml

@ -31,5 +31,6 @@ runs:
python-version: "3.10"
- name: "Install nox"
run: pipx install '${{ github.action_path }}'
# --python "$(which python)" => always use the last setup-python version to install nox.
run: pipx install --python "$(which python)" '${{ github.action_path }}'
shell: bash

28
noxfile.py

@ -105,3 +105,31 @@ def docs(session: nox.Session) -> None:
sphinx_args.insert(0, "--open-browser")
session.run(sphinx_cmd, *sphinx_args)
# The following sessions are only to be run in CI to check the nox GHA action
def _check_python_version(session: nox.Session) -> None:
if session.python.startswith("pypy"):
python_version = session.python[4:]
implementation = "pypy"
else:
python_version = session.python
implementation = "cpython"
session.run(
"python",
"-c",
"import sys; assert '.'.join(str(v) for v in sys.version_info[:2]) =="
f" '{python_version}'",
)
if python_version[:2] != "2.":
session.run(
"python",
"-c",
f"import sys; assert sys.implementation.name == '{implementation}'",
)
@nox.session(python=["3.7", "3.8", "3.9", "3.10", "pypy3.7", "pypy3.8", "pypy3.9"])
def github_actions_default_tests(session: nox.Session) -> None:
"""Check default versions installed by the nox GHA Action"""
_check_python_version(session)

Loading…
Cancel
Save