diff --git a/.github/labeler.yml b/.github/labeler.yml index 42dd074..2ec2b2b 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -25,6 +25,14 @@ - changed-files: - any-glob-to-any-file: ['examples/**/*.py', 'doc/source/examples.rst'] +# HACK: the label is declared with the only purpose of avoiding the +# GitHub labeler bot from removing it. This is a known issue reported in the +# official action/labeler repo https://github.com/actions/labeler/issues/763 +'deploy-pr-doc': + - all: + - changed-files: + - all-globs-to-all-files: ['THIS-NEVER-MATCHES-A-FILE'] + ## -- Other labels ------------------------------------------------------------ 'style:code': - any: diff --git a/.github/labels.yml b/.github/labels.yml index c2b5daf..6028619 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -65,6 +65,10 @@ description: Skip documentation runs in CI/CD color: 0677ba +- name: 'deploy-pr-doc' + description: Deploy pull request documentation + color: 0677ba + # -- Dependencies labels ----------------------------------------------------- - name: 'dependencies' diff --git a/.github/workflows/ci_cd_pr.yml b/.github/workflows/ci_cd_pr.yml index 50062ff..3005073 100644 --- a/.github/workflows/ci_cd_pr.yml +++ b/.github/workflows/ci_cd_pr.yml @@ -6,9 +6,10 @@ on: env: MAIN_PYTHON_VERSION: '3.13' LIBRARY_NAME: 'ansys-lumerical-core' - DOCKER_IMAGE_LUMERICAL_UNIFIED: 'ghcr.io/ansys-internal/lumerical-unified:latest' + DOCKER_IMAGE_LUMERICAL_UNIFIED: 'ghcr.io/ansys-internal/lumerical-unified:v252_3' DOCKER_CONTAINER_LUMERICAL_UNIFIED_NAME: 'lumerical-unified' PIP_EXTRA_INDEX_URL: 'https://${{ secrets.PYANSYS_PYPI_PRIVATE_PAT }}@pkgs.dev.azure.com/pyansys/_packaging/pyansys/pypi/simple/' + DOCUMENTATION_CNAME: 'lumerical.docs.pyansys.com' permissions: contents: read @@ -20,6 +21,18 @@ concurrency: jobs: + # vulnerabilities: + # name: Vulnerabilities + # runs-on: ubuntu-latest + # steps: + # - name: PyAnsys Vulnerability check (on main) + # if: github.ref == 'refs/heads/main' + # uses: ansys/actions/check-vulnerabilities@v10.1 + # with: + # python-version: ${{ env.MAIN_PYTHON_VERSION }} + # python-package-name: ${{ env.LIBRARY_NAME }} + # token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + # dev-mode: ${{ github.ref != 'refs/heads/main' }} labeler: name: "Labels" permissions: @@ -83,16 +96,31 @@ jobs: doc-build: name: "Doc build" + if: github.event.action != 'closed' runs-on: ubuntu-latest needs: doc-style steps: - - uses: ansys/actions/doc-build@v10 + - uses: ansys/actions/doc-build@v10.1 with: skip-install: true python-version: ${{ env.MAIN_PYTHON_VERSION }} use-python-cache: false needs-quarto: true + doc-deploy-pr: + name: "Deploy PR documentation" + runs-on: ubuntu-latest + needs: doc-build + if: always() && (needs.doc-build.result == 'success' || needs.doc-build.result == 'skipped') + steps: + - uses: ansys/actions/doc-deploy-pr@v10.1 + with: + cname: ${{ env.DOCUMENTATION_CNAME }} + token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} + bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} + maximum-pr-doc-deployments: 10 + wheelhouse: name: "Wheelhouse / ${{ matrix.os }} / ${{ matrix.python }}" runs-on: ${{ matrix.os }} @@ -135,22 +163,68 @@ jobs: run: | docker pull ${{ env.DOCKER_IMAGE_LUMERICAL_UNIFIED }} + - name: "Prepare ownership for container user (lumerical)" + env: + LUMERICAL_UID: 1000 + LUMERICAL_GID: 1000 + run: | + echo "ORIG_UID=$(id -u)" >> $GITHUB_ENV + echo "ORIG_GID=$(id -g)" >> $GITHUB_ENV + sudo chown -R "$LUMERICAL_UID:$LUMERICAL_GID" . + ls -la + - name: "Run Lumerical Unified Container" run: | docker run \ --detach -it \ --network="host" \ --name ${{ env.DOCKER_CONTAINER_LUMERICAL_UNIFIED_NAME }} \ - --env ANSYSLMD_LICENSE_FILE=1055@${{ secrets.LICENSE_SERVER }} \ - --volume ${PWD}:/home/ansys/pylumerical \ - ${{ env.DOCKER_IMAGE_LUMERICAL_UNIFIED }} + --env ANSYSLMD_LICENSE_FILE=1055@${{ secrets.LICENSE_SERVER }} \ + --mount type=bind,source=${PWD},target=/home/lumerical/pylumerical \ + ${{ env.DOCKER_IMAGE_LUMERICAL_UNIFIED }} - - name: "Install project" + - name: "Install Project Dependencies and Run Tests" run: | docker exec \ - --workdir /home/ansys/pylumerical \ + --workdir /home/lumerical/pylumerical \ ${{ env.DOCKER_CONTAINER_LUMERICAL_UNIFIED_NAME }} /bin/bash --login -c \ - "python -m pip install -e .[tests] && pytest tests" + "python -m pip install -e .[tests] && \ + pytest --cov="/home/lumerical/.local/lib/python3.13/site-packages/ansys/api/lumerical/" \ + --cov="./tests/unit" --cov-report=xml:.cov/xml --cov-report=html:.cov/html --verbose" + + - name: "Restore original ownership" + if: always() + env: + ORIG_UID: ${{ env.ORIG_UID }} + ORIG_GID: ${{ env.ORIG_GID }} + run: | + if [[ -z "$ORIG_UID" || -z "$ORIG_GID" || ! "$ORIG_UID" =~ ^[0-9]+$ || ! "$ORIG_GID" =~ ^[0-9]+$ ]]; then + if [[ -z "$ORIG_UID" || ! "$ORIG_UID" =~ ^[0-9]+$ ]]; then + echo "Skipping chown: ORIG_UID ('$ORIG_UID') is not set or not a valid integer (expected a numeric UID)." + elif [[ -z "$ORIG_GID" || ! "$ORIG_GID" =~ ^[0-9]+$ ]]; then + echo "Skipping chown: ORIG_GID ('$ORIG_GID') is not set or not a valid integer (expected a numeric GID)." + else + echo "Skipping chown: Unknown error with ORIG_UID ('$ORIG_UID') or ORIG_GID ('$ORIG_GID')." + fi + else + sudo chown -R "$ORIG_UID:$ORIG_GID" . + fi + ls -la + + - name: Upload Coverage Results + if: always() + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: coverage-html-ubuntu + path: .cov/html + retention-days: 7 + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + files: .cov/xml - name: "Stop lumerical services" if: always() diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..f693699 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,12 @@ +coverage: + range: 70..100 + round: down + precision: 2 + status: + project: + default: + target: 80% + +codecov: + notify: + wait_for_ci: yes \ No newline at end of file diff --git a/doc/source/changelog/16.documentation.md b/doc/source/changelog/16.documentation.md new file mode 100644 index 0000000..2c4bde7 --- /dev/null +++ b/doc/source/changelog/16.documentation.md @@ -0,0 +1 @@ +Add deploy PR documentation label and workflow diff --git a/doc/source/contributing.rst b/doc/source/contributing.rst index 61296ea..d46564d 100644 --- a/doc/source/contributing.rst +++ b/doc/source/contributing.rst @@ -53,11 +53,10 @@ you to modify the source and enhance it. python -m pip install -U pip python -m pip install -e . -#. Install additional requirements as needed for build, documentation, and tests: +#. Install additional requirements as needed for documentation and tests: .. code:: bash - python -m pip install -r requirements_build.txt python -m pip install .[tests] python -m pip install .[doc] @@ -135,20 +134,6 @@ You can also clean the documentation build directory by running: make clean - -Distributing ------------- - -If you would like to create either source or wheel files, start by installing -the building requirements and then executing the build module: - -.. code:: bash - - python -m pip install -r requirements/requirements_build.txt - python -m build - python -m twine check dist/* - - .. LINKS AND REFERENCES .. _pre-commit: https://pre-commit.com/ diff --git a/pyproject.toml b/pyproject.toml index 9d5ba98..8b2f46c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,8 +35,8 @@ dependencies = [ [project.optional-dependencies] tests = [ - "pytest==7.4.3", - "pytest-cov==4.1.0", + "pytest==8.4.2", + "pytest-cov==7.0.0", ] doc = [ "ansys-sphinx-theme[autoapi]==1.4.2", @@ -45,6 +45,9 @@ doc = [ "sphinx-copybutton==0.5.2", "sphinx_design==0.6.1", ] +examples = [ + "matplotlib==3.10.0", +] [tool.flit.module] name = "ansys.lumerical.core" diff --git a/requirements_build.txt b/requirements_build.txt deleted file mode 100644 index d2ccba1..0000000 --- a/requirements_build.txt +++ /dev/null @@ -1,2 +0,0 @@ -build==0.10.0 -twine==4.0.2