Skip to content

Commit

Permalink
t
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakski committed Nov 21, 2024
1 parent abee619 commit 9563cdf
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 1,350 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- test
paths-ignore:
- README.md
- LICENSE
Expand All @@ -12,16 +13,15 @@ on:

jobs:
linux:
name: Linux, Python ${{ matrix.python-version }}, Sphinx ${{ matrix.sphinx-version }}
name: Linux, Python ${{ matrix.python }}, environment ${{ matrix.env }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- '3.9'
sphinx-version:
- '3'
- '4'
- '5'
include:
- {python: "3.9", env: "1"}
- {python: "3.9", env: "2"}
- {python: "3.9", env: "3"}
- {python: "3.9", env: "4"}
steps:
- name: Cache dependencies
uses: actions/cache@v2
Expand All @@ -36,9 +36,9 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ matrix.python }}

- name: Run tests
run: ./ci.sh test "sphinx${SPHINX_VERSION}"
run: ./ci.sh test "$ENV"
env:
SPHINX_VERSION: ${{ matrix.sphinx-version }}
ENV: ${{ matrix.env }}
83 changes: 24 additions & 59 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,6 @@ on_error() {
exit "$exit_code"
}

restore_lockfile() {
if [ -e poetry.lock.save ]; then
echo "Restoring original poetry.lock file..."
mv poetry.lock.save poetry.lock
fi
}

restore_pyproject() {
if [ -e pyproject.toml.save ]; then
echo "Restoring original pyproject.toml file..."
mv pyproject.toml.save pyproject.toml
fi
}

on_exit() {
restore_lockfile
restore_pyproject
}

ensure_poetry() {
if which poetry >/dev/null; then
return 0
fi
echo "Ensuring Poetry is installed..."
mkdir -p "${HOME}/.local/lib"
declare poetry_venv_path
poetry_venv_path="${HOME}/.local/lib/poetry_venv"
if [ ! -e "$poetry_venv_path" ]; then
python3 -m venv --upgrade-deps "$poetry_venv_path"
fi
if [ ! -e "${poetry_venv_path}/bin/poetry" ]; then
"${poetry_venv_path}/bin/pip" install "poetry==1.3.2"
fi
mkdir -p "${HOME}/.local/bin"
ln -sf "${poetry_venv_path}/bin/poetry" "${HOME}/.local/bin/poetry"
}

print_help() {
cat << EOF
Handle continuous integration tasks.
Expand All @@ -59,39 +22,41 @@ Subcommands:
EOF
}

# Poetry doesn't implement `--constraint` flag like pip. Yet we want to ensure
# that tests run always with the same dependency versions.
# shellcheck disable=SC2034
update_requirements_cmd() {
cp pyproject.toml pyproject.toml.save
cp poetry.lock poetry.lock.save
declare sphinx_version
for sphinx_version in 3 4 5; do
poetry add --lock "Sphinx@^${sphinx_version}"
poetry export --with dev --output "requirements-sphinx${sphinx_version}.txt"
cp poetry.lock.save poetry.lock
declare i
declare -a env1 env2 env3 env4
# Some contrib extensions don't specify required Sphinx version in dependencies, yet fail on setup
env1=(
"Sphinx>=3,<4"
)
env2=(
"Sphinx>=4,<5"
"sphinxcontrib-applehelp<=1.0.5"
"sphinxcontrib-devhelp<=1.0.2"
"sphinxcontrib-htmlhelp<=2.0.1"
"sphinxcontrib-serializinghtml<=1.1.5"
"sphinxcontrib-qthelp<=1.0.3"
)
env3=("Sphinx>=5,<6")
env4=("Sphinx>=5,<6" "ruamel.yaml>=0.17,<0.18")
for i in {1..4}; do
declare -n constraints="env${i}"
python3 -m venv --clear venv
./venv/bin/pip install ".[test]" "${constraints[@]}"
./venv/bin/pip freeze --exclude "sphinxcontrib-autoyaml" >"tests/requirements-${i}.txt"
done
rm poetry.lock.save
mv pyproject.toml.save pyproject.toml
}

test_cmd() {
declare requirements=$1
declare wheel_file
for wheel_file in ./dist/*.whl; do
rm "$wheel_file"
done
poetry install --verbose
poetry build --format wheel
declare env=$1
python3 -m venv --clear venv
./venv/bin/pip install --no-deps -r "requirements-${requirements}.txt"
./venv/bin/pip install --no-deps ./dist/*.whl
./venv/bin/pip install --no-deps -r "tests/requirements-${env}.txt" .
./venv/bin/python -m tests -v
}

main() {
trap 'on_error ${BASH_SOURCE[0]}:${LINENO}' ERR
trap on_exit EXIT
ensure_poetry

declare subcommand
subcommand=$1
Expand Down
638 changes: 0 additions & 638 deletions poetry.lock

This file was deleted.

55 changes: 29 additions & 26 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
[tool.poetry]
name = 'sphinxcontrib-autoyaml'
version = '1.1.2'
description = 'Sphinx autodoc extension for documenting YAML files from comments'
authors = ['Jakub Pieńkowski <[email protected]>']
license = 'MIT'
readme = 'README.md'
repository = 'https://github.com/Jakski/sphinxcontrib-autoyaml'
packages = [
{ include = "sphinxcontrib" },
[build-system]
requires = ["setuptools >= 66.1.0"]
build-backend = "setuptools.build_meta"

[project]
name = "sphinxcontrib-autoyaml"
version = "1.1.2"
description = "Sphinx autodoc extension for documenting YAML files from comments"
authors = [
{name = "Jakub Pieńkowski", email = "jakub+sphinxcontrib[email protected]"},
]
license = {text = "MIT"}
readme = "README.md"
classifiers = [
'Development Status :: 3 - Alpha',
'Framework :: Sphinx :: Extension',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: MIT License',
'Topic :: Documentation',
"Development Status :: 3 - Alpha",
"Framework :: Sphinx :: Extension",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: MIT License",
"Topic :: Documentation",
]
requires-python = ">=3.6"
dependencies = [
"Sphinx>=3.5.1",
"ruamel.yaml>=0.16.12",
]

[tool.poetry.dependencies]
python = '^3.6'
Sphinx = '>=3.5.1'
'ruamel.yaml' = '>=0.16.12'

[tool.poetry.dev-dependencies]
sphinx-testing = "^1.0.1"
flake8 = "^3.8.4"
[project.optional-dependencies]
test = [
"sphinx-testing>=1.0.1",
"flake8>=3.8.4",
]

[build-system]
requires = ['poetry-core>=1.0.0']
build-backend = 'poetry.core.masonry.api'
[tool.setuptools]
packages = ["sphinxcontrib"]
Loading

0 comments on commit 9563cdf

Please sign in to comment.