Skip to content

Commit

Permalink
Merge pull request #71 from cloud-gov/update-django-4
Browse files Browse the repository at this point in the history
Update to support Django 4
  • Loading branch information
kfoley-18F authored Jan 29, 2024
2 parents cf2424b + 3764e3d commit 5cca5e1
Show file tree
Hide file tree
Showing 23 changed files with 274 additions and 116 deletions.
31 changes: 0 additions & 31 deletions .circleci/config.yml

This file was deleted.

8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ to [Semantic Versioning](http://semver.org/).

## [Unreleased][unreleased]

## [2.1.5][] - 2024-01-26

* Update Django dependency to `>=4.0,<5.0`

## [2.1.4][] - 2022-08-16

* Update PyJWT version to >= `2.4.0` to [address vulnerability](https://security.snyk.io/vuln/SNYK-PYTHON-PYJWT-2840625)
Expand Down Expand Up @@ -82,7 +86,9 @@ This is a hotfix release to fix a broken pypi build.

Initial release.

[unreleased]: https://github.com/cloud-gov/cg-django-uaa/compare/v2.1.0...HEAD
[unreleased]: https://github.com/cloud-gov/cg-django-uaa/compare/v2.1.5...HEAD
[2.1.5]: https://github.com/cloud-gov/cg-django-uaa/compare/v2.1.4...v2.1.5
[2.1.4]: https://github.com/cloud-gov/cg-django-uaa/compare/v2.1.3...v2.1.4
[2.1.3]: https://github.com/cloud-gov/cg-django-uaa/compare/v2.1.2...v2.1.3
[2.1.2]: https://github.com/cloud-gov/cg-django-uaa/compare/v2.1.1...v2.1.2
[2.1.1]: https://github.com/cloud-gov/cg-django-uaa/compare/v2.1.0...v2.1.1
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ RUN pip install cg-django-uaa-${version}.tar.gz && \

COPY example /example

# Remove existing database from local testing, if any,
# otherwise superuser creation below will fail
RUN rm /example/db.sqlite3

WORKDIR /example

RUN python manage.py migrate && \
Expand Down
14 changes: 7 additions & 7 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ Here's how to issue a new release:

1. Bump the version number in `uaa_client/__init__.py`.

2. Move the "unreleased" section to a new version entry in
1. Move the "unreleased" section to a new version entry in
`CHANGELOG.md`.

3. From the project root, install dependencies and run automated tests:
1. From the project root, install dependencies and run automated tests:

```shell
tox
```

4. Run the following to ensure that everything builds and
1. Run the following to ensure that everything builds and
installs OK in an isolated environment:

```shell
Expand All @@ -25,10 +25,10 @@ Here's how to issue a new release:
You should be able to visit <http://localhost:8000> and log in
as `[email protected]` without any problems.

5. Commit and push your changes with a commit message like
1. Commit and push your changes with a commit message like
"Bump version to v1.0.4."

6. Tag your version and push it to GitHub. For instance, if you're
1. Tag your version and push it to GitHub. For instance, if you're
releasing v1.0.4, do:

```shell
Expand All @@ -41,7 +41,7 @@ Here's how to issue a new release:
`CHANGELOG.md` for this, as whatever you enter will
show up on the [GitHub releases page][].

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

```conf
Expand All @@ -55,7 +55,7 @@ Here's how to issue a new release:
password: <your password>
```

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

[GitHub releases page]: https://github.com/18F/cg-django-uaa/releases
Expand Down
149 changes: 149 additions & 0 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
---
jobs:

- name: run-tests
plan:
- in_parallel:
- get: cg-django-uaa-pr
trigger: true
- get: general-task
- put: cg-django-uaa-pr
params:
path: cg-django-uaa-pr
status: pending
- task: run-tests
image: general-task
file: cg-django-uaa-pr/ci/run-tests.yml
on_failure:
put: cg-django-uaa-pr
params:
path: cg-django-uaa-pr
status: failure
on_success:
put: cg-django-uaa-pr
params:
path: cg-django-uaa-pr
status: success

- name: set-self
plan:
- get: cg-django-uaa-repo-tag
trigger: true
- set_pipeline: self
file: cg-django-uaa-repo-tag/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
on_failure:
put: slack
params:
text: |
:x: FAILED to release cg-django-uaa
<$ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME|View build details>
channel: ((slack-failure-channel))
username: ((slack-username))
icon_url: ((slack-icon-url))
on_success:
put: slack
params:
text: |
:white_check_mark: Successfully released cg-django-uaa
<$ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME|View build details>
channel: ((slack-success-channel))
username: ((slack-username))
icon_url: ((slack-icon-url))

resources:
- name: cg-django-uaa-pr
type: pull-request
check_every: 1m
source:
repository: cloud-gov/cg-django-uaa
access_token: ((status-access-token))
disable_forks: true

# 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]+)$'
commit_verification_keys: ((cloud-gov-pgp-keys))

# This resource for posting to slack
- name: slack
type: slack-notification
source:
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: general-task
type: registry-image
source:
aws_access_key_id: ((ecr_aws_key))
aws_secret_access_key: ((ecr_aws_secret))
repository: general-task
aws_region: us-gov-west-1
tag: latest

resource_types:
- name: registry-image
type: registry-image
source:
aws_access_key_id: ((ecr_aws_key))
aws_secret_access_key: ((ecr_aws_secret))
repository: registry-image-resource
aws_region: us-gov-west-1
tag: latest

- name: slack-notification
type: registry-image
source:
aws_access_key_id: ((ecr_aws_key))
aws_secret_access_key: ((ecr_aws_secret))
repository: slack-notification-resource
aws_region: us-gov-west-1
tag: latest

- name: git
type: registry-image
source:
aws_access_key_id: ((ecr_aws_key))
aws_secret_access_key: ((ecr_aws_secret))
repository: git-resource
aws_region: us-gov-west-1
tag: latest

- name: pull-request
type: registry-image
source:
aws_access_key_id: ((ecr_aws_key))
aws_secret_access_key: ((ecr_aws_secret))
repository: github-pr-resource
aws_region: us-gov-west-1
tag: latest

- name: github-release
type: registry-image
source:
repository: concourse/github-release-resource
4 changes: 4 additions & 0 deletions ci/prepare-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

TAG=$(git describe --tags)
echo "$TAG" > tag
12 changes: 12 additions & 0 deletions ci/prepare-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/prepare-release.sh
10 changes: 10 additions & 0 deletions ci/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

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

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

# run tests
tox
9 changes: 9 additions & 0 deletions ci/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
platform: linux

inputs:
- name: cg-django-uaa-pr

run:
dir: cg-django-uaa-pr
path: ci/run-tests.sh
12 changes: 7 additions & 5 deletions example/example/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""

import django
from django.shortcuts import render, redirect
from django.conf.urls import url, include
from django.conf.urls import include
from django.urls import re_path
from django.contrib import admin, auth

from uaa_client.decorators import staff_login_required
Expand All @@ -38,8 +40,8 @@ def logout(request):
_kwargs["namespace"] = "uaa_client"

urlpatterns = [
url(r"^$", index),
url(r"^admin/", admin.site.urls),
url(r"^auth/", include("uaa_client.urls", **_kwargs)),
url(r"^logout/", logout, name="logout"),
re_path(r"^$", index),
re_path(r"^admin/", admin.site.urls),
re_path(r"^auth/", include("uaa_client.urls", **_kwargs)),
re_path(r"^logout/", logout, name="logout"),
]
25 changes: 11 additions & 14 deletions example/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@
import os
import sys

if __name__ == "__main__":
def main():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == "__main__":
main()
Loading

0 comments on commit 5cca5e1

Please sign in to comment.