Skip to content

Commit 4c1dca6

Browse files
unfinished
1 parent d1e2811 commit 4c1dca6

File tree

8 files changed

+98
-68
lines changed

8 files changed

+98
-68
lines changed

.github/workflows/checks.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,25 @@ jobs:
160160
- name: Run format check
161161
run: poetry run -- nox -s project:format
162162

163+
Build-Packages:
164+
name: Build Package Check
165+
needs: [ Documentation, Lint, Type-Check, Security, Format, build-matrix ]
166+
runs-on: ubuntu-24.04
167+
permissions:
168+
contents: read
169+
steps:
170+
- name: SCM Checkout
171+
uses: actions/checkout@v4
172+
173+
- name: Setup Python & Poetry Environment
174+
uses: ./.github/actions/python-environment
175+
176+
- name: Run Distribution Check
177+
run: poetry run -- nox -s lint:build-packages
178+
163179
Tests:
164180
name: Unit-Tests (Python-${{ matrix.python-version }})
165-
needs: [ Documentation, Lint, Type-Check, Security, Format, build-matrix ]
181+
needs: [ Documentation, Lint, Type-Check, Security, Format, build-matrix , Build-Packages]
166182
runs-on: ubuntu-24.04
167183
permissions:
168184
contents: read
@@ -191,19 +207,3 @@ jobs:
191207
name: coverage-python${{ matrix.python-version }}-fast
192208
path: .coverage
193209
include-hidden-files: true
194-
195-
Build-Packages:
196-
name: Build Package Check
197-
needs: [ Documentation, Lint, Type-Check, Security, Format, build-matrix, Tests ]
198-
runs-on: ubuntu-24.04
199-
permissions:
200-
contents: read
201-
steps:
202-
- name: SCM Checkout
203-
uses: actions/checkout@v4
204-
205-
- name: Setup Python & Poetry Environment
206-
uses: ./.github/actions/python-environment
207-
208-
- name: Run Distribution Check
209-
run: poetry run -- nox -s lint:build-packages

doc/changes/unreleased.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ PROJECT_CONFIG = Config(python_versions=(...), exasol_versions=(...), create_maj
2929

3030
* #465: Created BaseConfig class to better synchronize attributes needed for the PTB's
3131
growing functionalities
32-
* #494: Created check of built packages
32+
* #494: Created check of built packages with nox session ``package:check``:

exasol/toolbox/nox/_lint.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,3 @@ def import_lint(session: Session) -> None:
177177
"Please make sure you have a configuration file for the importlinter"
178178
)
179179
_import_lint(session=session, path=path)
180-
181-
182-
@nox.session(name="lint:build-packages", python=False)
183-
def dist_check(session: Session) -> None:
184-
"""Checks whether your distribution’s long description will render correctly on PyPI
185-
186-
This has more robust checks for rst documentation than markdown.
187-
"""
188-
session.run("poetry", "build", "--project", PROJECT_CONFIG.root)
189-
session.run("twine", "check", PROJECT_CONFIG.root / "./dist/*")

exasol/toolbox/nox/_package.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from __future__ import annotations
2+
3+
import nox
4+
from nox import Session
5+
6+
from noxconfig import PROJECT_CONFIG
7+
8+
9+
@nox.session(name="package:check", python=False)
10+
def package_check(session: Session) -> None:
11+
"""Checks whether your distribution’s long description will render correctly on PyPI
12+
13+
This has more robust checks for rst documentation than markdown.
14+
"""
15+
session.run("poetry", "build", "--project", PROJECT_CONFIG.root)
16+
session.run("twine", "check", PROJECT_CONFIG.root / "./dist/*")

exasol/toolbox/nox/tasks.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,7 @@ def check(session: Session) -> None:
8888

8989
from exasol.toolbox.nox._package_version import version_check
9090

91+
from exasol.toolbox.nox._package import package_check
92+
9193
# isort: on
9294
# fmt: on

exasol/toolbox/templates/github/workflows/checks.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,25 @@ jobs:
160160
- name: Run format check
161161
run: poetry run -- nox -s project:format
162162

