Skip to content

Commit

Permalink
Merge pull request #4 from cidrblock/fix_release_pipeline
Browse files Browse the repository at this point in the history
Add release pipeline
  • Loading branch information
cidrblock authored Aug 14, 2023
2 parents a0199e9 + 47cfa9d commit 7127c7d
Show file tree
Hide file tree
Showing 11 changed files with 324 additions and 5 deletions.
7 changes: 4 additions & 3 deletions .config/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
black
pytest
ruff
mypy
pip-tools
pre-commit
pydoclint
pytest
ruff
toml-sort
mypy
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @cidrblock @ssbarnea
3 changes: 3 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Community Code of Conduct

Please see the official [Ansible Community Code of Conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
version: 2
updates:
- package-ecosystem: pip
directory: /.config/
schedule:
day: sunday
interval: weekly
labels:
- dependabot-deps-updates
- skip-changelog
versioning-strategy: lockfile-only
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: daily
labels:
- "dependencies"
- "skip-changelog"
2 changes: 2 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# see https://github.com/ansible-community/devtools
_extends: ansible-community/devtools
13 changes: 13 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
# See https://github.com/ansible/devtools/blob/main/.github/workflows/push.yml
name: push
"on":
push:
branches:
- main
- "releases/**"
- "stable/**"

jobs:
ack:
uses: ansible/devtools/.github/workflows/push.yml@main
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
# cspell:ignore mislav
name: release

"on":
release:
types: [published]

jobs:
pypi:
name: Publish to PyPI registry
environment: release
runs-on: ubuntu-22.04
permissions:
id-token: write

env:
FORCE_COLOR: 1
PY_COLORS: 1
TOXENV: pkg

steps:
- name: Switch to using Python 3.9 by default
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install tox
run: python3 -m pip install --user "tox>=4.0.0"

- name: Check out src from Git
uses: actions/checkout@v3
with:
fetch-depth: 0 # needed by setuptools-scm
submodules: true

- name: Build dists
run: python -m tox

- name: Publish to pypi.org
if: >- # "create" workflows run separately from "push" & "pull_request"
github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
72 changes: 72 additions & 0 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: tox

# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on:
create: # is used for publishing to PyPI and TestPyPI
tags: # any tag regardless of its name, no branches
- "**"
push: # only publishes pushes to the main branch to TestPyPI
branches: # any integration branch but not tag
- "main"
pull_request:

jobs:
pre:
name: pre
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.generate_matrix.outputs.matrix }}
steps:
- name: Determine matrix
id: generate_matrix
uses: coactions/dynamic-matrix@v1
with:
min_python: "3.9"
max_python: "3.11"
default_python: "3.11" # used by jobs in other_names
other_names: |
lint
tox:
name: ${{ matrix.name }} / python ${{ matrix.python_version }}
runs-on: ubuntu-20.04
needs: pre
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.pre.outputs.matrix) }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # needed by setuptools-scm

- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}

- name: Install tox
run: python3 -m pip install --upgrade "tox>=4.0.2"

- name: Log Python info (${{ matrix.python_version }})
run: |
command -v python
python --version --version
python3 -m pip freeze --all
- name: "tox -e ${{ matrix.passed_name }}"
continue-on-error: ${{ matrix.devel || false }}
run: python3 -m tox -e ${{ matrix.passed_name }}

