|
1 | | -name: Tidy3dTests |
| 1 | +name: "tidy3d-frontend-tests" |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | workflow_dispatch: |
|
10 | 10 | - 'pre/*' |
11 | 11 |
|
12 | 12 | jobs: |
| 13 | + pre-commit: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + - name: Set up Python |
| 18 | + uses: actions/setup-python@v5 |
| 19 | + with: |
| 20 | + python-version: "3.10" |
| 21 | + submodules: 'recursive' |
| 22 | + - name: Test pre-commit hooks |
| 23 | + run: | |
| 24 | + python -m pip install --upgrade pip |
| 25 | + pip install pre-commit |
| 26 | + pre-commit run # this should be really more agressive |
| 27 | + test-latest-submodules: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - name: Checkout repository with submodules |
| 31 | + uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + submodules: 'recursive' |
| 34 | + # This fetches only a single branch by default, so additional fetch is needed |
| 35 | + fetch-depth: 0 # Optionally, set to 0 to fetch all history for all branches and tags |
| 36 | + |
| 37 | + - name: Determine current branch or PR ref |
| 38 | + id: get_branch |
| 39 | + run: | |
| 40 | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then |
| 41 | + echo "BRANCH_NAME=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV |
| 42 | + else |
| 43 | + echo "BRANCH_NAME=$(echo $GITHUB_REF | sed 's|refs/heads/||')" >> $GITHUB_ENV |
| 44 | + fi |
| 45 | + echo $BRANCH_NAME |
| 46 | + shell: bash |
| 47 | + |
| 48 | + - name: Initialize and update submodule |
| 49 | + run: | |
| 50 | + git submodule update --init --recursive |
| 51 | +
|
| 52 | + - name: Check if submodules are up to date |
| 53 | + shell: bash |
| 54 | + run: | |
| 55 | + NOTEBOOKS_PATH=docs/notebooks |
| 56 | + FAQ_PATH=docs/faq |
| 57 | +
|
| 58 | + # Checking out Notebooks submodule with the same branch as the main project |
| 59 | + echo "Checking $NOTEBOOKS_PATH for updates..." |
| 60 | + cd $NOTEBOOKS_PATH |
| 61 | + echo $(git fetch --all --verbose) |
| 62 | + echo $(git remote get-url origin) |
| 63 | + git checkout origin/$BRANCH_NAME |
| 64 | + if git show-ref --verify refs/remotes/origin/$BRANCH_NAME; then |
| 65 | + echo "Branch $BRANCH_NAME exists." |
| 66 | + else |
| 67 | + echo "::error::Branch $BRANCH_NAME does not exist on remote." |
| 68 | + exit 1 |
| 69 | + fi |
| 70 | + NOTEBOOKS_LATEST_COMMIT=$(git rev-parse refs/remotes/origin/${{ env.BRANCH_NAME }}) |
| 71 | + NOTEBOOKS_CURRENT_COMMIT=$(git rev-parse HEAD) |
| 72 | + |
| 73 | + |
| 74 | + cd ../.. |
| 75 | + if [ "$NOTEBOOKS_LATEST_COMMIT" != "$NOTEBOOKS_CURRENT_COMMIT" ]; then |
| 76 | + echo "::error ::Submodule $NOTEBOOKS_PATH is not up to date with the ${{ env.BRANCH_NAME }} branch. Please update it." |
| 77 | + exit 1 |
| 78 | + else |
| 79 | + echo "Submodule $NOTEBOOKS_PATH is up to date with the ${{ env.BRANCH_NAME }} branch." |
| 80 | + fi |
| 81 | +
|
| 82 | + # Checking FAQs only on the develop branch. |
| 83 | + echo "Checking $FAQ_PATH for updates..." |
| 84 | + cd $FAQ_PATH |
| 85 | + FAQ_LATEST_COMMIT=$(git rev-parse origin/develop) |
| 86 | + FAQ_CURRENT_COMMIT=$(git rev-parse HEAD) |
| 87 | + cd ../.. |
| 88 | + if [ "$FAQ_LATEST_COMMIT" != "$FAQ_CURRENT_COMMIT" ]; then |
| 89 | + echo "::error ::Submodule $FAQ_PATH is not up to date. Please update it." |
| 90 | + exit 1 |
| 91 | + else |
| 92 | + echo "Submodule $FAQ_PATH is up to date." |
| 93 | + fi |
13 | 94 | build: |
14 | 95 | name: test ${{ matrix.python-version }} - ${{ matrix.platform }} |
15 | 96 | runs-on: ${{ matrix.platform }} |
16 | 97 | strategy: |
17 | 98 | matrix: |
18 | | - python-version: ['3.8', '3.9', '3.10', '3.11'] |
| 99 | + python-version: ['3.9', '3.10', '3.11'] |
19 | 100 | platform: [ubuntu-latest, macos-latest, windows-latest] |
| 101 | + defaults: |
| 102 | + run: |
| 103 | + shell: bash |
| 104 | + env: # Set environment variables for the whole job |
| 105 | + PIP_ONLY_BINARY: gdstk |
| 106 | + MPLBACKEND: agg |
20 | 107 | steps: |
21 | | - - uses: actions/checkout@v1 |
| 108 | + - uses: actions/checkout@v4 |
| 109 | + |
| 110 | + #---------------------------------------------- |
| 111 | + # ----- install & configure poetry ----- |
| 112 | + #---------------------------------------------- |
| 113 | + - name: Install Poetry |
| 114 | + uses: abatilo/actions-poetry@v2 |
| 115 | + with: |
| 116 | + version: 1.7.1 |
| 117 | + |
| 118 | + # After installing Poetry add to PATH |
| 119 | + - name: Add Poetry's bin directory to PATH |
| 120 | + run: | |
| 121 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 122 | + echo $(which poetry) |
| 123 | + echo $(poetry --version) |
| 124 | +
|
22 | 125 | - name: Set up Python ${{ matrix.python-version }} |
23 | | - uses: actions/setup-python@v2 |
| 126 | + uses: actions/setup-python@v5 |
24 | 127 | with: |
25 | 128 | python-version: ${{ matrix.python-version }} |
26 | | - - name: Install dependencies |
| 129 | + cache: "poetry" # caching poetry dependencies |
| 130 | + |
| 131 | + #---------------------------------------------- |
| 132 | + # install your root project, if required |
| 133 | + #---------------------------------------------- |
| 134 | + - name: Install library |
| 135 | + run: | |
| 136 | + poetry --version |
| 137 | + poetry install -E dev |
| 138 | + #---------------------------------------------- |
| 139 | + # add matrix specifics and run test suite |
| 140 | + #---------------------------------------------- |
| 141 | + - name: Run tests |
27 | 142 | run: | |
28 | | - python -m pip install --upgrade pip |
29 | | - pip install tox-gh-actions |
30 | | - pip install tox |
31 | | - - name: Test with tox |
32 | | - run: tox |
| 143 | + poetry run black . --check --diff |
| 144 | + poetry run ruff check tidy3d --fix --exit-non-zero-on-fix |
| 145 | + poetry run pytest -rA tests |
| 146 | + poetry run pytest -rA tests/test_data/_test_datasets_no_vtk.py |
0 commit comments