Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy to stage #518

Merged
merged 54 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
343ade0
Bump virtualenv from 20.25.0 to 20.25.1
dependabot[bot] Feb 25, 2024
eb3e7ce
Bump responses from 0.24.1 to 0.25.0
dependabot[bot] Feb 25, 2024
78c4ccf
Bump pylint from 3.0.3 to 3.1.0
dependabot[bot] Feb 25, 2024
90f8f2b
Allow more direct dependencies only
amstilp Feb 28, 2024
0dd7c39
Add a workflow to combine dependabot PRs
amstilp Feb 28, 2024
ad58d26
Merge pull request #497 from UW-GAC/maint/combine-dependabot-prs
amstilp Feb 28, 2024
ac1a939
Bump coverage from 7.4.1 to 7.4.3
dependabot[bot] Feb 28, 2024
15223ac
Bump django-simple-history from 3.4.0 to 3.5.0
dependabot[bot] Feb 28, 2024
7eed5fe
Bump pytest from 8.0.1 to 8.0.2
dependabot[bot] Feb 28, 2024
5f40a95
Only combine "dependency" PRs
amstilp Feb 28, 2024
2c0d759
Merge pull request #501 from UW-GAC/maint/combine-dependabot-prs
amstilp Feb 28, 2024
d0837fc
Merge dependabot/pip/pytest-8.0.2 into combined-prs-branch
github-actions[bot] Feb 28, 2024
ff3880c
Merge dependabot/pip/django-simple-history-3.5.0 into combined-prs-br…
github-actions[bot] Feb 28, 2024
ccf93f4
Merge dependabot/pip/coverage-7.4.3 into combined-prs-branch
github-actions[bot] Feb 28, 2024
b1410ad
Merge dependabot/pip/pylint-3.1.0 into combined-prs-branch
github-actions[bot] Feb 28, 2024
7754659
Merge dependabot/pip/responses-0.25.0 into combined-prs-branch
github-actions[bot] Feb 28, 2024
c2a5c92
Merge dependabot/pip/virtualenv-20.25.1 into combined-prs-branch
github-actions[bot] Feb 28, 2024
ba2bbe2
Merge branch 'main' into combined-prs-branch
github-actions[bot] Feb 28, 2024
9cbb007
Merge pull request #502 from UW-GAC/combined-prs-branch
amstilp Feb 28, 2024
5ce1577
Bump crispy-bootstrap5 from 2023.10 to 2024.2
dependabot[bot] Feb 28, 2024
a88d349
Bump django-autocomplete-light from 3.9.4 to 3.11.0
dependabot[bot] Feb 28, 2024
c6e6ec5
Merge dependabot/pip/crispy-bootstrap5-2024.2 into combined-prs-branch
github-actions[bot] Mar 4, 2024
4da54a1
Merge dependabot/pip/django-autocomplete-light-3.11.0 into combined-p…
github-actions[bot] Mar 4, 2024
b49e24c
Merge branch 'main' into combined-prs-branch
github-actions[bot] Mar 4, 2024
0cecb66
Fix select_label input to combine-prs workflow
amstilp Mar 4, 2024
08084f5
Merge branch 'main' into combined-prs-branch
github-actions[bot] Mar 4, 2024
d66adb0
Merge pull request #504 from UW-GAC/maint/fix-combine-prs-select-label
amstilp Mar 4, 2024
263bdae
Merge pull request #503 from UW-GAC/combined-prs-branch
amstilp Mar 4, 2024
d9ceee7
Do not autoclose PRs after combined PR is merged
amstilp Mar 8, 2024
4e73bf4
Merge pull request #505 from UW-GAC/maint/combine-prs-autoclose-false
amstilp Mar 8, 2024
2680da9
Bump pytest from 8.0.2 to 8.1.1
dependabot[bot] Mar 10, 2024
83a053d
Bump pip-tools from 7.4.0 to 7.4.1
dependabot[bot] Mar 10, 2024
47c4183
Bump types-requests from 2.31.0.20240218 to 2.31.0.20240310
dependabot[bot] Mar 10, 2024
32d8a24
Bump django from 4.2.10 to 4.2.11
dependabot[bot] Mar 10, 2024
f7c7dfd
Bump mypy from 1.8.0 to 1.9.0
dependabot[bot] Mar 10, 2024
5721d5c
Merge dependabot/pip/mypy-1.9.0 into combined-prs-branch
github-actions[bot] Mar 11, 2024
3bfeb6a
Merge dependabot/pip/django-4.2.11 into combined-prs-branch
github-actions[bot] Mar 11, 2024
359ab01
Merge dependabot/pip/types-requests-2.31.0.20240310 into combined-prs…
github-actions[bot] Mar 11, 2024
f72adac
Merge dependabot/pip/pip-tools-7.4.1 into combined-prs-branch
github-actions[bot] Mar 11, 2024
e5c8359
Merge dependabot/pip/pytest-8.1.1 into combined-prs-branch
github-actions[bot] Mar 11, 2024
c2531f3
Merge branch 'main' into combined-prs-branch
github-actions[bot] Mar 11, 2024
5ff644c
Merge pull request #511 from UW-GAC/combined-prs-branch
amstilp Mar 11, 2024
6143a43
Bump coverage from 7.4.3 to 7.4.4
dependabot[bot] Mar 17, 2024
f83341a
Bump types-requests from 2.31.0.20240310 to 2.31.0.20240311
dependabot[bot] Mar 17, 2024
b0b607d
Bump black from 24.2.0 to 24.3.0
dependabot[bot] Mar 17, 2024
dd47bda
Merge dependabot/pip/black-24.3.0 into combined-prs-branch
github-actions[bot] Mar 18, 2024
591d942
Merge dependabot/pip/types-requests-2.31.0.20240311 into combined-prs…
github-actions[bot] Mar 18, 2024
ae792cc
Merge dependabot/pip/coverage-7.4.4 into combined-prs-branch
github-actions[bot] Mar 18, 2024
d166534
Merge branch 'main' into combined-prs-branch
github-actions[bot] Mar 18, 2024
b2bb004
Merge pull request #515 from UW-GAC/combined-prs-branch
amstilp Mar 21, 2024
c1a2589
Add django-constance to requirements
amstilp Mar 22, 2024
6ad19ec
Add constance to the settings file
amstilp Mar 22, 2024
5fabb6f
Show site announcement if ANNOUNCEMENT_TEXT is set
amstilp Mar 22, 2024
9366857
Merge pull request #517 from UW-GAC/feature/banner-announcement
amstilp Mar 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ updates:
interval: "weekly"
day: "sunday"
allow:
# Allow both direct and indirect updates for all packages
- dependency-type: "all"
# Allow up to 10 dependencies for pip dependencies
open-pull-requests-limit: 10
# Allow only direct dependencies - should be ok with pip-sync?
- dependency-type: "direct"
# Allow up to 20 dependencies for pip dependencies
open-pull-requests-limit: 20
147 changes: 17 additions & 130 deletions .github/workflows/combine-prs.yml
Original file line number Diff line number Diff line change
@@ -1,139 +1,26 @@
name: 'Combine PRs'
name: Combine PRs

