Skip to content

Commit

Permalink
Merge pull request #857 from UW-GAC/main
Browse files Browse the repository at this point in the history
Deploy to stage
  • Loading branch information
amstilp authored Dec 6, 2024
2 parents cb139d2 + 436098b commit e1c5a46
Show file tree
Hide file tree
Showing 31 changed files with 1,390 additions and 213 deletions.
13 changes: 13 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sort-direction: ascending

categories:
- title: "⬆️ Dependencies"
labels:
- "dependencies"
- "update-requirements-files"
- "combined-pr"

template: |
## What’s Changed
$CHANGES
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,6 @@ jobs:
python -m coverage report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.6.0
uses: codecov/codecov-action@v5.0.7
with:
token: ${{ secrets.CODECOV_TOKEN }}
114 changes: 114 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Release Drafter

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- deploy/production

permissions:
contents: read

jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: read
runs-on: ubuntu-latest
steps:

- name: Get current date
id: get-date
run: |
export CURRENT_DATE=$(TZ=":America/Los_Angeles" date "+%Y-%m-%d")
echo "current_date=${CURRENT_DATE}" >> $GITHUB_OUTPUT
echo "Current date set to ${CURRENT_DATE}"
- name: Get number of releases for the current date
id: get-release-count
run: |
export RELEASE_COUNT=$(gh release list \
--repo ${{ github.repository }} \
--json tagName \
--exclude-drafts \
--jq "map(select(.tagName | startswith(\"${CURRENT_DATE}\")))|length" \
)
echo "release_count=${RELEASE_COUNT}" >> $GITHUB_OUTPUT
echo "Found ${RELEASE_COUNT} releases"
env:
CURRENT_DATE: ${{ steps.get-date.outputs.current_date }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Prepare release version
id: get-version
run: |
export VERSION="${CURRENT_DATE}"
if [ $RELEASE_COUNT -gt 0 ]; then
echo "Release already exists for version ${VERSION}"
echo "Appending release count to version"
export VERSION="${CURRENT_DATE}-${RELEASE_COUNT}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Version set to ${VERSION}"
env:
CURRENT_DATE: ${{ steps.get-date.outputs.current_date }}
RELEASE_COUNT: ${{ steps.get-release-count.outputs.release_count }}


- name: Check that version doesn't exist
id: check-release
run: |
echo "Checking version ${VERSION}"
export CHECK=$(gh release list \
--repo ${{ github.repository }} \
--json tagName \
--exclude-drafts \
--jq "map(select(.tagName == \"${VERSION}\"))|length" \
)
echo "Found ${CHECK} releases"
if [ $CHECK -gt 0 ]; then
echo "Release already exists for version ${VERSION}"
exit 1
fi
env:
VERSION: ${{ steps.get-version.outputs.version }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check that tag doesn't exist
id: check-tag
run: |
echo "Checking tag for version ${VERSION}"
# Query the API for this tag.
export CHECK=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/tags \
--jq "map(select(.name == \"${VERSION}\"))|length" \
)
echo "Found ${CHECK} tags"
if [ $CHECK -gt 0 ]; then
echo "Tag already exists for version ${VERSION}"
exit 1
fi
env:
VERSION: ${{ steps.get-version.outputs.version }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}


- uses: release-drafter/release-drafter@v6
with:
commitish: deploy/production
tag: ${{ steps.get-version.outputs.version }}
name: ${{ steps.get-version.outputs.version }}
version: ${{ steps.get-version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.7.0
rev: v0.8.1
hooks:
# Run the linter.
- id: ruff
Expand All @@ -21,7 +21,7 @@ repos:
- id: ruff-format

- repo: https://github.com/gitleaks/gitleaks
rev: v8.21.1
rev: v8.21.2
hooks:
- id: gitleaks

Expand Down
22 changes: 11 additions & 11 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
"socialaccount_signup",
"admin:index",
"admin:login",
"favicon",
]

# django-dbbackup
Expand Down Expand Up @@ -345,6 +346,11 @@
"request_scope": True,
"django_group_name": "Approved by PI for AnVIL access",
},
{
"drupal_machine_name": "authenticated",
"request_scope": True,
"django_group_name": "Authenticated",
},
],
}
}
Expand Down Expand Up @@ -375,25 +381,19 @@
# django-anvil-consortium-manager
# ------------------------------------------------------------------------------
ANVIL_WORKSPACE_ADAPTERS = [
"gregor_django.gregor_anvil.adapters.ResourceWorkspaceAdapter",
"gregor_django.gregor_anvil.adapters.TemplateWorkspaceAdapter",
"gregor_django.gregor_anvil.adapters.CombinedConsortiumDataWorkspaceAdapter",
"gregor_django.gregor_anvil.adapters.UploadWorkspaceAdapter",
"gregor_django.gregor_anvil.adapters.ResourceWorkspaceAdapter",
"gregor_django.gregor_anvil.adapters.ExchangeWorkspaceAdapter",
"gregor_django.gregor_anvil.adapters.PartnerUploadWorkspaceAdapter",
"gregor_django.gregor_anvil.adapters.CombinedConsortiumDataWorkspaceAdapter",
"gregor_django.gregor_anvil.adapters.ReleaseWorkspaceAdapter",
"gregor_django.gregor_anvil.adapters.DCCProcessingWorkspaceAdapter",
"gregor_django.gregor_anvil.adapters.DCCProcessedDataWorkspaceAdapter",
"gregor_django.gregor_anvil.adapters.ExchangeWorkspaceAdapter",
"gregor_django.gregor_anvil.adapters.ReleaseWorkspaceAdapter",
"gregor_django.gregor_anvil.adapters.TemplateWorkspaceAdapter",
]
ANVIL_ACCOUNT_ADAPTER = "gregor_django.gregor_anvil.adapters.AccountAdapter"
ANVIL_MANAGED_GROUP_ADAPTER = "gregor_django.gregor_anvil.adapters.ManagedGroupAdapter"

