Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ MITOL_APIGATEWAY_USERINFO_UPDATE=True
# Host for Digital Credentials issuer-coordinator service
VERIFIABLE_CREDENTIAL_SIGNER_URL=http://dcc.odl.local:4005/instance/test/credentials/issue
VERIFIABLE_CREDENTIAL_BEARER_TOKEN='test'

# MIT Learn URLs (defaults point to production Learn; override to point at a local Learn instance)
MIT_LEARN_TERMS_URL=https://learn.mit.edu/terms
MIT_LEARN_PRIVACY_URL=https://learn.mit.edu/privacy
MIT_LEARN_HONOR_CODE_URL=https://learn.mit.edu/honor_code
90 changes: 83 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,89 @@
name: CI
on: [push]
jobs:
python-checks:
runs-on: ubuntu-24.04

services:
db:
image: postgres:15.16
# Health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres # pragma: allowlist secret
POSTGRES_DB: postgres
ports:
- 5432:5432

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Apt update
run: sudo apt-get update -y

- name: Apt install
run: cat Aptfile | sudo xargs apt-get install

- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
enable-cache: true

- name: Install Python
run: uv python install 3.11

- name: Install dependencies
run: uv sync --locked

- name: Create test local state
run: ./scripts/test/stub-data.sh

- name: Django system checks
run: uv run ./manage.py check --fail-level WARNING
env: &django-env-vars
DEBUG: False
NODE_ENV: 'production'
CELERY_TASK_ALWAYS_EAGER: 'True'
CELERY_BROKER_URL: redis://localhost:6379/4
CELERY_RESULT_BACKEND: redis://localhost:6379/4
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres # pragma: allowlist secret
MAILGUN_KEY: fake_mailgun_key
MAILGUN_SENDER_DOMAIN: other.fake.site
MITX_ONLINE_ADMIN_EMAIL: example@localhost
MITX_ONLINE_BASE_URL: http://localhost:8013
MITX_ONLINE_DB_DISABLE_SSL: 'True'
MITX_ONLINE_EMAIL_BACKEND: django.core.mail.backends.locmem.EmailBackend
MITX_ONLINE_NOTIFICATION_EMAIL_BACKEND: django.core.mail.backends.locmem.EmailBackend
MITX_ONLINE_SECURE_SSL_REDIRECT: 'False'
MITX_ONLINE_USE_S3: 'False'
OPENEDX_API_BASE_URL: http://localhost:18000
OPENEDX_API_CLIENT_ID: fake_client_id
OPENEDX_API_CLIENT_SECRET: fake_client_secret # pragma: allowlist secret
SECRET_KEY: local_unsafe_key # pragma: allowlist secret

- name: Migration and OpenAPI spec checks
run: ./scripts/test/python_checks.sh
env: *django-env-vars

python-tests:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
runs-on: ubuntu-24.04

strategy:
fail-fast: false
matrix:
group: [1, 2, 3, 4]

env:
# coverage instrumentation roughly doubles suite runtime and nothing in CI
# consumes the coverage output (no upload step, all codecov.yml thresholds
# disabled) - skip it here, it's still available locally via a plain `pytest --cov`.
PYTEST_ADDOPTS: "--no-cov"

services:
db:
image: postgres:15.16
Expand Down Expand Up @@ -52,7 +132,7 @@
run: |
celery -A main worker -B -l INFO &
sleep 10
env: &django-env-vars
env: &django-shard-env-vars
DEBUG: False
NODE_ENV: 'production'
CELERY_TASK_ALWAYS_EAGER: 'True'
Expand All @@ -73,16 +153,12 @@
OPENEDX_API_CLIENT_SECRET: fake_client_secret # pragma: allowlist secret
SECRET_KEY: local_unsafe_key # pragma: allowlist secret

- name: Django system checks
run: uv run ./manage.py check --fail-level WARNING
env: *django-env-vars

- name: Tests
run: |
export MEDIA_ROOT="$(mktemp -d)"
cp scripts/test/data/webpack-stats/* webpack-stats/
./scripts/test/python_tests.sh
env: *django-env-vars
./scripts/test/python_tests.sh -n logical --splits 4 --group ${{ matrix.group }}
env: *django-shard-env-vars

javascript-tests:
runs-on: ubuntu-24.04
Expand Down
71 changes: 33 additions & 38 deletions .github/workflows/openapi-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,38 @@ jobs:
ref: ${{ github.base_ref }}
path: base
- name: Generate oasdiff changelog
id: oasdif_changelog
run: | # Capture changelog as a multiline output
echo "changelog<<EOF" > $GITHUB_OUTPUT
for spec in base/openapi/specs/*.yaml; do
base_spec="$spec"
head_spec="head/openapi/specs/$(basename "$spec")"
if [ -f "$head_spec" ]; then
echo "## Changes for $(basename "$spec"):" >> $GITHUB_OUTPUT
docker run --rm \
--workdir ${{ github.workspace }} \
--volume ${{ github.workspace }}:${{ github.workspace }}:rw \
-e GITHUB_WORKSPACE=${{ github.workspace }} \
tufin/oasdiff changelog \
"$base_spec" \
"$head_spec" \
>> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
fi
done
echo "EOF" >> $GITHUB_OUTPUT
- name: Get summary
id: oasdif_summary
run: |
echo summary=$(echo "${{ steps.oasdif_changelog.outputs.changelog }}" | head -1 ) \
>> $GITHUB_OUTPUT
run: | # Write the full comment body to a file rather than a step output.
# A large changelog interpolated into a JS action's `body:` input becomes a
# huge INPUT_BODY env var, which can blow past the OS argv+envp size limit
# and crash the action with "Argument list too long". Writing straight to a
# file and using `body-path` avoids that entirely.
{
echo "## OpenAPI Changes"
echo ""
echo "<details>"
echo "<summary>Show/hide changes</summary>"
echo ""
echo '```'
for spec in base/openapi/specs/*.yaml; do
base_spec="$spec"
head_spec="head/openapi/specs/$(basename "$spec")"
if [ -f "$head_spec" ]; then
echo "## Changes for $(basename "$spec"):"
docker run --rm \
--workdir ${{ github.workspace }} \
--volume ${{ github.workspace }}:${{ github.workspace }}:rw \
-e GITHUB_WORKSPACE=${{ github.workspace }} \
tufin/oasdiff changelog \
"$base_spec" \
"$head_spec"
echo ""
fi
done
echo '```'
echo ""
echo "Unexpected changes? Ensure your branch is up-to-date with \`main\` (consider rebasing)."
echo "</details>"
} > comment_body.md
- name: Find existing comment
id: find_comment
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4
Expand All @@ -54,25 +61,13 @@ jobs:
- name: Post changes as comment
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
# Even if no changes, make sure to update old comment if it was found.
if: steps.oasdif_summary.outputs.summary || steps.find_comment.outputs.comment-id
with:
token: ${{ secrets.GITHUB_TOKEN }}
edit-mode: "replace"
repository: ${{ github.repository }}
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find_comment.outputs.comment-id }}
body: |
## OpenAPI Changes

<details>
<summary>Show/hide ${{ steps.oasdif_summary.outputs.summary || 'No detectable change.' }}</summary>

```
${{ steps.oasdif_changelog.outputs.changelog }}
```

Unexpected changes? Ensure your branch is up-to-date with `main` (consider rebasing).
</details>
body-path: comment_body.md
- name: Check for breaking changes
id: oasdif_breaking
run: |
Expand Down
Loading