# Controls when the action will run - in this case triggered manually
on:
workflow_dispatch:
inputs:
branchPrefix:
description: 'Branch prefix to find combinable PRs based on'
required: true
default: 'dependabot'
mustBeGreen:
description: 'Only combine PRs that are green (status is success)'
required: true
default: true
combineBranchName:
description: 'Name of the branch to combine PRs into'
required: true
default: 'combine-prs-branch'
ignoreLabel:
description: 'Exclude PRs with this label'
required: true
default: 'nocombine'
schedule:
- cron: '0 8 * * 1' # Monday at 08:00 UTC
workflow_dispatch: # allows you to manually trigger the workflow

# The minimum permissions required to run this Action
permissions:
contents: write
pull-requests: write
checks: read

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "combine-prs"
combine-prs:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/github-script@v7
id: fetch-branch-names
name: Fetch branch names
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const pulls = await github.paginate('GET /repos/:owner/:repo/pulls', {
owner: context.repo.owner,
repo: context.repo.repo
});
branches = [];
prs = [];
base_branch = null;
for (const pull of pulls) {
const branch = pull['head']['ref'];
console.log('Pull for branch: ' + branch);
if (branch.startsWith('${{ github.event.inputs.branchPrefix }}')) {
console.log('Branch matched: ' + branch);
statusOK = true;
if(${{ github.event.inputs.mustBeGreen }}) {
console.log('Checking green status: ' + branch);
const checkRuns = await github.request('GET /repos/{owner}/{repo}/commits/{ref}/check-runs', {
owner: context.repo.owner,
repo: context.repo.repo,
ref: branch
});
for await (const cr of checkRuns.data.check_runs) {
console.log('Validating check conclusion: ' + cr.conclusion);
if(cr.conclusion != 'success') {
console.log('Discarding ' + branch + ' with check conclusion ' + cr.conclusion);
statusOK = false;
}
}
}
console.log('Checking labels: ' + branch);
const labels = pull['labels'];
for(const label of labels) {
const labelName = label['name'];
console.log('Checking label: ' + labelName);
if(labelName == '${{ github.event.inputs.ignoreLabel }}') {
console.log('Discarding ' + branch + ' with label ' + labelName);
statusOK = false;
}
}
if (statusOK) {
console.log('Adding branch to array: ' + branch);
branches.push(branch);
prs.push('#' + pull['number'] + ' ' + pull['title']);
base_branch = pull['base']['ref'];
}
}
}