# Specify the URL name that AccountLink and AccountLinkVerify redirect to.
ANVIL_ACCOUNT_LINK_REDIRECT = "users:redirect"
# Specify the subject for AnVIL account verification emails.
ANVIL_ACCOUNT_LINK_EMAIL_SUBJECT = "Verify your AnVIL account email"
ANVIL_ACCOUNT_VERIFY_NOTIFICATION_EMAIL = "[email protected]"

DRUPAL_API_CLIENT_ID = env("DRUPAL_API_CLIENT_ID", default="")
DRUPAL_API_CLIENT_SECRET = env("DRUPAL_API_CLIENT_SECRET", default="")
DRUPAL_API_REL_PATH = env("DRUPAL_API_REL_PATH", default="mockapi")
Expand Down
7 changes: 7 additions & 0 deletions config/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.templatetags.static import static as static_url_tag
from django.urls import include, path
from django.views import defaults as default_views
from django.views.generic import TemplateView
from django.views.generic.base import RedirectView

urlpatterns = [
path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
Expand All @@ -22,6 +24,11 @@
"gregor_anvil/",
include("gregor_django.gregor_anvil.urls", namespace="gregor_anvil"),
),
path(
"favicon.ico",
RedirectView.as_view(url=static_url_tag("images/favicons/favicon_1.jpg"), permanent=True),
name="favicon",
),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


