diff --git a/.devcontainer/server/.env.server b/.devcontainer/server/.env.server index 2f1c56123..529195460 100644 --- a/.devcontainer/server/.env.server +++ b/.devcontainer/server/.env.server @@ -1,2 +1 @@ ELIGIBILITY_SERVER_SETTINGS=/.devcontainer/server/settings.py -FLASK_APP=eligibility_server/app.py diff --git a/.devcontainer/server/settings.py b/.devcontainer/server/settings.py index 9b2eba4df..4027bb479 100644 --- a/.devcontainer/server/settings.py +++ b/.devcontainer/server/settings.py @@ -4,14 +4,14 @@ # Eligibility Verification settings -CLIENT_KEY_PATH = "https://raw.githubusercontent.com/cal-itp/eligibility-server/dev/keys/client.pub" -SERVER_PRIVATE_KEY_PATH = "https://raw.githubusercontent.com/cal-itp/eligibility-server/dev/keys/server.key" -SERVER_PUBLIC_KEY_PATH = "https://raw.githubusercontent.com/cal-itp/eligibility-server/dev/keys/server.pub" +CLIENT_KEY_PATH = "https://raw.githubusercontent.com/cal-itp/eligibility-server/main/keys/client.pub" +SERVER_PRIVATE_KEY_PATH = "https://raw.githubusercontent.com/cal-itp/eligibility-server/main/keys/server.key" +SERVER_PUBLIC_KEY_PATH = "https://raw.githubusercontent.com/cal-itp/eligibility-server/main/keys/server.pub" SUB_FORMAT_REGEX = r".+" # Data settings -IMPORT_FILE_PATH = "https://raw.githubusercontent.com/cal-itp/eligibility-server/dev/data/server.csv" +IMPORT_FILE_PATH = "https://raw.githubusercontent.com/cal-itp/eligibility-server/main/data/server.csv" INPUT_HASH_ALGO = "" # CSV-specific settings diff --git a/.github/ISSUE_TEMPLATE/release.yml b/.github/ISSUE_TEMPLATE/release.yml index 24e0045cd..f77ec12e5 100644 --- a/.github/ISSUE_TEMPLATE/release.yml +++ b/.github/ISSUE_TEMPLATE/release.yml @@ -14,6 +14,9 @@ body: Each release is coordinated by a **Release Manager**. The release manager may assign sub-tasks or ask for help as-needed, but is otherwise responsible for all aspects of the release. + Each release also identifies a **Smoke Tester** responsible for carrying out the [Smoke Tests according to our + established procedure](https://docs.google.com/document/d/1ADXWW4mfLJwLKVqtVemPNX9yTqYKqIWfCz1DipAU02g/edit). + After this issue is created, use the checklist to manage the steps of the release process, marking items as completed. [Read more about the release process](https://docs.calitp.org/benefits/deployment/release/). @@ -29,6 +32,14 @@ body: placeholder: "@cal-itp-bot" validations: required: true + - type: input + id: smoke-tester + attributes: + label: Smoke tester + description: GitHub handle of who is responsible for smoke testing this release + placeholder: "@cal-itp-bot" + validations: + required: true - type: input id: version attributes: @@ -76,7 +87,8 @@ body: - label: QA the app in test - label: Ensure `prod` secrets are up to date - label: Open a PR for the `test` branch into `prod`, merge - - label: QA the app in prod + - label: Smoke Test the app in prod + - label: Confirm acceptance of Smoke Tests by adding a comment to this issue - label: Tag the release on the `prod` branch, push the tag to GitHub (see [docs](https://docs.calitp.org/benefits/deployment/release/#5-tag-the-release) for commands) - label: Create a release in GitHub for the tag, generating release notes - label: Edit release notes with additional context, images, animations, etc. as-needed @@ -90,7 +102,8 @@ body: - label: Bump the application version - label: Ensure `prod` secrets are up to date - label: Open a PR from the hotfix branch into `prod`, merge - - label: QA the fix in prod + - label: Smoke Test the fix in prod + - label: Confirm acceptance of Smoke Tests by adding a comment to this issue - label: Tag the release on `prod`, push the tag to GitHub (see [docs](https://docs.calitp.org/benefits/deployment/release/#5-tag-the-release) for commands) - label: Create a release in GitHub for the tag, generating release notes - label: Edit release notes with additional context, images, animations, etc. as-needed diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 747a33f70..82d93655f 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -33,7 +33,7 @@ jobs: uses: actions/checkout@v4 - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -42,4 +42,4 @@ jobs: # queries: ./path/to/local/query, your-org/your-repo/queries@main - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0eff8aa05..5dadca811 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,7 +22,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version-file: .github/workflows/.python-version cache: pip diff --git a/.github/workflows/mkdocs.yml b/.github/workflows/mkdocs.yml index 0da72978b..248332173 100644 --- a/.github/workflows/mkdocs.yml +++ b/.github/workflows/mkdocs.yml @@ -8,25 +8,81 @@ on: - completed branches: - dev + pull_request: + branches: + - dev + paths: + - "docs/**" + - "mkdocs.yml" + - ".github/workflows/mkdocs.yml" push: branches: - dev paths: - - 'docs/**' - - 'mkdocs.yml' - - '.github/workflows/mkdocs.yml' + - "docs/**" + - "mkdocs.yml" + - ".github/workflows/mkdocs.yml" jobs: + docs-preview: + name: Publish docs preview + runs-on: ubuntu-latest + # only pull requests should generate a preview + if: github.event.pull_request + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: "refs/pull/${{ github.event.number }}/merge" + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version-file: .github/workflows/.python-version + cache: pip + cache-dependency-path: "docs/requirements.txt" + + - name: Build MkDocs website + run: | + pip install -r docs/requirements.txt + mkdocs build + + - name: Install Netlify CLI + run: npm install --location=global netlify-cli + + - name: Deploy Preview to Netlify + run: | + netlify deploy \ + --dir="site" \ + --alias="${GITHUB_REPOSITORY#*/}-${{ github.event.number }}" + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_PREVIEW_APP_SITE_ID }} + + - name: Add Netlify link PR comment + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const hostnameSuffix = "cal-itp-previews.netlify.app" + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `Preview url: https://${context.repo.repo}-${{ github.event.number }}--${hostnameSuffix}`, + }) + docs: name: Publish docs runs-on: ubuntu-latest - if: github.event.workflow_run == null || github.event.workflow_run.conclusion == 'success' + # don't publish for pull requests, and also not for unsuccessful (triggering) workflow runs + if: github.event.pull_request == null && (github.event.workflow_run == null || github.event.workflow_run.conclusion == 'success') steps: - name: Checkout uses: actions/checkout@v4 - name: Download coverage report - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v3 with: workflow: tests-pytest.yml branch: dev diff --git a/.github/workflows/tests-cypress.yml b/.github/workflows/tests-cypress.yml index d412423a2..17420a0c0 100644 --- a/.github/workflows/tests-cypress.yml +++ b/.github/workflows/tests-cypress.yml @@ -27,7 +27,7 @@ jobs: working-directory: tests/cypress wait-on: http://localhost:8000/healthcheck - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: failure() with: name: cypress-screenshots diff --git a/.github/workflows/tests-pytest.yml b/.github/workflows/tests-pytest.yml index 531c318c3..351e014c8 100644 --- a/.github/workflows/tests-pytest.yml +++ b/.github/workflows/tests-pytest.yml @@ -22,7 +22,7 @@ jobs: sudo apt-get update -y sudo apt-get install -y gettext - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version-file: .github/workflows/.python-version cache: pip @@ -38,7 +38,7 @@ jobs: run: ./tests/pytest/run.sh - name: Upload coverage report - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: coverage-report path: benefits/static/coverage diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0f67df768..054f7687d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ default_stages: repos: - repo: https://github.com/compilerla/conventional-pre-commit - rev: v3.0.0 + rev: v3.1.0 hooks: - id: conventional-pre-commit stages: [commit-msg] @@ -34,33 +34,33 @@ repos: args: ["--maxkb=1500"] - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 24.1.1 hooks: - id: black types: - python - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 + rev: 7.0.0 hooks: - id: flake8 types: - python - repo: https://github.com/pycqa/bandit - rev: 1.7.5 + rev: 1.7.7 hooks: - id: bandit args: ["-ll"] files: .py$ - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.1.0 + rev: v4.0.0-alpha.8 hooks: - id: prettier types_or: [javascript, css] - repo: https://github.com/Riverside-Healthcare/djLint - rev: v1.34.0 + rev: v1.34.1 hooks: - id: djlint-django diff --git a/README.md b/README.md index ec0dd1f00..256d59885 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Benefits +![Cal-ITP Benefits - Landing - Laptop+Mobile](https://github.com/cal-itp/benefits/assets/6279581/3f5c558b-ad45-49cd-bb51-b230c625837b) -Cal-ITP Benefits is an application that enables automated eligibility verification and enrollment for transit benefits onto customers’ existing contactless bank (credit/debit) cards. +Cal-ITP Benefits is a web application that enables digital eligibility verification and enrollment for transit benefits onto transit riders’ existing contactless debit and credit cards. View the technical documentation online: diff --git a/benefits/core/admin.py b/benefits/core/admin.py index 8de5ac2ec..c6744e380 100644 --- a/benefits/core/admin.py +++ b/benefits/core/admin.py @@ -1,6 +1,7 @@ """ The core application: Admin interface configuration. """ + from django.conf import settings diff --git a/benefits/core/analytics.py b/benefits/core/analytics.py index de3d8f86c..d998571a4 100644 --- a/benefits/core/analytics.py +++ b/benefits/core/analytics.py @@ -1,6 +1,7 @@ """ The core application: analytics implementation. """ + import itertools import json import logging diff --git a/benefits/core/apps.py b/benefits/core/apps.py index 4f8b9243d..33f0461dd 100644 --- a/benefits/core/apps.py +++ b/benefits/core/apps.py @@ -1,6 +1,7 @@ """ The core application: Houses base templates and reusable models and components. """ + from django.apps import AppConfig diff --git a/benefits/core/context_processors.py b/benefits/core/context_processors.py index 2d3032cf3..958ac6d57 100644 --- a/benefits/core/context_processors.py +++ b/benefits/core/context_processors.py @@ -1,6 +1,7 @@ """ The core application: context processors for enriching request context data. """ + from django.conf import settings from . import models, session diff --git a/benefits/core/middleware.py b/benefits/core/middleware.py index 73f59ea39..144545870 100644 --- a/benefits/core/middleware.py +++ b/benefits/core/middleware.py @@ -1,6 +1,7 @@ """ The core application: middleware definitions for request/response cycle. """ + import logging from django.conf import settings diff --git a/benefits/core/migrations/0002_data.py b/benefits/core/migrations/0002_data.py index 2b2b6def1..c1807c2ea 100644 --- a/benefits/core/migrations/0002_data.py +++ b/benefits/core/migrations/0002_data.py @@ -1,5 +1,6 @@ """Data migration which loads configuration data for Benefits. """ + import json import os @@ -39,14 +40,14 @@ def load_data(app, *args, **kwargs): mst_server_public_key = PemData.objects.create( label="Eligibility server public key", remote_url=os.environ.get( - "MST_SERVER_PUBLIC_KEY_URL", "https://raw.githubusercontent.com/cal-itp/eligibility-server/dev/keys/server.pub" + "MST_SERVER_PUBLIC_KEY_URL", "https://raw.githubusercontent.com/cal-itp/eligibility-server/main/keys/server.pub" ), ) sbmtd_server_public_key = PemData.objects.create( label="Eligibility server public key", remote_url=os.environ.get( - "SBMTD_SERVER_PUBLIC_KEY_URL", "https://raw.githubusercontent.com/cal-itp/eligibility-server/dev/keys/server.pub" + "SBMTD_SERVER_PUBLIC_KEY_URL", "https://raw.githubusercontent.com/cal-itp/eligibility-server/main/keys/server.pub" ), ) diff --git a/benefits/core/models.py b/benefits/core/models.py index 7d92b3456..8de6ec1fe 100644 --- a/benefits/core/models.py +++ b/benefits/core/models.py @@ -1,6 +1,7 @@ """ The core application: Common model definitions. """ + import importlib import logging diff --git a/benefits/core/recaptcha.py b/benefits/core/recaptcha.py index ffc6e2e15..b6541eee8 100644 --- a/benefits/core/recaptcha.py +++ b/benefits/core/recaptcha.py @@ -1,6 +1,7 @@ """ The core application: helpers to work with reCAPTCHA. """ + import requests from django.conf import settings diff --git a/benefits/core/session.py b/benefits/core/session.py index a8675f163..5582e5a29 100644 --- a/benefits/core/session.py +++ b/benefits/core/session.py @@ -1,6 +1,7 @@ """ The core application: helpers to work with request sessions. """ + import hashlib import logging import time diff --git a/benefits/core/templates/core/base.html b/benefits/core/templates/core/base.html index 5de0488d0..31373e292 100644 --- a/benefits/core/templates/core/base.html +++ b/benefits/core/templates/core/base.html @@ -44,7 +44,7 @@ {% endif %}