Merge branch 'main' into 4365-list-cards #8338
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: [push] | |
jobs: | |
python-tests: | |
runs-on: ubuntu-latest | |
services: | |
# Label used to access the service container | |
db: | |
# Docker Hub image | |
image: postgres:12.19 | |
# Set 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 | |
redis: | |
image: redis:5.0.14 | |
ports: | |
- 6379:6379 | |
elastic: | |
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.21 | |
env: | |
network.host: "0.0.0.0" | |
http.cors.enabled: "true" | |
http.cors.allow-origin: "*" | |
http.max_content_length: "10mb" | |
rest.action.multi.allow_explicit_index: "false" | |
ES_JAVA_OPTS: "-Xms1024m -Xmx1024m" | |
discovery.type: "single-node" | |
ports: | |
- 9200:9200 | |
steps: | |
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 | |
- name: update apt | |
run: sudo apt-get update -y | |
- name: Apt install | |
run: cat Aptfile | sudo xargs apt-get install | |
- name: Install poetry | |
uses: snok/install-poetry@93ada01c735cc8a383ce0ce2ae205a21c415379b # v1 | |
with: | |
version: 1.7.1 | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5 | |
with: | |
python-version: "3.12.3" | |
cache: "poetry" | |
- name: Validate lockfile | |
run: poetry lock --check | |
- name: Install dependencies | |
run: poetry install --no-interaction | |
- name: Create test local state | |
run: ./scripts/test/stub-data.sh | |
- name: Tests | |
run: | | |
poetry run ./manage.py collectstatic --noinput --clear | |
export MEDIA_ROOT="$(mktemp -d)" | |
./scripts/test/python_tests.sh | |
env: | |
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres # pragma: allowlist secret | |
MITOPEN_SECURE_SSL_REDIRECT: "False" | |
MITOPEN_DB_DISABLE_SSL: "True" | |
MITOPEN_FEATURES_DEFAULT: "True" | |
OPENSEARCH_URL: localhost:9200 | |
CELERY_TASK_ALWAYS_EAGER: "True" | |
CELERY_BROKER_URL: redis://localhost:6379/4 | |
CELERY_RESULT_BACKEND: redis://localhost:6379/4 | |
TIKA_CLIENT_ONLY: "True" | |
MITOPEN_BASE_URL: http://localhost:8063/ | |
MAILGUN_KEY: fake_mailgun_key | |
MAILGUN_SENDER_DOMAIN: other.fake.site | |
OPENSEARCH_INDEX: testindex | |
INDEXING_API_USERNAME: mitodl | |
MITOPEN_COOKIE_DOMAIN: localhost | |
MITOPEN_COOKIE_NAME: cookie_monster | |
- name: Upload coverage to CodeCov | |
uses: codecov/codecov-action@125fc84a9a348dbcf27191600683ec096ec9021c # v4.4.1 | |
with: | |
file: ./coverage.xml | |
javascript-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 | |
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4 | |
with: | |
node-version: "^20" | |
cache: yarn | |
cache-dependency-path: yarn.lock | |
- name: Setup environment | |
run: sudo apt-get install libelf1 | |
- name: Install dependencies | |
run: yarn install --immutable | |
- name: Dependencies are consistent | |
run: yarn syncpack list-mismatches | |
- name: Style lint | |
run: yarn run style-lint | |
- name: Webpack build | |
run: yarn run build | |
env: | |
MITOPEN_AXIOS_BASE_PATH: https://api.mitopen-test.odl.mit.edu | |
- name: Lints | |
run: yarn run lint-check | |
- name: Typecheck | |
run: yarn run typecheck | |
- name: Get number of CPU cores | |
id: cpu-cores | |
uses: SimenB/github-actions-cpu-cores@97ba232459a8e02ff6121db9362b09661c875ab8 # v2 | |
- name: Tests | |
run: yarn test --max-workers ${{ steps.cpu-cores.outputs.count }} | |
env: | |
CODECOV: true | |
NODE_ENV: test | |
- name: Upload frontend build | |
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4 | |
with: | |
name: frontend-build | |
path: frontends/mit-open/build | |
- name: Upload coverage to CodeCov | |
uses: codecov/codecov-action@125fc84a9a348dbcf27191600683ec096ec9021c # v4.4.1 | |
with: | |
file: coverage/lcov.info | |
build-storybook: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 | |
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4 | |
with: | |
node-version: "^20" | |
cache: yarn | |
cache-dependency-path: yarn.lock | |
- name: Install dependencies | |
run: yarn install | |
- name: Copy static assets | |
run: | | |
mkdir -p frontends/mit-open/build/static; | |
cp -R frontends/mit-open/public/ frontends/mit-open/build/static; | |
- run: PUBLIC_URL=/mit-open yarn build-github-pages | |
working-directory: frontends | |
- run: PUBLIC_URL=/mit-open yarn build-storybook --output-dir ../github-pages/build/storybook | |
working-directory: frontends | |
- name: Setup Pages | |
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5 | |
- name: Upload artifact | |
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4 | |
with: | |
name: pages-site | |
path: frontends/github-pages/build | |
openapi-generated-client-check-v0: | |
# This job checks that the output of openapi-generator-typescript-axios that | |
# is checked into version control is up-to-date. | |
env: | |
OPENAPI_SCHEMA: ./openapi/specs/v0.yaml | |
GENERATOR_IGNORE_FILE: ./frontends/api/.openapi-generator-ignore | |
GENERATOR_OUTPUT_DIR_CI: ./frontends/api/tmp/generated/v0 | |
GENERATOR_OUTPUT_DIR_VC: ./frontends/api/src/generated/v0 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 | |
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4 | |
with: | |
node-version: "^20" | |
cache: yarn | |
cache-dependency-path: yarn.lock | |
- name: Install dependencies | |
run: yarn install --immutable | |
- name: Generate Fresh API Client | |
uses: openapi-generators/openapitools-generator-action@v1 | |
with: | |
generator: typescript-axios | |
openapi-file: $OPENAPI_SCHEMA | |
generator-tag: v7.2.0 | |
command-args: | | |
--output $GENERATOR_OUTPUT_DIR_CI \ | |
--ignore-file-override $GENERATOR_IGNORE_FILE \ | |
-c scripts/openapi-configs/typescript-axios-v0.yaml | |
- name: Format freshly generated client | |
run: npx prettier $GENERATOR_OUTPUT_DIR_CI/**/*.ts --no-semi --write | |
- name: Check VC client is up-to-date | |
run: | | |
diff $GENERATOR_OUTPUT_DIR_CI $GENERATOR_OUTPUT_DIR_VC \ | |
|| { echo "OpenAPI spec is out of date. Please regenerate via ./scripts/generate_openapi.sh"; exit 1; } | |
openapi-generated-client-check-v1: | |
# This job checks that the output of openapi-generator-typescript-axios that | |
# is checked into version control is up-to-date. | |
env: | |
OPENAPI_SCHEMA: ./openapi/specs/v1.yaml | |
GENERATOR_IGNORE_FILE: ./frontends/api/.openapi-generator-ignore | |
GENERATOR_OUTPUT_DIR_CI: ./frontends/api/tmp/generated/v1 | |
GENERATOR_OUTPUT_DIR_VC: ./frontends/api/src/generated/v1 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 | |
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4 | |
with: | |
node-version: "^20" | |
cache: yarn | |
cache-dependency-path: yarn.lock | |
- name: Install dependencies | |
run: yarn install --immutable | |
- name: Generate Fresh API Client | |
uses: openapi-generators/openapitools-generator-action@v1 | |
with: | |
generator: typescript-axios | |
openapi-file: $OPENAPI_SCHEMA | |
generator-tag: v7.2.0 | |
command-args: | | |
--output $GENERATOR_OUTPUT_DIR_CI \ | |
--ignore-file-override $GENERATOR_IGNORE_FILE \ | |
-c scripts/openapi-configs/typescript-axios-v1.yaml | |
- name: Format freshly generated client | |
run: npx prettier $GENERATOR_OUTPUT_DIR_CI/**/*.ts --no-semi --write | |
- name: Check VC client is up-to-date | |
run: | | |
diff $GENERATOR_OUTPUT_DIR_CI $GENERATOR_OUTPUT_DIR_VC \ | |
|| { echo "OpenAPI spec is out of date. Please regenerate via ./scripts/generate_openapi.sh"; exit 1; } | |
e2e-tests: | |
# Disabling the E2E tests for now | |
if: false | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4 | |
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4 | |
with: | |
node-version: "^20" | |
cache: yarn | |
cache-dependency-path: e2e_testing/yarn.lock | |
- name: Install frontend dependencies | |
run: yarn install --immutable | |
- name: Build frontend | |
run: NODE_ENV=production yarn build | |
- name: Build exported components | |
run: NODE_ENV=production yarn workspace mit-open build-exports | |
- name: Build services | |
run: docker compose -f docker-compose-e2e-tests.yml build | |
- name: Start services | |
run: docker compose -f docker-compose-e2e-tests.yml up nginx web --detach --wait | |
- name: Apply test data | |
run: ./e2e_testing/scripts/apply-fixtures.sh | |
- name: Install E2E test dependencies | |
working-directory: e2e_testing | |
run: yarn install --immutable | |
- name: Install Playwright browsers | |
working-directory: e2e_testing | |
run: yarn playwright install --with-deps chromium | |
- name: Run E2E tests | |
working-directory: e2e_testing | |
run: BASE_URL=http://localhost:8063 CI=true yarn test | |
- name: Setup Pages | |
if: always() | |
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5 | |
- name: Upload artifact | |
if: always() | |
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4 | |
with: | |
name: playwright-report | |
path: e2e_testing/playwright-report | |
publish-pages: | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
permissions: | |
pages: write | |
id-token: write | |
actions: read | |
needs: | |
- build-storybook | |
# - e2e-tests | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4 | |
with: | |
path: pages-site | |
# - name: Move E2E test report | |
# run: mv playwright-report pages-site/ | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3 | |
with: | |
path: pages-site | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4 |