tox_passed:
needs: tox
runs-on: ubuntu-latest
steps:
- run: >-
python -c "assert set([
'${{ needs.tox.result }}',
]) == {'success'}"
84 changes: 84 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --extra=docs --extra=test --no-annotate --output-file=requirements.txt
#
ansible-builder==3.0.0
ansible-compat==4.1.5
ansible-core==2.15.2
ansible-creator @ git+https://github.com/NilashishC/ansible-creator.git
ansible-lint==6.17.2
ansible-navigator==3.4.2
ansible-runner==2.3.3
ansible-sign==0.1.1
attrs==23.1.0
bindep==2.11.0
black==23.7.0
bracex==2.3.post1
cachetools==5.3.1
certifi==2023.7.22
cffi==1.15.1
chardet==5.2.0
charset-normalizer==3.2.0
click==8.1.6
click-help-colors==0.9.1
colorama==0.4.6
coverage==7.3.0
cryptography==41.0.3
distlib==0.3.7
distro==1.8.0
docutils==0.20.1
enrich==1.2.7
execnet==2.0.2
filelock==3.12.2
idna==3.4
iniconfig==2.0.0
jinja2==3.0.3
jsonschema==4.19.0
jsonschema-specifications==2023.7.1
lockfile==0.12.2
markdown-it-py==3.0.0
markupsafe==2.1.3
mdurl==0.1.2
molecule==6.0.0
mypy-extensions==1.0.0
onigurumacffi==1.2.0
packaging==23.1
parsley==1.3
pathspec==0.11.2
pbr==5.11.1
pexpect==4.8.0
platformdirs==3.10.0
pluggy==1.2.0
ptyprocess==0.7.0
pycparser==2.21
pygments==2.16.1
pyproject-api==1.5.3
pytest==7.4.0
pytest-ansible==4.0.0
pytest-xdist==3.3.1
python-daemon==3.0.1
python-gnupg==0.5.1
pyyaml==6.0.1
referencing==0.30.2
requests==2.31.0
requirements-parser==0.5.0
resolvelib==1.0.1
rich==13.5.2
rpds-py==0.9.2
ruamel-yaml==0.17.32
ruamel-yaml-clib==0.2.7
six==1.16.0
subprocess-tee==0.4.1
tox==4.8.0
tox-ansible==2.0.9
types-setuptools==68.0.0.3
tzdata==2023.3
urllib3==2.0.4
virtualenv==20.24.3
wcmatch==8.4.1
yamllint==1.32.0

# The following packages are considered to be unsafe in a requirements file:
# setuptools
4 changes: 2 additions & 2 deletions src/ansible_cdk/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# file generated by setuptools_scm
# don't change, don't track in version control
__version__ = version = "0.0.1"
__version_tuple__ = version_tuple = (0, 0, 1)
__version__ = version = "0.0.2.dev10"
__version_tuple__ = version_tuple = (0, 0, 2, "dev10")
81 changes: 81 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
[tox]
requires =
tox>=4.2
env_list =
py
lint
pkg
no_package = true
skip_missing_interpreters = true
work_dir = {env:TOX_WORK_DIR:.tox}

[testenv]
description = Run pytest under {basepython} ({envpython})
deps =
--editable .[test]
pass_env =
CI
CONTAINER_*
DOCKER_*
GITHUB_*
HOME
PYTEST_*
SSH_AUTH_SOCK
TERM
USER
set_env =
COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}}
COVERAGE_PROCESS_START = {toxinidir}/pyproject.toml
FORCE_COLOR = 1
PIP_CONSTRAINT = {toxinidir}/requirements.txt
PRE_COMMIT_COLOR = always
TERM = xterm-256color
commands =
coverage run -m pytest {posargs}
sh -c "coverage combine -q .tox/.coverage.* && coverage xml || true && coverage report"
allowlist_externals =
coverage
rm
sh
envlist = lint, py, packaging, report, clean

[testenv:lint]
description = Enforce quality standards under {basepython} ({envpython})
deps =
--editable .
pre-commit
commands =
pre-commit run --show-diff-on-failure --all-files
install_command = pip install {opts} {packages}

[testenv:pkg]
description =
Do packaging/distribution
skip_install = true
deps =
build>=0.9
twine >= 4.0.2 # pyup: ignore
set_env =
commands =
rm -rfv {toxinidir}/dist/
python -m build \
--outdir {toxinidir}/dist/ \
{toxinidir}
sh -c "python -m twine check --strict {toxinidir}/dist/*"

[testenv:clean]
description = Erase coverage data
skip_install = true
deps =
coverage[toml]
commands =
coverage erase

[testenv:report]
description = Produce coverage report
skip_install = true
deps =
coverage[toml]
commands =
coverage report
cat .tox/.tmp/.mypy/index.txt

0 comments on commit 7127c7d

Please sign in to comment.