Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rmanaem authored May 14, 2024
0 parents commit 0e7e603
Show file tree
Hide file tree
Showing 44 changed files with 15,467 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[codespell]
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
skip = .git,package-lock.json,*.css,.codespellrc
check-hidden = true
# ignore-regex =
# ignore-words-list =
37 changes: 37 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
'plugin:cypress/recommended',
'airbnb',
'airbnb/hooks',
'airbnb-typescript',
'prettier',
],
ignorePatterns: ['dist', '.eslintrc.cjs', 'lint-staged.config.js'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['./tsconfig.*json'],
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: {
alwaysTryTypes: true,
},
},
},
plugins: ['react-refresh', 'cypress', 'eslint-plugin-tsdoc'],
rules: {
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
'react/react-in-jsx-scope': 'off',
'tsdoc/syntax': 'warn',
// Disabling this rule allows us to use blanket exports from components
'import/prefer-default-export': 'off',
},
};
29 changes: 29 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'weekly'
labels:
- '_bot'
- 'maint:dependency'
- 'type:maintenance'

- package-ecosystem: 'gitsubmodule'
directory: '/'
schedule:
interval: 'weekly'

- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'weekly'
labels:
- '_bot'
- 'maint:dependency'
- 'type:maintenance'
42 changes: 42 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!--- Until this PR is ready for review, you can include [WIP] in the title, or create a draft PR. -->


<!---
Below is a suggested pull request template. Feel free to add more details you feel are relevant/necessary.
For more info on the Neurobagel PR process and other contributing guidelines, see https://neurobagel.org/contributing/CONTRIBUTING/.
-->

<!--
Please indicate after the # which issue you're closing with this PR, if applicable.
If the PR closes multiple issues, include "closes" before each one is listed.
You can also link to other issues if necessary, e.g. "See also #1234".
https://help.github.com/articles/closing-issues-using-keywords
-->
- Closes #

<!--
Please give a brief overview of what has changed or been added in the PR.
This can include anything specific the maintainers should be looking for when they review the PR.
-->
Changes proposed in this pull request:

-
-

<!-- To be checked off by reviewers -->
## Checklist
_This section is for the PR reviewer_

- [ ] PR has an interpretable title with a prefix (`[ENH]`, `[FIX]`, `[REF]`, `[TST]`, `[CI]`, `[MNT]`, `[INF]`, `[MODEL]`, `[DOC]`) _(see our [Contributing Guidelines](https://neurobagel.org/contributing/CONTRIBUTING#pull-request-guidelines) for more info)_
- [ ] PR has a label for the release changelog or `skip-release` (to be applied by maintainers only)
- [ ] PR links to GitHub issue with mention `Closes #XXXX`
- [ ] Tests pass
- [ ] Checks pass

For new features:
- [ ] Tests have been added

For bug fixes:
- [ ] There is at least one test that would fail under the original bug conditions.
72 changes: 72 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: checks

on:
push:
branches:
- main
pull_request:
# Enables GH merge queues
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#merge_group
merge_group:

jobs:
tsc:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Run TSC
run: npm run typecheck

eslint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Run ESLint
run: npm run lint:check

prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Run Prettier Check
run: npm run format:check

codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Codespell
uses: codespell-project/actions-codespell@v2
137 changes: 137 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: tests

on:
push:
branches:
- main
pull_request:
merge_group:

jobs:
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up node env
uses: actions/setup-node@v4
with:
node-version: 20

- name: build
run: npm install && npm run build

- name: Run end to end tests
uses: cypress-io/github-action@v6
with:
wait-on: http://localhost:5173
start: npm run preview
component: false

- name: Upload e2e coverage artifact
uses: actions/upload-artifact@v4
with:
name: e2eCov
path: coverage

component:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: build
run: npm install && npm run build

- name: Run component tests
uses: cypress-io/github-action@v6
with:
component: true

- name: Upload component coverage artifact
uses: actions/upload-artifact@v4
with:
name: compCov
path: coverage

unit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Run unit tests
run: npm run test:unit

- name: Upload unit coverage artifact
uses: actions/upload-artifact@v4
with:
name: unitCov
path: coverage

merge-coverage:
# Run this job only if both e2e and component tests passed
needs: [e2e, component, unit]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Setup
run: npm install

- name: Download e2e coverage artifacts
uses: actions/download-artifact@v4
with:
name: e2eCov
path: e2eCov

- name: Download component coverage artifacts
uses: actions/download-artifact@v4
with:
name: compCov
path: compCov

- name: Download unit coverage artifacts
uses: actions/download-artifact@v4
with:
name: unitCov
path: unitCov

- name: Install nyc
run: npm install -g nyc

- name: Merge coverage reports
run: |
mkdir -p combined_coverage final_coverage
nyc merge e2eCov combined_coverage/e2e.json
nyc merge compCov combined_coverage/component.json
nyc merge unitCov combined_coverage/unit.json
nyc merge combined_coverage final_coverage/combined-coverage.json
- name: Generate final coverage report
run: nyc report --reporter=lcov --temp-dir final_coverage --report-dir ./coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage/lcov.info
flags: tests
name: codecov-combined
fail_ci_if_error: true

36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# Environment files
.env

# Cypress
cypress/screenshots
cypress/downloads

# Code coverage reports
coverage
.nyc_output

4 changes: 4 additions & 0 deletions .husky/post-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

git diff HEAD^ HEAD --exit-code -- ./package.json || npm ci
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged

Loading

0 comments on commit 0e7e603

Please sign in to comment.