Skip to content

Commit

Permalink
fix: GitHub Action can now be used on ubuntu-18.04 runner (#606)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
mayeut committed May 10, 2022
1 parent f12fb34 commit 6430a34
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 2 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 28 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 6430a34

Please sign in to comment.