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

feat(action): do not depend on pipx in Nox action #768

Merged
merged 7 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
10 changes: 10 additions & 0 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ./
- run: nox --non-interactive --error-on-missing-interpreter --session github_actions_default_tests

action-all-tests:
runs-on: windows-latest
steps:
Expand All @@ -43,3 +44,12 @@ jobs:
with:
python-versions: "3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, pypy-2.7, pypy-3.7, pypy-3.8, pypy-3.9, pypy-3.10"
- run: nox --non-interactive --error-on-missing-interpreter --session github_actions_all_tests

action-macos14-tests:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: ./
with:
python-versions: "3.10, 3.11, 3.12, pypy-3.8, pypy-3.9, pypy-3.10"
- run: nox --non-interactive --error-on-missing-interpreter --session github_actions_macos_14
44 changes: 42 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,45 @@ runs:
allow-prereleases: true

- name: "Install nox"
run: pipx install --python "${{ steps.allpython.outputs.python-path }}" '${{ github.action_path }}'
shell: bash
run: |
import os
import shutil
import sys
import venv

from pathlib import Path
from subprocess import run


class EnvBuilder(venv.EnvBuilder):
def __init__(self):
super().__init__()

def setup_scripts(self, context):
pass

def post_setup(self, context):
super().post_setup(context)
self.bin_path = Path(context.env_exe).parent
run([sys.executable, "-m", "pip", "--python", context.env_exe, "install", r"${{ github.action_path }}"], check=True)


print("::group::Install nox")
nox_bin_path = Path(r"${{ runner.temp }}") / "nox"
if nox_bin_path.exists():
shutil.rmtree(nox_bin_path)
venv_path = Path(r"${{ runner.temp }}") / "nox-venv"
if venv_path.exists():
shutil.rmtree(venv_path)
builder = EnvBuilder()
builder.create(venv_path)
nox_path = [path for path in builder.bin_path.glob("nox*") if path.stem == "nox"][0]
nox_bin_path.mkdir()
try:
os.symlink(nox_path, nox_bin_path / nox_path.name)
except OSError:
shutil.copyfile(nox_path, nox_bin_path / nox_path.name)
with open(os.environ["GITHUB_PATH"], "at") as f:
f.write(f"{nox_bin_path}\n")
print("::endgroup::")
shell: "${{ steps.localpython.outputs.python-path }}" -u
henryiii marked this conversation as resolved.
Show resolved Hide resolved
17 changes: 16 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ def github_actions_default_tests(session: nox.Session) -> None:
_check_python_version(session)


# The following sessions are only to be run in CI to check the nox GHA action
@nox.session(
python=[
"3.7",
Expand All @@ -192,3 +191,19 @@ def github_actions_default_tests(session: nox.Session) -> None:
def github_actions_all_tests(session: nox.Session) -> None:
"""Check all versions installed by the nox GHA Action"""
_check_python_version(session)


@nox.session(
python=[
"3.10",
"3.11",
"3.12",
"pypy3.8",
"pypy3.9",
"pypy3.10",
]
)
def github_actions_macos_14(session: nox.Session) -> None:
"""Check default versions installed by the nox GHA Action"""
assert sys.version_info[:2] == (3, 11)
_check_python_version(session)
Loading