diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0dbfae6a..9a6c9d56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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 @@ -78,4 +93,3 @@ jobs: - run: invoke unit.pytest - run: invoke integration.query - run: invoke integration.write-policy - - run: invoke build.uninstall-package diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index cdc3b67b..36738bd5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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: diff --git a/tasks.py b/tasks.py index 56ec6a96..ca08144a 100755 --- a/tasks.py +++ b/tasks.py @@ -35,6 +35,9 @@ docker = Collection("docker") ns.add_collection(docker) +sanity = Collection("sanity") +ns.add_collection(sanity) + @task def build_docs(c): @@ -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]) @@ -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") @@ -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")