Skip to content

Commit 74150ef

Browse files
committed
add sanity checks to validate the package
1 parent 4be1141 commit 74150ef

File tree

3 files changed

+46
-7
lines changed

3 files changed

+46
-7
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,27 @@ jobs:
1919
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
2020
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
2121
with:
22-
python-version: '3.8' # needed for 'pyupgrade'
22+
python-version: '3.8'
2323
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
2424

25+
sanity:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
29+
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
30+
with:
31+
python-version: '3.8'
32+
- run: |
33+
pip install --upgrade pip
34+
pip install -r requirements.txt
35+
pip install invoke
36+
37+
- run: invoke build.build-package
38+
- run: invoke sanity.validate-sdist
39+
- run: invoke sanity.validate-wheel
40+
2541
ci:
26-
needs: pre-commit
42+
needs: [pre-commit, sanity]
2743
runs-on: ubuntu-latest
2844
timeout-minutes: 15
2945
steps:
@@ -48,10 +64,9 @@ jobs:
4864
- run: invoke unit.pytest
4965
- run: invoke integration.query
5066
- run: invoke integration.write-policy
51-
- run: invoke build.uninstall-package
5267

5368
python-version:
54-
needs: pre-commit
69+
needs: [pre-commit, sanity]
5570
if: github.event_name == 'pull_request'
5671
runs-on: ubuntu-latest
5772
timeout-minutes: 15
@@ -78,4 +93,3 @@ jobs:
7893
- run: invoke unit.pytest
7994
- run: invoke integration.query
8095
- run: invoke integration.write-policy
81-
- run: invoke build.uninstall-package

.github/workflows/publish.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ jobs:
5454
git fetch --tags
5555
git pull origin master
5656
pip install setuptools wheel twine
57-
python -m setup sdist bdist_wheel
57+
python setup.py sdist bdist_wheel
58+
59+
- run: invoke sanity.validate-sdist
60+
- run: invoke sanity.validate-wheel
61+
5862
- name: Publish package
5963
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0
6064
with:

tasks.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
docker = Collection("docker")
3636
ns.add_collection(docker)
3737

38+
sanity = Collection("sanity")
39+
ns.add_collection(sanity)
40+
3841

3942
@task
4043
def build_docs(c):
@@ -59,7 +62,7 @@ def download_latest_aws_docs(c):
5962
def build_package(c):
6063
"""Build the policy_sentry package from the current directory contents for use with PyPi"""
6164
c.run("python -m pip install --upgrade setuptools wheel")
62-
c.run("python setup.py -q sdist bdist_wheel")
65+
c.run("python setup.py sdist bdist_wheel")
6366

6467

6568
@task(pre=[build_package])
@@ -306,6 +309,21 @@ def build_docker(c):
306309
c.run("docker build -t kmcquade/policy_sentry .")
307310

308311

312+
# Sanity checks
313+
@task(post=[uninstall_package])
314+
def validate_wheel(c):
315+
"""Validate the wheel can be installed and works properly"""
316+
c.run("pip3 install dist/policy_sentry-*.whl")
317+
c.run("policy_sentry query service-table --fmt csv", pty=True)
318+
319+
320+
@task(post=[uninstall_package])
321+
def validate_sdist(c):
322+
"""Validate the sdist archive can be installed and works properly"""
323+
c.run("pip3 install dist/policy_sentry-*.tar.gz")
324+
c.run("policy_sentry query service-table --fmt csv", pty=True)
325+
326+
309327
# Add all testing tasks to the test collection
310328
integration.add_task(clean_config_directory, "clean")
311329
integration.add_task(version_check, "version")
@@ -331,3 +349,6 @@ def build_docker(c):
331349
build.add_task(upload_to_pypi_prod_server, "upload-prod")
332350

333351
docker.add_task(build_docker, "build-docker")
352+
353+
sanity.add_task(validate_wheel, "validate-wheel")
354+
sanity.add_task(validate_sdist, "validate-sdist")

0 commit comments

Comments
 (0)