Skip to content
Merged
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
41 changes: 41 additions & 0 deletions .eslintrc.strict.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* ESLint config that approximates DeepSource + SonarQube rules.
* Run with: bun run lint:strict (or: bunx eslint --config .eslintrc.strict.cjs src/)
*
* DeepSource's JavaScript analyzer uses ESLint under the hood and supports
* style_guide (e.g. "standard"). SonarQube rules are available via eslint-plugin-sonarjs.
* This config enables rules that catch the kinds of issues both report.
*/
module.exports = {
root: true,
extends: [
'react-app',
'react-app/jest',
'plugin:sonarjs/recommended',
],
plugins: ['sonarjs'],
overrides: [
{
files: ['src/**/*.{ts,tsx,js,jsx}'],
rules: {
// DeepSource JS-0050: use === and !==
eqeqeq: ['error', 'always'],
// Avoid console in browser code (DeepSource JS-0002)
'no-console': ['warn', { allow: ['warn', 'error'] }],
// Object shorthand (DeepSource JS-0240)
'object-shorthand': ['warn', 'always'],
// Empty callbacks (DeepSource JS-0321)
'no-empty-function': ['warn', { allow: ['arrowFunctions'] }],
// Prefer named exports when re-exporting (DeepSource JS-P1003)
'sonarjs/prefer-single-boolean-return': 'warn',
},
},
],
ignorePatterns: [
'build/',
'node_modules/',
'coverage/',
'*.config.js',
'*.config.cjs',
],
};
13 changes: 5 additions & 8 deletions .github/workflows/deploy-to-firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,16 @@ jobs:
- name: Checkout to repository
uses: actions/checkout@v4.2.2

- name: Setup Node
uses: actions/setup-node@v4.4.0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
node-version: 20.8.1

- name: Install Yarn
run: sudo npm i -g yarn
bun-version: latest

- name: Install dependencies
run: yarn
run: bun install --frozen-lockfile

- name: Build
run: REACT_APP_CONFIG=preview PUBLIC_URL=/ yarn build
run: REACT_APP_CONFIG=preview PUBLIC_URL=/ bun run build

- name: Deploy
uses: FirebaseExtended/action-hosting-deploy@v0
Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/deploy-to-github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,17 @@ jobs:
- name: Checkout to repository
uses: actions/checkout@v4.2.2

- name: Setup Node
uses: actions/setup-node@v4.4.0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
node-version: 20.8.1

- name: Install Yarn
run: sudo npm i -g yarn
bun-version: latest

- name: Install dependencies
run: yarn
run: bun install --frozen-lockfile

- name: Build and deploy to GitHub Pages
run: |
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
yarn deploy -- -u "github-actions-bot <support+actions@github.com>"
bun run deploy -- -u "github-actions-bot <support+actions@github.com>"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ jobs:
ref: master
persist-credentials: false

- name: Setup Node
uses: actions/setup-node@v4.4.0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
node-version: 20.8.1
bun-version: latest

- name: Install dependencies
run: yarn
run: bun install --frozen-lockfile

- name: Build
run: yarn build
run: bun run build

- name: Zip build
run: zip -r build.zip build
Expand All @@ -37,4 +37,4 @@ jobs:
GIT_AUTHOR_EMAIL: ${{ vars.RELEASE_GIT_AUTHOR_EMAIL }}
GIT_COMMITTER_NAME: ${{ vars.RELEASE_GIT_COMMITTER_NAME }}
GIT_COMMITTER_EMAIL: ${{ vars.RELEASE_GIT_COMMITTER_EMAIL }}
run: npx semantic-release --branches master
run: bunx semantic-release --branches master
14 changes: 7 additions & 7 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ jobs:
- name: Checkout to repository
uses: actions/checkout@v4.2.2

- name: Setup Node
uses: actions/setup-node@v4.4.0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
node-version: 20.8.1
bun-version: latest

- name: Install dependencies
run: yarn
run: bun install --frozen-lockfile

- name: Build
run: yarn build
run: bun run build

- name: Lint
run: yarn lint
run: bun run lint

- name: Test
run: yarn test
run: bun run test
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
/coverage
.env

.cursorrules

# production
/build

Expand All @@ -28,7 +30,7 @@ public/config/*
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
bun-debug.log*
bun-error.log*

/.github
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
# Block commit if typecheck or lint fails
bun run typecheck && bun run lint
10 changes: 6 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ The app is built using [craco](https://github.com/gsoft-inc/craco) (with the [cr

Tests are written and run using the [jest](https://jestjs.io/) framework.

The [yarn](https://yarnpkg.com/) package manager is used to manage dependencies and run scripts specified in `package.json` (`build`, `lint`, `test`, etc.).
The [Bun](https://bun.sh/) runtime and package manager is used to manage dependencies and run scripts specified in `package.json` (`build`, `lint`, `test`, etc.).

## Coding style

Source code is linted using [ts-standard](https://github.com/standard/ts-standard) (based on [eslint](https://eslint.org/)) and TypeScript is used with [strict type checking compiler options](https://www.typescriptlang.org/tsconfig#Strict_Type_Checking_Options_6173) enabled.
Source code is linted and formatted using [Biome](https://biomejs.dev/). TypeScript is used with [strict type checking compiler options](https://www.typescriptlang.org/tsconfig#Strict_Type_Checking_Options_6173) enabled. Semicolons are not used at the end of statements (Biome uses `asNeeded`).

Use the following command to identify potential coding style and type annotation violations:
Use the following commands to check and fix style:

$ yarn lint
$ bun run lint # check for issues
$ bun run lint:fix # auto-fix issues
$ bun run fmt # format code


### Documentation
Expand Down
23 changes: 11 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,27 @@ RUN apt-get update && \
curl \
dumb-init \
gnupg \
nginx && \
nginx \
unzip && \
apt-get clean

RUN curl -fsSL https://deb.nodesource.com/setup_21.x | bash - && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
curl -sS https://deb.nodesource.com/setup_21.x | bash - && \
apt-get update && \
apt-get install -y --no-install-suggests --no-install-recommends \
nodejs \
yarn && \
nodejs && \
apt-get clean

# Install Bun (matches packageManager in package.json)
ENV BUN_INSTALL=/usr/local
RUN curl -fsSL https://bun.sh/install | bash -

WORKDIR /usr/local/share/mghcomputationalpathology/slim

# Install dependencies first and then include code for efficient caching
COPY package.json .
COPY yarn.lock .
COPY bun.lock .

# There are sometimes weird network errors. Increasing the network timeout
# seems to help (see https://github.com/yarnpkg/yarn/issues/5259)
RUN yarn install --frozen-lockfile --network-timeout 100000
RUN bun install --frozen-lockfile

COPY craco.config.js .
COPY tsconfig.json .
Expand All @@ -57,7 +56,7 @@ RUN addgroup --system --gid 101 nginx && \
--shell /bin/false \
nginx

RUN NODE_OPTIONS=--max_old_space_size=8192 yarn run build && \
RUN NODE_OPTIONS=--max_old_space_size=8192 bun run build && \
mkdir -p /var/www/html && \
cp -R build/* /var/www/html/

Expand All @@ -82,4 +81,4 @@ RUN useradd -m -s /bin/bash tester && \

USER tester

ENTRYPOINT ["/usr/bin/dumb-init", "--", "yarn", "test"]
ENTRYPOINT ["/usr/bin/dumb-init", "--", "bun", "run", "test"]
Loading