if (branches.length == 0) {
core.setFailed('No PRs/branches matched criteria');
return;
}

core.setOutput('base-branch', base_branch);
core.setOutput('prs-string', prs.join('\n'));

combined = branches.join(' ')
console.log('Combined: ' + combined);
return combined
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Creates a branch with other PR branches merged together
- name: Created combined branch
env:
BASE_BRANCH: ${{ steps.fetch-branch-names.outputs.base-branch }}
BRANCHES_TO_COMBINE: ${{ steps.fetch-branch-names.outputs.result }}
COMBINE_BRANCH_NAME: ${{ github.event.inputs.combineBranchName }}
run: |
echo "${{steps.fetch-branch-names.outputs.result}}"
sourcebranches="${BRANCHES_TO_COMBINE%\"}"
sourcebranches="${sourcebranches#\"}"

basebranch="${BASE_BRANCH%\"}"
basebranch="${basebranch#\"}"

git config pull.rebase false
git config user.name github-actions
git config user.email [email protected]

git branch $COMBINE_BRANCH_NAME $basebranch
git checkout $COMBINE_BRANCH_NAME
git pull origin $sourcebranches --no-edit
git push origin $COMBINE_BRANCH_NAME
# Creates a PR with the new combined branch
- uses: actions/github-script@v7
name: Create Combined Pull Request
- name: combine-prs
id: combine-prs
uses: github/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const prString = `${{ steps.fetch-branch-names.outputs.prs-string }}`;
const body = 'This PR was created by the Combine PRs action by combining the following PRs:\n' + prString;
await github.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Combined PR',
head: '${{ github.event.inputs.combineBranchName }}',
base: '${{ steps.fetch-branch-names.outputs.base-branch }}',
body: body
});

labels: combined-pr # Optional: add a label to the combined PR
ci_required: true # require all checks to pass before combining
select_label: dependencies # Optional: only combine PRs with this label
autoclose: false # do not close the source PRs - dependabot should handle it.
13 changes: 13 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"dal_select2",
"fontawesomefree",
"simple_history",
"constance",
]

LOCAL_APPS = [
Expand Down Expand Up @@ -198,6 +199,7 @@
"django.template.context_processors.static",
"django.template.context_processors.tz",
"django.contrib.messages.context_processors.messages",
"constance.context_processors.config",
"gregor_django.utils.context_processors.settings_context",
],
},
Expand Down Expand Up @@ -362,6 +364,17 @@
# https://django-tables2.readthedocs.io/en/latest/pages/custom-rendering.html?highlight=django_tables2_template#available-templates
DJANGO_TABLES2_TEMPLATE = "django_tables2/bootstrap5.html"

# django-constance
# ------------------------------------------------------------------------------
CONSTANCE_CONFIG = {
"ANNOUNCEMENT_TEXT": ("", "Site-wide announcement message", str),
}

CONSTANCE_BACKEND = "constance.backends.database.DatabaseBackend"
CONSTANCE_IGNORE_ADMIN_VERSION_CHECK = True
# CONSTANCE_DATABASE_CACHE_BACKEND = "default"
CONSTANCE_DATABASE_CACHE_AUTOFILL_TIMEOUT = None

