Skip to content

Commit 2e857d7

Browse files
CI Improvements (#951)
Co-authored-by: Nour Massri <mnmassri@mit.edu>
1 parent 3f824a9 commit 2e857d7

File tree

6 files changed

+74
-14
lines changed

6 files changed

+74
-14
lines changed

.github/workflows/ci.yml

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
- opened
99
- synchronize
1010
- reopened
11+
workflow_dispatch:
1112

1213
defaults:
1314
run:
@@ -17,13 +18,26 @@ env:
1718
CACHE_NUMBER: 1
1819

1920
jobs:
20-
unit-test-frontend:
21-
name: Frontend linting / unit tests
21+
frontend-readiness:
22+
name: Frontend linting / readiness checks
2223
# Defines the type of runner the job runs on
2324
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
2427
steps:
2528
- name: Checkout to the repository
2629
uses: actions/checkout@v3
30+
- name: Cache conda
31+
uses: actions/cache@v3
32+
with:
33+
path: ~/conda_pkgs_dir
34+
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment-dev.yml') }}
35+
- name: Setup miniconda
36+
uses: conda-incubator/setup-miniconda@v2.2.0
37+
with:
38+
environment-file: environment-dev.yml
39+
activate-environment: galaxy
40+
use-only-tar-bz2: true
2741
- name: Set up NodeJS environment
2842
uses: actions/setup-node@v3
2943
with:
@@ -43,23 +57,27 @@ jobs:
4357
${{ runner.os }}-build-
4458
${{ runner.os }}-
4559
- name: Install package dependencies
46-
run: npm install
60+
run: npm ci
4761
working-directory: ./frontend
4862
- name: Check linting and formatting
4963
# Custom script for checking the linting and formatting being in place
5064
run: npm run lint
5165
working-directory: ./frontend
52-
# Run test cases and this could ensure minimum coverage as well if set
53-
# This section should be un-commented when our frontend implements unit testing
54-
# - name: Execute test cases
55-
# run: npm run test
56-
# working-directory: ./frontend
66+
- name: Check TypeScript types
67+
run: npx tsc --noEmit
68+
working-directory: ./frontend
69+
- name: Verify generated types are up-to-date
70+
run: |
71+
# Run the type generation script (conda environment 'galaxy' is already activated)
72+
./generate_types.sh
73+
# Check if any files were modified
74+
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)
75+
working-directory: ./frontend
5776
lint:
5877
name: Linter (pre-commit)
5978
runs-on: ubuntu-latest
6079
permissions:
6180
contents: read
62-
id-token: write
6381
steps:
6482
- name: Checkout branch
6583
uses: actions/checkout@v3.1.0
@@ -72,7 +90,28 @@ jobs:
7290
uses: conda-incubator/setup-miniconda@v2.2.0
7391
with:
7492
environment-file: environment-dev.yml
93+
activate-environment: galaxy
7594
use-only-tar-bz2: true
95+
- name: Set up NodeJS environment
96+
uses: actions/setup-node@v3
97+
with:
98+
node-version: '20.12.2'
99+
- name: Cache node modules
100+
id: cache-npm
101+
uses: actions/cache@v3
102+
env:
103+
cache-name: cache-node-modules
104+
with:
105+
# npm cache files are stored in `~/.npm` on Linux/macOS
106+
path: ~/.npm
107+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
108+
restore-keys: |
109+
${{ runner.os }}-build-${{ env.cache-name }}-
110+
${{ runner.os }}-build-
111+
${{ runner.os }}-
112+
- name: Install frontend dependencies for pre-commit
113+
run: npm ci
114+
working-directory: ./frontend
76115
- name: Run linter
77116
run: |
78117
pre-commit install
@@ -82,7 +121,6 @@ jobs:
82121
runs-on: ubuntu-latest
83122
permissions:
84123
contents: read
85-
id-token: write
86124
steps:
87125
- name: Checkout branch
88126
uses: actions/checkout@v3.1.0
@@ -95,6 +133,7 @@ jobs:
95133
uses: conda-incubator/setup-miniconda@v2.2.0
96134
with:
97135
environment-file: environment-dev.yml
136+
activate-environment: galaxy
98137
use-only-tar-bz2: true
99138
- name: Initialize migrations
100139
run: ./manage.py makemigrations

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vscode

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,17 @@ repos:
5959
require_serial: true
6060
types_or: [python, pyi]
6161
exclude: ^backend/.*/migrations
62+
63+
- id: tsc-frontend
64+
name: tsc-frontend
65+
entry: bash -c 'cd frontend && npx --no-install tsc --noEmit'
66+
language: system
67+
files: ^frontend/src/.*\.(ts|tsx)$
68+
pass_filenames: false
69+
70+
- id: eslint-frontend
71+
name: eslint-frontend
72+
entry: bash -c 'cd frontend && npx --no-install eslint'
73+
language: system
74+
files: ^frontend/src/.*\.(ts|tsx)$
75+
pass_filenames: true

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 MIT Battlecode
3+
Copyright (c) 2025 MIT Battlecode
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

environment-dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ dependencies:
1919
- google-cloud-storage=2.5.0
2020
- isort=5.10.1
2121
- mypy=0.942
22-
- nodejs=18.11.0
22+
- nodejs=20
2323
- openjdk=11
24-
- openssl=3.0.5
24+
- openssl>=3.0.15
2525
- pillow=9.0.1
2626
- pip=22.3
2727
- pre_commit=2.20.0

frontend/vite.config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import eslint from "vite-plugin-eslint";
77
// https://vitejs.dev/config/
88
export default defineConfig({
99
base: "/",
10-
plugins: [react(), svgr(), tsconfigPaths(), eslint()],
10+
plugins: [
11+
react(),
12+
svgr(),
13+
tsconfigPaths(),
14+
// Show ESLint warnings/errors in overlay without blocking interaction
15+
eslint({ failOnError: false, failOnWarning: false }),
16+
],
1117
server: {
1218
port: 3000,
1319
open: true,

0 commit comments

Comments
 (0)