Expand Down
4 changes: 2 additions & 2 deletions gregor_django/drupal_oauth_provider/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get_mocked_response(self):
"name": "testmaster",
"email": "[email protected]",
"email_verified": "True",
"sub": 20122
"sub": "20122"
}""",
),
]
Expand Down Expand Up @@ -184,7 +184,7 @@ def get_id_token(self):
"iat": self.setup_time,
"aud": allowed_audience,
"scope": ["authenticated", "oauth_client_user"],
"sub": 20122,
"sub": "20122",
}
)

Expand Down
12 changes: 9 additions & 3 deletions gregor_django/gregor_anvil/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ class AccountAdapter(BaseAccountAdapter):

list_table_class = tables.AccountTable
list_filterset_class = filters.AccountListFilter
account_link_verify_redirect = "users:redirect"
account_link_email_subject = "Verify your AnVIL account email"
account_verify_notification_email = "[email protected]"

def get_autocomplete_queryset(self, queryset, q):
"""Filter to Accounts where the email or the associated user name matches the query `q`."""
Expand Down Expand Up @@ -115,6 +118,7 @@ class UploadWorkspaceAdapter(WorkspaceAdminSharingAdapterMixin, BaseWorkspaceAda
workspace_data_form_class = forms.UploadWorkspaceForm
workspace_form_class = WorkspaceForm
workspace_detail_template_name = "gregor_anvil/uploadworkspace_detail.html"
workspace_list_template_name = "gregor_anvil/uploadworkspace_list.html"

def get_autocomplete_queryset(self, queryset, q, forwarded={}):
"""Filter to Accounts where the email or the associated user name matches the query `q`."""
Expand All @@ -139,7 +143,7 @@ class PartnerUploadWorkspaceAdapter(WorkspaceAdminSharingAdapterMixin, BaseWorks
name = "Partner upload workspace"
description = "Workspaces that contain data uploaded by a Partner Group "
list_table_class_view = tables.PartnerUploadWorkspaceTable
list_table_class_staff_view = tables.PartnerUploadWorkspaceTable
list_table_class_staff_view = tables.PartnerUploadWorkspaceStaffTable

workspace_data_model = models.PartnerUploadWorkspace
workspace_data_form_class = forms.PartnerUploadWorkspaceForm
Expand All @@ -156,7 +160,7 @@ class ResourceWorkspaceAdapter(WorkspaceAdminSharingAdapterMixin, BaseWorkspaceA
"Workspaces that contain general Consortium resources (e.g., examples of using AnVIL, working with data, etc.)" # noqa: E501
)
list_table_class_view = tables.DefaultWorkspaceTable
list_table_class_staff_view = tables.DefaultWorkspaceTable
list_table_class_staff_view = tables.DefaultWorkspaceStaffTable
workspace_data_model = models.ResourceWorkspace
workspace_data_form_class = forms.ResourceWorkspaceForm
workspace_detail_template_name = "gregor_anvil/resourceworkspace_detail.html"
Expand Down Expand Up @@ -189,6 +193,7 @@ class CombinedConsortiumDataWorkspaceAdapter(WorkspaceAdminSharingAdapterMixin,
workspace_data_form_class = forms.CombinedConsortiumDataWorkspaceForm
workspace_detail_template_name = "gregor_anvil/combinedconsortiumdataworkspace_detail.html"
workspace_form_class = WorkspaceForm
workspace_list_template_name = "gregor_anvil/combinedconsortiumdataworkspace_list.html"


class ReleaseWorkspaceAdapter(WorkspaceAdminSharingAdapterMixin, BaseWorkspaceAdapter):
Expand Down Expand Up @@ -240,8 +245,9 @@ class ExchangeWorkspaceAdapter(WorkspaceAdminSharingAdapterMixin, BaseWorkspaceA
name = "Exchange workspace"
description = "Workspaces for exchanging data with a Research Center outside of an upload cycle"
list_table_class_view = tables.ExchangeWorkspaceTable
list_table_class_staff_view = tables.ExchangeWorkspaceTable
list_table_class_staff_view = tables.ExchangeWorkspaceStaffTable
workspace_data_model = models.ExchangeWorkspace
workspace_data_form_class = forms.ExchangeWorkspaceForm
workspace_form_class = WorkspaceForm
workspace_detail_template_name = "gregor_anvil/exchangeworkspace_detail.html"
workspace_list_template_name = "gregor_anvil/exchangeworkspace_list.html"
Loading

0 comments on commit e1c5a46

Please sign in to comment.