Skip to content

Commit

Permalink
Switch to Python 3.10 for tests, add Windows and macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
lkubb committed Sep 2, 2024
1 parent 6541e6b commit f821f46
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 82 deletions.
203 changes: 130 additions & 73 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
fetch-depth: 0
fetch-tags: true

- name: Set up Python 3.12
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.12
python-version: '3.10'

- name: Install Nox
run: |
Expand All @@ -40,77 +40,134 @@ jobs:
run: |
nox --force-color -e tests -- -vv tests/
# - name: Create CodeCov Flags
# if: always()
# id: codecov-flags
# run: |
# echo "flags=$(python -c "import sys; print('{},{},salt_{}'.format('${{ runner.os }}'.replace('-latest', ''), 'py{}{}'.format(*sys.version_info), '_'.join(str(v) for v in '${{ matrix.salt-version }}'.replace('==', '_').split('.'))))")" >> "$GITHUB_OUTPUT"

# - name: Upload Project Code Coverage
# if: always()
# continue-on-error: true
# shell: bash
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# REPORT_FLAGS: ${{ steps.codecov-flags.outputs.flags }},project
# REPORT_NAME: ${{ runner.os }}-Py${{ matrix.python-version }}-Salt${{ matrix.salt-version }}-project
# REPORT_PATH: artifacts/coverage-project.xml
# run: |
# if [ ! -f codecov.sh ]; then
# n=0
# until [ "$n" -ge 5 ]
# do
# if curl --max-time 30 -L https://codecov.io/bash --output codecov.sh; then
# break
# fi
# n=$((n+1))
# sleep 15
# done
# fi
# if [ -f codecov.sh ]; then
# n=0
# until [ "$n" -ge 5 ]
# do
# if bash codecov.sh -R $(pwd) -n "${REPORT_NAME}" -f "${REPORT_PATH}" -F "${REPORT_FLAGS}"; then
# break
# fi
# n=$((n+1))
# sleep 15
# done
# fi

# - name: Upload Tests Code Coverage
# if: always()
# continue-on-error: true
# shell: bash
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# REPORT_FLAGS: ${{ steps.codecov-flags.outputs.flags }},tests
# REPORT_NAME: ${{ runner.os }}-Py${{ matrix.python-version }}-Salt${{ matrix.salt-version }}-tests
# REPORT_PATH: artifacts/coverage-tests.xml
# run: |
# if [ ! -f codecov.sh ]; then
# n=0
# until [ "$n" -ge 5 ]
# do
# if curl --max-time 30 -L https://codecov.io/bash --output codecov.sh; then
# break
# fi
# n=$((n+1))
# sleep 15
# done
# fi
# if [ -f codecov.sh ]; then
# n=0
# until [ "$n" -ge 5 ]
# do
# if bash codecov.sh -R $(pwd) -n "${REPORT_NAME}" -f "${REPORT_PATH}" -F "${REPORT_FLAGS}"; then
# break
# fi
# n=$((n+1))
# sleep 15
# done
# fi
- name: Upload Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: runtests-${{ runner.os }}.log
path: artifacts/runtests-*.log

- name: Set Exit Status
if: always()
run: |
mkdir exitstatus
echo "${{ job.status }}" > exitstatus/${{ github.job }}
- name: Upload Exit Status
if: always()
uses: actions/upload-artifact@v4
with:
name: exitstatus-${{ github.job }}
path: exitstatus
if-no-files-found: error

Windows:
runs-on: windows-latest
timeout-minutes: 45

strategy:
fail-fast: false
max-parallel: 5

steps:
- uses: actions/checkout@v4
with:
# We need the full history for update tests
fetch-depth: 0
fetch-tags: true

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Download libeay32.dll
run: |
PY_LOC="$(which python.exe)"
export PY_LOC
echo "${PY_LOC}"
PY_DIR="$(dirname "${PY_LOC}")"
export PY_DIR
echo "${PY_DIR}"
curl https://repo.saltproject.io/windows/dependencies/64/libeay32.dll --output "${PY_DIR}/libeay32.dll"
ls -l "${PY_DIR}"
shell: bash

- name: Install Nox
run: |
python -m pip install --upgrade pip
pip install nox
- name: Install Test Requirements
shell: bash
run: |
export PATH="/C/Program Files (x86)/Windows Kits/10/bin/10.0.18362.0/x64;$PATH"
nox --force-color -e tests --install-only
- name: Test
shell: bash
env:
SKIP_REQUIREMENTS_INSTALL: true
run: |
export PATH="/C/Program Files (x86)/Windows Kits/10/bin/10.0.18362.0/x64;$PATH"
nox --force-color -e tests -- -vv tests/
- name: Upload Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: runtests-${{ runner.os }}.log
path: artifacts/runtests-*.log

