Skip to content

Commit

Permalink
Merge pull request #830 from UW-GAC/main
Browse files Browse the repository at this point in the history
Deploy to stage
  • Loading branch information
amstilp authored Nov 8, 2024
2 parents e252ade + d637f51 commit 8d1889b
Show file tree
Hide file tree
Showing 21 changed files with 457 additions and 148 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ jobs:
steps:

- name: Checkout Code Repository
uses: actions/checkout@v4
uses: actions/checkout@v4.2.2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v5.3.0
with:
python-version: ${{ matrix.python-version }}
cache: pip
Expand Down Expand Up @@ -93,27 +93,28 @@ jobs:
- name: Run tests
run: |
pytest --cov=primed -n auto
mv .coverage .coverage-${{ strategy.job-index }}
mv .coverage coverage-${{ strategy.job-index }}
- name: List files for debugging purposes
run: ls -lhta

- name: Upload coverage data
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v4.4.3
with:
name: coverage-data-${{ strategy.job-index }}
path: .coverage-${{ strategy.job-index }}
path: coverage-${{ strategy.job-index }}
if-no-files-found: error

coverage:
needs:
- test
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
uses: actions/checkout@v4.2.2

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v5.3.0
with:
python-version: '3.10'

Expand All @@ -123,13 +124,14 @@ jobs:
pip install --upgrade coverage "django<4" django-coverage-plugin
- name: Download coverage data
uses: actions/download-artifact@v4
uses: actions/download-artifact@v4.1.8
with:
path: ./artifacts/

- name: Merge coverage files
run: |
python -m coverage combine ./artifacts/coverage-data*/.coverage-*
ls -la ./artifacts/coverage-data*
python -m coverage combine ./artifacts/coverage-data*/coverage-*
python -m coverage xml
ls -la .coverage*
Expand All @@ -138,6 +140,6 @@ jobs:
python -m coverage report
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v4.6.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
4 changes: 1 addition & 3 deletions .github/workflows/combine-prs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Combine PRs

on:
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
Expand All @@ -18,7 +16,7 @@ jobs:
steps:
- name: combine-prs
id: combine-prs
uses: github/combine-prs@v5.1.0
uses: github/combine-prs@v5.2.0
with:
labels: combined-pr # Optional: add a label to the combined PR
ci_required: true # require all checks to pass before combining
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
name: gitleaks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@v2
- uses: gitleaks/gitleaks-action@v2.3.7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}} # Only required for Organizations, not personal accounts.
6 changes: 3 additions & 3 deletions .github/workflows/pip-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ jobs:

steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
uses: actions/checkout@v4.2.2
with:
ref: ${{ github.head_ref }}

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v5.3.0
with:
python-version: "3.10"

- name: Update requirements files
uses: UW-GAC/pip-tools-actions/update-requirements-files@v0.1
uses: UW-GAC/pip-tools-actions/update-requirements-files@v0.2
with:
requirements_files: |-
requirements/requirements.in
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
exclude: 'docs|node_modules|migrations|.git|.tox'
default_stages: [commit]
default_stages: [pre-commit]
fail_fast: true

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml

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

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

Expand Down
1 change: 1 addition & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
"maintenance_mode.middleware.MaintenanceModeMiddleware",
"simple_history.middleware.HistoryRequestMiddleware",
"django_htmx.middleware.HtmxMiddleware",
"allauth.account.middleware.AccountMiddleware",
]

# STATIC
Expand Down
2 changes: 1 addition & 1 deletion primed/cdsa/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Meta:
model = models.AgreementMajorVersion
django_get_or_create = ("version",)

version = Faker("random_int", min=1)
version = Sequence(lambda n: n + 1)


class AgreementVersionFactory(DjangoModelFactory):
Expand Down
12 changes: 11 additions & 1 deletion primed/drupal_oauth_provider/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

from allauth.account.models import EmailAddress
from allauth.socialaccount import app_settings, providers
from allauth.socialaccount.adapter import get_adapter
from allauth.socialaccount.providers.base import ProviderAccount
from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured

from .views import CustomAdapter

logger = logging.getLogger(__name__)

DRUPAL_PROVIDER_ID = "drupal_oauth_provider"
Expand All @@ -24,9 +27,16 @@ class CustomAccount(ProviderAccount):


class CustomProvider(OAuth2Provider):
id = "drupal_oauth_provider"
id = DRUPAL_PROVIDER_ID
name = OVERRIDE_NAME
account_class = CustomAccount
oauth2_adapter_class = CustomAdapter
supports_token_authentication = True

def __init__(self, request, app=None):
if app is None:
app = get_adapter().get_app(request, self.id)
super().__init__(request, app=app)

def extract_uid(self, data):
return str(data["sub"])
Expand Down
Loading

0 comments on commit 8d1889b

Please sign in to comment.