Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
95 changes: 36 additions & 59 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,67 +29,44 @@ permissions:
contents: read

jobs:
linting:
name: Reuse linting job
uses: ./.github/workflows/lint.yml
lint:
uses: reqstool/.github/.github/workflows/python-lint.yml@91cd368066d5458b5d46bdf34c4d8ca483f6633f # 1.2.2
with:
package-manager: poetry

build:
needs: linting
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
reqstool-source: [pypi, main]
steps:
# Full history and tags: poetry-dynamic-versioning derives the version from git state, so a
# shallow clone would build the wrong number rather than fail.
- name: Check out source repository
uses: actions/checkout@v7.0.1
with:
persist-credentials: false
fetch-depth: 0
fetch-tags: true
ref: ${{ inputs.ref || github.ref }}
- name: Set up Python
uses: actions/setup-python@v7.1.0
with:
python-version: "3.15.2"
- name: Install and configure Poetry
uses: snok/install-poetry@a783c322200f0519c7926aa6faa857c4e23e9263 # v1.4.2
with:
version: 2.5.1
virtualenvs-create: true
- name: Install poetry-dynamic-versioning
run: poetry self add "poetry-dynamic-versioning[plugin]"
- name: Install dependencies
run: poetry install --with dev
- name: Build wheel (used by e2e tests)
run: poetry build --format wheel
- name: Install plugin into Poetry (activates it for e2e tests)
run: poetry self add $(ls $PWD/dist/reqstool_python_poetry_plugin-*.whl | tail -1)
- name: Run tests
run: poetry run pytest --junitxml=build/junit.xml --cov --cov-report=xml:build/coverage.xml
- name: Build project
run: poetry build
- name: Install reqstool
uses: reqstool/.github/.github/actions/install-reqstool@6fc8d3e3d4c3fdf7a83cb7b7a274e4761486ca71 # 1.2.1
with:
reqstool-source: ${{ matrix.reqstool-source }}
- name: Validate reqstool spec completeness
# not yet available in the latest PyPI release
if: matrix.reqstool-source == 'main'
uses: reqstool/.github/.github/actions/validate-reqstool@6fc8d3e3d4c3fdf7a83cb7b7a274e4761486ca71 # 1.2.1
- name: Run reqstool status
uses: reqstool/.github/.github/actions/reqstool-status@6fc8d3e3d4c3fdf7a83cb7b7a274e4761486ca71 # 1.2.1
with:
fail-if-incomplete: "true"
# Upload artifacts for later use
- name: Upload Artifacts
if: matrix.reqstool-source == 'pypi'
uses: actions/upload-artifact@v7.0.2
with:
name: ${{ inputs.artifact-name || 'dist' }}
path: dist/
needs: lint
uses: reqstool/.github/.github/workflows/python-build-poetry.yml@91cd368066d5458b5d46bdf34c4d8ca483f6633f # 1.2.2
with:
coverage-source: reqstool_python_poetry_plugin
install-self-as-plugin: true
ref: ${{ inputs.ref }}
artifact-name: ${{ inputs.artifact-name || 'dist' }}

reqstool:
needs: build
uses: reqstool/.github/.github/workflows/common-reqstool-verify.yml@91cd368066d5458b5d46bdf34c4d8ca483f6633f # 1.2.2
with:
build-artifact: ${{ inputs.artifact-name || 'dist' }}-build

smoke:
needs: build
uses: reqstool/.github/.github/workflows/python-smoke.yml@91cd368066d5458b5d46bdf34c4d8ca483f6633f # 1.2.2
with:
dist-artifact: ${{ inputs.artifact-name || 'dist' }}
requirements: pytest==9.2.0
command: poetry --version && python -c "import reqstool_python_poetry_plugin.plugin" && pytest tests/unit

validate-openspec:
uses: reqstool/.github/.github/workflows/common-validate-openspec.yml@6fc8d3e3d4c3fdf7a83cb7b7a274e4761486ca71 # 1.2.1

ci:
if: ${{ always() }}
needs: [lint, build, reqstool, smoke, validate-openspec]
runs-on: ubuntu-latest
steps:
- name: Fail unless every needed job succeeded
env:
NEEDS: ${{ toJSON(needs) }}
run: |
echo "$NEEDS" | python3 -c 'import json,sys; r={k:v["result"] for k,v in json.load(sys.stdin).items()}; print(r); sys.exit(0 if all(v=="success" for v in r.values()) else 1)'
31 changes: 0 additions & 31 deletions .github/workflows/lint.yml

This file was deleted.

14 changes: 7 additions & 7 deletions src/reqstool_python_poetry_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ def _cleanup_pyproject_install_after_install(self) -> None:
pyproject_path = Path(str(self._poetry.package.root_dir)) / "pyproject.toml"
if not pyproject_path.exists():
return
content = pyproject_path.read_text(encoding="utf-8")
cleaned = re.sub(r"\n{3,}", "\n\n", content)
content = pyproject_path.read_text(encoding="utf-8", newline="")
cleaned = re.sub(r"(\r?\n)(?:\r?\n){2,}", r"\1\1", content)
if cleaned != content:
pyproject_path.write_text(cleaned, encoding="utf-8")
pyproject_path.write_text(cleaned, encoding="utf-8", newline="")
self._cleo_io.write_line("[reqstool] Cleaned up excess blank lines in pyproject.toml")

@Requirements("POETRY_PLUGIN_003")
Expand Down Expand Up @@ -174,19 +174,19 @@ def _generate_reqstool_config(self) -> None:
msg: str = f"[reqstool] missing mandatory {self.INPUT_FILE_REQUIREMENTS_YML}: {requirements_file}"
raise RuntimeError(msg)

resources["requirements"] = str(requirements_file)
resources["requirements"] = requirements_file.as_posix()
self._cleo_io.write_line(f"[reqstool] added to {self.OUTPUT_SDIST_REQSTOOL_CONFIG_YML}: {requirements_file}")

if svcs_file.exists():
resources["software_verification_cases"] = str(svcs_file)
resources["software_verification_cases"] = svcs_file.as_posix()
self._cleo_io.write_line(f"[reqstool] added to {self.OUTPUT_SDIST_REQSTOOL_CONFIG_YML}: {svcs_file}")

if mvrs_file.exists():
resources["manual_verification_results"] = str(mvrs_file)
resources["manual_verification_results"] = mvrs_file.as_posix()
self._cleo_io.write_line(f"[reqstool] added to {self.OUTPUT_SDIST_REQSTOOL_CONFIG_YML}: {mvrs_file}")

if annotations_file.exists():
resources["annotations"] = str(annotations_file)
resources["annotations"] = annotations_file.as_posix()
self._cleo_io.write_line(f"[reqstool] added to {self.OUTPUT_SDIST_REQSTOOL_CONFIG_YML}: {annotations_file}")

if test_result_patterns:
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/reqstool_python_poetry_plugin/test_plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright © LFV

from pathlib import Path
from unittest.mock import MagicMock, patch

import pytest
Expand Down Expand Up @@ -123,7 +124,7 @@ def test_create_annotations_file_passes_configured_sources_and_output_path(tmp_p

decorator_processor_cls.return_value.process_decorated_data.assert_called_once_with(
path_to_python_files=["src", "tests/unit"],
output_file="build/reqstool/annotations.yml",
output_file=str(Path("build/reqstool/annotations.yml")),
)


Expand Down
Loading