-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
linting + CI #96
linting + CI #96
Changes from all commits
7a2e53f
ebdcc31
5e1e1cf
0a33cb5
4d8e253
182f8ba
aeecceb
879473e
0cf9277
c536210
5482e1c
e4f4ae3
866bf7d
8315290
34ab0a3
961beff
dc34d90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Pre-Commit Formatting | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- 'client/**' | ||
- 'frontend/**' | ||
- 'backend/**' | ||
- '.github/workflows/**' # Re-run if a workflow is modified - useful to test workflow changes in PRs | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
pre-commit-checks: | ||
name: pre-commit checks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.9' | ||
|
||
- uses: dorny/paths-filter@v2 | ||
id: changes | ||
with: | ||
filters: | | ||
frontend: | ||
- 'frontend/**' | ||
|
||
- uses: actions/setup-node@v3 | ||
if: steps.changes.outputs.frontend == 'true' | ||
with: | ||
node-version: 20.8.x | ||
|
||
- name: Install PNPM | ||
if: steps.changes.outputs.frontend == 'true' | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8.9.0 | ||
run_install: false | ||
|
||
- name: Get pnpm store directory | ||
if: steps.changes.outputs.frontend == 'true' | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
|
||
- name: Setup pnpm cache | ||
uses: actions/cache@v3 | ||
if: steps.changes.outputs.frontend == 'true' | ||
with: | ||
path: ${{ env.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
|
||
- name: Install dependencies with PNPM | ||
if: steps.changes.outputs.frontend == 'true' | ||
run: pnpm install --frozen-lockfile | ||
working-directory: frontend | ||
|
||
- name: Build GraphQL Types | ||
if: steps.changes.outputs.frontend == 'true' | ||
run: pnpm build | ||
working-directory: frontend/packages/data-portal | ||
|
||
- name: run pre-commit | ||
uses: pre-commit/[email protected] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Workflow for running several tests for PRs and pushes to the main branch for | ||
# data portal frontend code. | ||
|
||
name: Frontend Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "frontend/**" | ||
pull_request: | ||
branches: | ||
- "**" | ||
paths: | ||
- "frontend/**" | ||
|
||
defaults: | ||
run: | ||
working-directory: frontend/ | ||
|
||
jobs: | ||
# Runs several tests on the frontend codebase to check for code style, | ||
# formatting, best practices, and run unit/integration tests. | ||
tests: | ||
name: ${{ matrix.name }} | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.8.x | ||
|
||
- name: Install PNPM | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8.9.0 | ||
run_install: false | ||
|
||
- name: Get pnpm store directory | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
|
||
- name: Setup pnpm cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ env.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
|
||
- name: Install dependencies with PNPM | ||
run: pnpm install --frozen-lockfile | ||
working-directory: frontend | ||
|
||
- name: Build GraphQL Types | ||
run: pnpm build | ||
working-directory: frontend/packages/data-portal | ||
|
||
- name: ${{ matrix.name }} | ||
run: ${{ matrix.run }} | ||
|
||
# Run linters and tests as matrix strategies so that they: | ||
# 1. Show up as separate GitHub checks. | ||
# 2. So we can reuse the Node.js and PNPM installation steps | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- name: jest | ||
run: pnpm -r test | ||
|
||
- name: tsc | ||
run: pnpm -r type-check |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ on: | |
push: | ||
branches: | ||
- "main" | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
repos: | ||
- repo: https://github.com/psf/black-pre-commit-mirror | ||
rev: 23.9.1 | ||
hooks: | ||
- id: black | ||
files: backend|client/python | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.0.292 | ||
hooks: | ||
- id: ruff | ||
files: backend|client/python | ||
args: | ||
- --fix | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: check-toml | ||
- id: check-yaml | ||
exclude: frontend # covered by prettier | ||
- id: check-json | ||
exclude: frontend # covered by prettier | ||
- id: check-merge-conflict | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- repo: local | ||
hooks: | ||
- id: pnpm-lint | ||
name: pnpm lint | ||
entry: pnpm -r --parallel lint:fix | ||
language: system | ||
types_or: [javascript, jsx, ts, tsx] | ||
files: frontend | ||
pass_filenames: false |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,10 +46,6 @@ exclude = ["tests*"] # exclude packages matching these glob patterns (empty by | |
[tool.setuptools_scm] | ||
root = "../../.." | ||
|
||
[tool.black] | ||
line-length = 120 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this might be good to retain, as the default line limit of 80 is quite short. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i can revert this if you desire There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a blocker: Yes, please, if it isn't too much trouble. |
||
target_version = ['py39'] | ||
|
||
[tool.mypy] | ||
show_error_codes = true | ||
ignore_missing_imports = true | ||
|
@@ -60,12 +56,3 @@ strict = true | |
markers = [ | ||
"expensive: too expensive to run regularly or in CI", | ||
] | ||
|
||
[tool.ruff] | ||
select = ["E", "F", "B", "I"] | ||
ignore = ["E501", "E402", "C408", ] | ||
line-length = 120 | ||
target-version = "py39" | ||
|
||
[tool.ruff.isort] | ||
known-first-party =["cryoet_data_portal"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
-r ../../../../py-dev-requirements.txt | ||
numpy | ||
pytest | ||
requests-mock | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically not, no
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker: We could remove it.