163+
Build-Packages:
164+
name: Build Package Check
165+
needs: [ Documentation, Lint, Type-Check, Security, Format, build-matrix ]
166+
runs-on: ubuntu-24.04
167+
permissions:
168+
contents: read
169+
steps:
170+
- name: SCM Checkout
171+
uses: actions/checkout@v4
172+
173+
- name: Setup Python & Poetry Environment
174+
uses: exasol/python-toolbox/.github/actions/python-environment@v1
175+
176+
- name: Run Distribution Check
177+
run: poetry run -- nox -s lint:build-packages
178+
163179
Tests:
164180
name: Unit-Tests (Python-${{ matrix.python-version }})
165-
needs: [ Documentation, Lint, Type-Check, Security, Format, build-matrix ]
181+
needs: [ Documentation, Lint, Type-Check, Security, Format, build-matrix, Build-Packages ]
166182
runs-on: ubuntu-24.04
167183
permissions:
168184
contents: read
@@ -188,19 +204,3 @@ jobs:
188204
name: coverage-python${{ matrix.python-version }}-fast
189205
path: .coverage
190206
include-hidden-files: true
191-
192-
Build-Packages:
193-
name: Build Package Check
194-
needs: [ Documentation, Lint, Type-Check, Security, Format, build-matrix, Tests ]
195-
runs-on: ubuntu-24.04
196-
permissions:
197-
contents: read
198-
steps:
199-
- name: SCM Checkout
200-
uses: actions/checkout@v4
201-
202-
- name: Setup Python & Poetry Environment
203-
uses: ./.github/actions/python-environment
204-
205-
- name: Run Distribution Check
206-
run: poetry run -- nox -s lint:build-packages

test/unit/nox/_lint_test.py

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import pytest
2+
from unittest.mock import (
3+
MagicMock,
4+
patch,
5+
)
6+
from nox.command import CommandFailed
7+
import shutil
8+
from pathlib import Path
9+
10+
from exasol.toolbox.nox._package import package_check, PROJECT_CONFIG
11+
from exasol.toolbox.config import BaseConfig
12+
13+
class TestDistributionCheck:
14+
@staticmethod
15+
def test_works_as_expected(nox_session):
16+
package_check(nox_session)
17+
18+
@staticmethod
19+
def test_raises_non_zero_exist_with_readme_error(nox_session, tmp_path):
20+
# TODOs
21+
# 1. copy package files to a temp directory
22+
# 2. mock/alter the path for the function you need to use for testing
23+
# 3. modify rst file to have a broken link like is in this commit:
24+
# - `Python <https://www.python.org/`__ >= 3.9
25+
package = Path(tmp_path)
26+
package_readme = package / "README.rst"
27+
shutil.copytree(PROJECT_CONFIG.root / "exasol", package / "exasol")
28+
shutil.copyfile(PROJECT_CONFIG.root / "README.rst", package_readme)
29+
shutil.copytree(PROJECT_CONFIG.root / "doc/changes", package / "doc/changes")
30+
shutil.copyfile(PROJECT_CONFIG.root / "LICENSE", package / "LICENSE")
31+
shutil.copyfile(PROJECT_CONFIG.root / "pyproject.toml", package / "pyproject.toml")
32+
old = "- `Python <https://www.python.org/>`__ >= 3.9"
33+
error = "- `Python <https://www.python.org/>`__ >= 3.9"
34+
readme = package_readme.read_text().splitlines()
35+
error_readme = [error if old in line else line for line in readme]
36+
package_readme.write_text("/n".join(error_readme))
37+
config = BaseConfig()
38+
mock = MagicMock(spec=BaseConfig, wraps=config)
39+
mock.root = package
40+
with pytest.raises(CommandFailed) as e:
41+
with patch("exasol.toolbox.nox._package.PROJECT_CONFIG", mock):
42+
print(PROJECT_CONFIG.root)
43+
package_check(nox_session)
44+
# verify broken with non-zero exit status
45+
assert str(e.value) == "Returned code 1"

0 commit comments

Comments
 (0)