Skip to content

Commit

Permalink
add sanity checks to validate the package
Browse files Browse the repository at this point in the history
  • Loading branch information
gruebel committed Jul 22, 2024
1 parent 4be1141 commit 74150ef
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,27 @@ jobs:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: '3.8' # needed for 'pyupgrade'
python-version: '3.8'
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1

sanity:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: '3.8'
- run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install invoke
- run: invoke build.build-package
- run: invoke sanity.validate-sdist
- run: invoke sanity.validate-wheel

ci:
needs: pre-commit
needs: [pre-commit, sanity]
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
Expand All @@ -48,10 +64,9 @@ jobs:
- run: invoke unit.pytest
- run: invoke integration.query
- run: invoke integration.write-policy
- run: invoke build.uninstall-package

python-version:
needs: pre-commit
needs: [pre-commit, sanity]
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 15
Expand All @@ -78,4 +93,3 @@ jobs:
- run: invoke unit.pytest
- run: invoke integration.query
- run: invoke integration.write-policy
- run: invoke build.uninstall-package
6 changes: 5 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ jobs:
git fetch --tags
git pull origin master
pip install setuptools wheel twine
python -m setup sdist bdist_wheel
python setup.py sdist bdist_wheel
- run: invoke sanity.validate-sdist
- run: invoke sanity.validate-wheel

- name: Publish package
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0
with:
Expand Down
23 changes: 22 additions & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
docker = Collection("docker")
ns.add_collection(docker)

sanity = Collection("sanity")
ns.add_collection(sanity)


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


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


# Sanity checks
@task(post=[uninstall_package])
def validate_wheel(c):
"""Validate the wheel can be installed and works properly"""
c.run("pip3 install dist/policy_sentry-*.whl")
c.run("policy_sentry query service-table --fmt csv", pty=True)


@task(post=[uninstall_package])
def validate_sdist(c):
"""Validate the sdist archive can be installed and works properly"""
c.run("pip3 install dist/policy_sentry-*.tar.gz")
c.run("policy_sentry query service-table --fmt csv", pty=True)


# Add all testing tasks to the test collection
integration.add_task(clean_config_directory, "clean")
integration.add_task(version_check, "version")
Expand All @@ -331,3 +349,6 @@ def build_docker(c):
build.add_task(upload_to_pypi_prod_server, "upload-prod")

docker.add_task(build_docker, "build-docker")

sanity.add_task(validate_wheel, "validate-wheel")
sanity.add_task(validate_sdist, "validate-sdist")

0 comments on commit 74150ef

Please sign in to comment.