- name: Set Exit Status
if: always()
run: |
mkdir exitstatus
echo "${{ job.status }}" > exitstatus/${{ github.job }}
- name: Upload Exit Status
if: always()
uses: actions/upload-artifact@v4
with:
name: exitstatus-${{ github.job }}
path: exitstatus
if-no-files-found: error

macOS:
runs-on: macOS-latest
timeout-minutes: 45

strategy:
fail-fast: false
max-parallel: 5

steps:
- uses: actions/checkout@v4
with:
# We need the full history for update tests
fetch-depth: 0
fetch-tags: true

- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install Nox
run: |
python -m pip install --upgrade pip
pip install nox
- name: Install Test Requirements
run: |
nox --force-color -e tests --install-only
brew install enchant
- name: Test
env:
SKIP_REQUIREMENTS_INSTALL: true
run: |
nox --force-color -e tests -- -vv tests/
- name: Upload Logs
if: always()
Expand Down
6 changes: 3 additions & 3 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ project_name_full:
_migrations:
# (Re)initialize the project and run pre-commit after updating
- >-
'{{ copier_python }}'
'{{ "{src}{sep}tasks{sep}initialize.py".format(src=_copier_conf.src_path, sep=_copier_conf.sep) }}'
"{{ copier_python }}"
"{{ "{src}{sep}tasks{sep}initialize.py".format(src=_copier_conf.src_path, sep=_copier_conf.sep) }}"
migrate
- version: 0.3.0
when: '{{ _stage == "before" }}'
Expand All @@ -321,7 +321,7 @@ _tasks:
not _copier_conf.answers.last
and '.new_copy.' not in _copier_conf.dst_path.name
and '.old_copy.' not in _copier_conf.dst_path.name -%}
'{{ copier_python }}' '{{ "{src}{sep}tasks{sep}initialize.py".format(src=_copier_conf.src_path, sep=_copier_conf.sep) }}' init
"{{ copier_python }}" "{{ "{src}{sep}tasks{sep}initialize.py".format(src=_copier_conf.src_path, sep=_copier_conf.sep) }}" init
{%- endif -%}
# =====================================
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
DOCSAUTO_REQUIREMENTS = ("sphinx-autobuild",)

TESTS_REQUIREMENTS = (
"copier>=9.1",
"copier>=9.3",
"copier-templates-extensions",
"plumbum",
"pytest",
Expand Down
1 change: 1 addition & 0 deletions project/tools/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
finish_task(
f"Failed initializing environment: {err}",
False,
True,
extra=(
"No worries, just follow the manual steps documented here: "
"https://salt-extensions.github.io/salt-extension-copier/topics/creation.html#first-steps"
Expand Down
9 changes: 5 additions & 4 deletions tests/helpers/copier_hlp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections import ChainMap
from pathlib import Path
from typing import Optional

import yaml
from copier import run_copy
Expand All @@ -9,7 +10,7 @@
from pytest_copie.plugin import _add_yaml_include_constructor


def load_copier_yaml(template_dir: Path | None = None) -> ChainMap:
def load_copier_yaml(template_dir: Optional[Path] = None) -> ChainMap:
template_dir = template_dir or Path(".")
files = template_dir.glob("copier.*")
try:
Expand All @@ -24,8 +25,8 @@ class UpgradedCopie(Copie):

def copy(
self,
extra_answers: dict | None = None,
template_dir: Path | None = None,
extra_answers: Optional[dict] = None,
template_dir: Optional[Path] = None,
vcs_ref: str = "HEAD",
) -> Result:
"""
Expand Down Expand Up @@ -74,7 +75,7 @@ def copy(
return Result(exception=e, exit_code=-1)

def update(
self, project_dir: Path, extra_answers: dict | None = None, vcs_ref: str = "HEAD"
self, project_dir: Path, extra_answers: Optional[dict] = None, vcs_ref: str = "HEAD"
) -> Result:
try:
worker = run_update(
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class VirtualEnv:
venv_bin_dir: Path = field(init=False, repr=False)

def __post_init__(self):
if sys.platform == "nt":
if platform.system() == "Windows":
self.venv_python = self.venv_dir / "Scripts" / "python.exe"
else:
self.venv_python = self.venv_dir / "bin" / "python"
Expand Down

0 comments on commit f821f46

Please sign in to comment.