Skip to content

Commit

Permalink
Fix testing (#72)
Browse files Browse the repository at this point in the history
* fix tox env names

* update test running script

* update branch

* make tox run in development mode for PR tests

* update prepare-release script to build release

* add test release step && re-enable step to create github release

* update dev docs

* update 18F -> cloud-gov in repo name

* update dev docs

* update pipeline set-self step to use branch as source

* update pipeline

* update RELEASE
  • Loading branch information
markdboyd authored Jan 29, 2024
1 parent 5cca5e1 commit d4d356a
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 29 deletions.
9 changes: 6 additions & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ Here's how to issue a new release:
`CHANGELOG.md` for this, as whatever you enter will
show up on the [GitHub releases page][].

1. After you push, the [CI pipeline](./ci/pipeline.yml) will automatically
create a [GitHub release][GitHub releases page] for the tag.

1. If you haven't already done so, create a `~/.pypirc` file
with the following content:

Expand All @@ -56,7 +59,7 @@ Here's how to issue a new release:
```

1. Run `python -m twine upload dist/*`. The new release should now
be visible on [pypi][].
be visible on [PyPI][].

[GitHub releases page]: https://github.com/18F/cg-django-uaa/releases
[pypi]: https://pypi.python.org/pypi/cg-django-uaa
[GitHub releases page]: https://github.com/cloud-gov/cg-django-uaa/releases
[PyPI]: https://pypi.python.org/pypi/cg-django-uaa
42 changes: 26 additions & 16 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,26 @@ jobs:

- name: set-self
plan:
- get: cg-django-uaa-repo-tag
- get: cg-django-uaa-repo
trigger: true
- set_pipeline: self
file: cg-django-uaa-repo-tag/ci/pipeline.yml
file: cg-django-uaa-repo/ci/pipeline.yml

- name: create-release
plan:
- get: cg-django-uaa-repo-tag
passed: [set-self]
trigger: true
- task: prepare-release
file: cg-django-uaa-repo-tag/ci/prepare-release.yml
# - put: cg-django-uaa-release
# params:
# name: cg-django-uaa-repo-tag/tag
# tag: cg-django-uaa-repo-tag/tag
# generate_release_notes: true
- task: test-release
file: cg-django-uaa-repo-tag/ci/test-release.yml
- put: cg-django-uaa-release
params:
name: cg-django-uaa-repo-tag/tag
tag: cg-django-uaa-repo-tag/tag
generate_release_notes: true
globs:
- cg-django-uaa-repo-tag/dist/cg-django-uaa*
on_failure:
put: slack
params:
Expand Down Expand Up @@ -72,15 +75,22 @@ resources:
access_token: ((status-access-token))
disable_forks: true

# this resource is this repo
- name: cg-django-uaa-repo
type: git
source:
uri: https://github.com/cloud-gov/cg-django-uaa.git
branch: main
commit_verification_keys: ((cloud-gov-pgp-keys))

# this resource is this repo
# NOTE: we only execute on tag changes not commits, see tag_regex
- name: cg-django-uaa-repo-tag
type: git
source:
uri: https://github.com/cloud-gov/cg-django-uaa.git
branch: update-django-4
# only run on new tags matching pattern like: v0.1.5
# tag_regex: '^v([0-9]+\.){0,2}(\*|[0-9]+)$'
tag_regex: '^v([0-9]+\.){0,2}(\*|[0-9]+)$'
commit_verification_keys: ((cloud-gov-pgp-keys))

# This resource for posting to slack
Expand All @@ -90,12 +100,12 @@ resources:
url: ((slack-webhook-url))

# Resource for creating a new release
# - name: cg-django-uaa-release
# type: github-release
# source:
# owner: cloud-gov
# repository: cg-django-uaa
# access_token: ((cg-ci-bot-ghtoken))
- name: cg-django-uaa-release
type: github-release
source:
owner: cloud-gov
repository: cg-django-uaa
access_token: ((cg-ci-bot-ghtoken))

- name: general-task
type: registry-image
Expand Down
6 changes: 6 additions & 0 deletions ci/prepare-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@

TAG=$(git describe --tags)
echo "$TAG" > tag

# Install build module
python -m pip install build

# Build release
python -m build --sdist
7 changes: 3 additions & 4 deletions ci/run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/bash

python -m venv venv
source ./venv/bin/activate
source venv/bin/activate

python -m pip install -r requirements-tests.txt
python -m pip install -e .

# run tests
tox
# run tests in development mode
tox --develop
11 changes: 11 additions & 0 deletions ci/test-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

python -m venv venv
source venv/bin/activate

TAG=$(git describe --tags)

python -m pip install -r requirements-tests.txt

# run tests on release
tox --installpkg "dist/cg-django-uaa-$TAG.tar.gz"
12 changes: 12 additions & 0 deletions ci/test-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
platform: linux

inputs:
- name: cg-django-uaa-repo-tag

outputs:
- name: cg-django-uaa-repo-tag

run:
dir: cg-django-uaa-repo-tag
path: ci/test-release.sh
6 changes: 3 additions & 3 deletions docs/developing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ development dependencies::

Then install cg-django-uaa in development mode::

python -m pip install -e .
python -m pip install --editable .

Using the example app
~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -54,9 +54,9 @@ with::

tox

or against specific versions, for instance python 3.8 with django 3.1::
or against specific versions, for instance Python 3.10 with Django 4.2::

tox -e py38-django31
tox -e py310-django42


Formatting code
Expand Down
22 changes: 19 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@
envlist = py3{8,9,10,11,12}-django{40,41,42}
isolated_build = true

[testenv:py3{8,9,10,11,12}]
[testenv:py3{8,9,10,11,12}-django40]
deps =
-rrequirements-tests.txt
-rrequirements-dev.txt
-r requirements-tests.txt
-r requirements-dev.txt
django40: Django>=4.0,<4.1
commands =
python -m uaa_client.runtests -v
python -m mypy uaa_client -v

[testenv:py3{8,9,10,11,12}-django41]
deps =
-r requirements-tests.txt
-r requirements-dev.txt
django41: Django>=4.1,<4.2
commands =
python -m uaa_client.runtests -v
python -m mypy uaa_client -v

[testenv:py3{8,9,10,11,12}-django42]
deps =
-r requirements-tests.txt
-r requirements-dev.txt
django42: Django>=4.2,<4.3
commands =
python -m uaa_client.runtests -v
Expand Down

0 comments on commit d4d356a

Please sign in to comment.