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
7 changes: 7 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[codespell]
skip = .git,*.pdf,*.png,*.jpg,*.jpeg,*.gif,*.svg,*.bmp,*.tiff,*.pyc,venv,.venv,.ipynb_checkpoints
check-filenames = true
quiet-level = 2
ignore-words-list = flexcompute,tidy3d,TE,TM,te,tm,FOM,fom,Commun,Thru
ignore-regex = [a-f0-9]{40}
builtin = clear,rare,informal
83 changes: 67 additions & 16 deletions .github/workflows/lint-notebooks.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,78 @@
name: "notebooks-linting"
name: "lint-notebooks"

on:
workflow_dispatch:
push:
branches: [ main, develop ]
branches: [ develop ]
pull_request:
branches: [ main, develop ]
branches: [ develop ]

permissions:
contents: read
pull-requests: write

jobs:
lint:
name: Run notebook linting
name: Run notebook linting and spell check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # required for changed-files action

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Run ruff format check
run: uvx ruff format --check --diff .

- name: Run ruff lint check
run: uvx ruff check .

- name: Get changed notebook files
id: changed_notebooks
if: github.event_name == 'pull_request'
uses: tj-actions/changed-files@v46
with:
fetch-depth: 1

- uses: astral-sh/ruff-action@v3
files: |
**.ipynb

- name: Run spell check on changed notebooks
id: spellcheck
if: github.event_name == 'pull_request' && steps.changed_notebooks.outputs.any_changed == 'true'
continue-on-error: true
run: |
uvx python spellcheck.py ${{ steps.changed_notebooks.outputs.all_changed_files }} > spellcheck_output.txt || true

- name: Prepare spellcheck comment body
id: prepare_comment
if: >
github.event_name == 'pull_request' &&
steps.changed_notebooks.outputs.any_changed == 'true' &&
steps.spellcheck.outcome == 'success' &&
hashFiles('spellcheck_output.txt') != ''
run: |
echo "<!-- lint-notebooks-spellcheck-comment -->" > comment_body.txt
echo "" >> comment_body.txt
cat spellcheck_output.txt >> comment_body.txt
echo "Generated by GitHub Action run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> comment_body.txt

- name: Find existing comment
uses: peter-evans/find-comment@v3
id: find_comment
if: steps.prepare_comment.outcome == 'success'
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!-- lint-notebooks-spellcheck-comment -->'

- name: Post or Update spell check comment
if: steps.prepare_comment.outcome == 'success'
uses: peter-evans/create-or-update-comment@v4
with:
version: 0.5.5

- name: Run ruff format
run: ruff format --check --diff .

- name: Run ruff check
run: ruff check .
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find_comment.outputs.comment-id }}
body-path: comment_body.txt
edit-mode: replace
6 changes: 3 additions & 3 deletions AdjointPlugin0Quickstart.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion AdjointPlugin10YBranchLevelSet.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion AdjointPlugin11CircuitMZI.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions AdjointPlugin12LightExtractor.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions AdjointPlugin13Metasurface.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions AdjointPlugin14PreFab.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions AdjointPlugin1Intro.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions AdjointPlugin2GradientChecking.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions AdjointPlugin3InverseDesign.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions AdjointPlugin5BoundaryGradients.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions AdjointPlugin6GratingCoupler.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions AdjointPlugin7Metalens.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions AdjointPlugin8WaveguideBend.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions AdjointPlugin9WDM.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion AndersonLocalization.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading