diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95447bf3c..2a8ff8b36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,7 @@ on: - opened - synchronize - reopened + workflow_dispatch: defaults: run: @@ -17,13 +18,26 @@ env: CACHE_NUMBER: 1 jobs: - unit-test-frontend: - name: Frontend linting / unit tests + frontend-readiness: + name: Frontend linting / readiness checks # Defines the type of runner the job runs on runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Checkout to the repository uses: actions/checkout@v3 + - name: Cache conda + uses: actions/cache@v3 + with: + path: ~/conda_pkgs_dir + key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment-dev.yml') }} + - name: Setup miniconda + uses: conda-incubator/setup-miniconda@v2.2.0 + with: + environment-file: environment-dev.yml + activate-environment: galaxy + use-only-tar-bz2: true - name: Set up NodeJS environment uses: actions/setup-node@v3 with: @@ -43,23 +57,27 @@ jobs: ${{ runner.os }}-build- ${{ runner.os }}- - name: Install package dependencies - run: npm install + run: npm ci working-directory: ./frontend - name: Check linting and formatting # Custom script for checking the linting and formatting being in place run: npm run lint working-directory: ./frontend - # Run test cases and this could ensure minimum coverage as well if set - # This section should be un-commented when our frontend implements unit testing - # - name: Execute test cases - # run: npm run test - # working-directory: ./frontend + - name: Check TypeScript types + run: npx tsc --noEmit + working-directory: ./frontend + - name: Verify generated types are up-to-date + run: | + # Run the type generation script (conda environment 'galaxy' is already activated) + ./generate_types.sh + # Check if any files were modified + git diff --exit-code src/api/_autogen/ || (echo "ERROR: Generated TypeScript types are out of date. Please run ./generate_types.sh and commit the changes." && exit 1) + working-directory: ./frontend lint: name: Linter (pre-commit) runs-on: ubuntu-latest permissions: contents: read - id-token: write steps: - name: Checkout branch uses: actions/checkout@v3.1.0 @@ -72,7 +90,28 @@ jobs: uses: conda-incubator/setup-miniconda@v2.2.0 with: environment-file: environment-dev.yml + activate-environment: galaxy use-only-tar-bz2: true + - name: Set up NodeJS environment + uses: actions/setup-node@v3 + with: + node-version: '20.12.2' + - name: Cache node modules + id: cache-npm + uses: actions/cache@v3 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: Install frontend dependencies for pre-commit + run: npm ci + working-directory: ./frontend - name: Run linter run: | pre-commit install @@ -82,7 +121,6 @@ jobs: runs-on: ubuntu-latest permissions: contents: read - id-token: write steps: - name: Checkout branch uses: actions/checkout@v3.1.0 @@ -95,6 +133,7 @@ jobs: uses: conda-incubator/setup-miniconda@v2.2.0 with: environment-file: environment-dev.yml + activate-environment: galaxy use-only-tar-bz2: true - name: Initialize migrations run: ./manage.py makemigrations diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..722d5e71d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 13d8fd641..60d020b32 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -59,3 +59,17 @@ repos: require_serial: true types_or: [python, pyi] exclude: ^backend/.*/migrations + + - id: tsc-frontend + name: tsc-frontend + entry: bash -c 'cd frontend && npx --no-install tsc --noEmit' + language: system + files: ^frontend/src/.*\.(ts|tsx)$ + pass_filenames: false + + - id: eslint-frontend + name: eslint-frontend + entry: bash -c 'cd frontend && npx --no-install eslint' + language: system + files: ^frontend/src/.*\.(ts|tsx)$ + pass_filenames: true diff --git a/LICENSE b/LICENSE index 559a8737c..ba9b07202 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 MIT Battlecode +Copyright (c) 2025 MIT Battlecode Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/environment-dev.yml b/environment-dev.yml index b47edfb75..fa54415d4 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -19,9 +19,9 @@ dependencies: - google-cloud-storage=2.5.0 - isort=5.10.1 - mypy=0.942 - - nodejs=18.11.0 + - nodejs=20 - openjdk=11 - - openssl=3.0.5 + - openssl>=3.0.15 - pillow=9.0.1 - pip=22.3 - pre_commit=2.20.0 diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 64f875e1d..d08ba430f 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -7,7 +7,13 @@ import eslint from "vite-plugin-eslint"; // https://vitejs.dev/config/ export default defineConfig({ base: "/", - plugins: [react(), svgr(), tsconfigPaths(), eslint()], + plugins: [ + react(), + svgr(), + tsconfigPaths(), + // Show ESLint warnings/errors in overlay without blocking interaction + eslint({ failOnError: false, failOnWarning: false }), + ], server: { port: 3000, open: true,