# django-anvil-consortium-manager
# ------------------------------------------------------------------------------
# Specify the path to the service account to use for managing access on AnVIL.
Expand Down
21 changes: 21 additions & 0 deletions gregor_django/gregor_anvil/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from anvil_consortium_manager.models import AnVILProjectManagerAccess
from anvil_consortium_manager.tests import factories as acm_factories
from anvil_consortium_manager.tests.utils import AnVILAPIMockTestMixin
from constance.test import override_config
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Permission
Expand Down Expand Up @@ -96,6 +97,26 @@ def test_acm_link_with_edit_but_not_view_permission(self):
reverse("anvil_consortium_manager:index"), response.rendered_content
)

def test_site_announcement_no_text(self):
user = User.objects.create_user(username="test-none", password="test-none")
self.client.force_login(user)
response = self.client.get(self.get_url())
self.assertNotContains(response, """id="alert-announcement""")

@override_config(ANNOUNCEMENT_TEXT="This is a test announcement")
def test_site_announcement_text(self):
user = User.objects.create_user(username="test-none", password="test-none")
self.client.force_login(user)
response = self.client.get(self.get_url())
self.assertContains(response, """id="alert-announcement""")
self.assertContains(response, "This is a test announcement")

@override_config(ANNOUNCEMENT_TEXT="This is a test announcement")
def test_site_announcement_text_unauthenticated_user(self):
response = self.client.get(self.get_url(), follow=True)
self.assertContains(response, """id="alert-announcement""")
self.assertContains(response, "This is a test announcement")


class ConsentGroupDetailTest(TestCase):
"""Tests for the ConsentGroupDetail view."""
Expand Down
13 changes: 11 additions & 2 deletions gregor_django/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,26 @@
</div>
</nav>

{% block extra_navbar %}
{% endblock %}
<main class="flex-shrink-0">
<div class="container">

{% if config.ANNOUNCEMENT_TEXT %}
<div class="alert alert-info my-3" role="alert" id="alert-announcement">
<i class="bi bi-megaphone-fill me-1"></i>
{{ config.ANNOUNCEMENT_TEXT }}
</div>
{% endif %}

{% if messages %}
{% for message in messages %}
<div class="alert {% if message.tags %}alert-{{ message.tags }}{% endif %} alert-dismissible fade show" role="alert">{{ message }}<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>
{% endfor %}
{% endif %}

{% block extra_navbar %}
{% endblock %}


{% block content %}

<div class="my-3 alert alert-warning" role="alert">
Expand Down
12 changes: 6 additions & 6 deletions requirements/dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ asgiref==3.7.2
# via
# -c requirements/requirements.txt
# django
astroid==3.0.3
astroid==3.1.0
# via pylint
asttokens==2.4.1
# via stack-data
Expand All @@ -22,7 +22,7 @@ backports-zoneinfo==0.2.1
# via
# -c requirements/requirements.txt
# django
black==24.2.0
black==24.3.0
# via -r requirements/dev-requirements.in
certifi==2023.7.22
# via
Expand Down Expand Up @@ -50,7 +50,7 @@ dill==0.3.8
# via pylint
distlib==0.3.8
# via virtualenv
django==4.2.10
django==4.2.11
# via
# -c requirements/requirements.txt
# django-debug-toolbar
Expand Down Expand Up @@ -111,7 +111,7 @@ mccabe==0.7.0
# via
# flake8
# pylint
mypy==1.8.0
mypy==1.9.0
# via -r requirements/dev-requirements.in
mypy-extensions==1.0.0
# via
Expand Down Expand Up @@ -154,7 +154,7 @@ pygments==2.17.2
# via
# ipython
# sphinx
pylint==3.0.3
pylint==3.1.0
# via
# pylint-django
# pylint-plugin-utils
Expand Down Expand Up @@ -246,7 +246,7 @@ urllib3==2.1.0
# -c requirements/requirements.txt
# -c requirements/test-requirements.txt
# requests
virtualenv==20.25.0
virtualenv==20.25.1
# via pre-commit
wcwidth==0.2.13
# via prompt-toolkit
Expand Down
4 changes: 4 additions & 0 deletions requirements/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ certifi>=2023.7.22
pyjwt>=2.4.0
urllib3>=1.26.18
sqlparse>=0.4.4

# Dynamic settings
django-constance
django-picklefield # Required by django-constance for database backend
Loading
Loading