diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml new file mode 100644 index 0000000..a5aadaa --- /dev/null +++ b/.github/workflows/ci-main.yml @@ -0,0 +1,43 @@ +name: CI - Main + +on: + push: + branches: + - main + +env: + DOCUMENTATION_CNAME: usd-viewer.docs.pyansys.com + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + doc-build: + name: Building library documentation + runs-on: ubuntu-latest + steps: + - name: Run Ansys documentation building action + uses: ansys/actions/doc-build@3931ac9351b13ae11b1203c2ef6b51e5c75502ea # v10.2.5 + with: + group-dependencies-name: "doc" + check-links: false + + doc-deploy-dev: + name: Deploy development documentation + runs-on: ubuntu-latest + needs: [doc-build] + permissions: + contents: write # Needed to update files on the gh-pages branch + pull-requests: write # Needed to add comments to the PR when cleaning pull directory + steps: + - uses: ansys/actions/doc-deploy-dev@main + with: + cname: ${{ env.DOCUMENTATION_CNAME }} + token: ${{ secrets.GITHUB_TOKEN }} + bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} + bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml new file mode 100644 index 0000000..2b5cdc4 --- /dev/null +++ b/.github/workflows/ci-pr.yml @@ -0,0 +1,228 @@ +name: CI - PR + +on: + pull_request: + types: [opened, reopened, synchronize, edited, labeled] + +env: + PACKAGE_NAME: ansys-tools-usdviewer + MAIN_PYTHON_VERSION: 3.13 + DOCUMENTATION_CNAME: usd-viewer.docs.pyansys.com + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + pr-name: + name: Check the name of the PR + runs-on: ubuntu-latest + permissions: + pull-requests: read # Required to read PR metadata + steps: + - name: Check commit name + uses: ansys/actions/check-pr-title@3931ac9351b13ae11b1203c2ef6b51e5c75502ea # v10.2.5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + changelog: + name: Changelog + runs-on: ubuntu-latest + permissions: + contents: write # Required for the changelog + pull-requests: write # Required for the changelog + steps: + - name: Create fragment + uses: ansys/actions/doc-changelog@21c9de9bee9692173780696d4a39964f20b9cfa3 # v10.1.5 + with: + token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} + bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} + + labeler: + name: Labels + permissions: + contents: read # Needed to read existing labels on the repository + pull-requests: write # Needed to add existing labels to PRs + issues: write # Needed to create labels that do not already exist + runs-on: ubuntu-latest + steps: + - name: Checkout project + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - name: Sync labels + uses: micnncim/action-label-syncer@3abd5ab72fda571e69fffd97bd4e0033dd5f495c # v1.3.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Label pull-request + # HACK: skip if contributor does not have write permissions (forks) + if: github.event.pull_request.head.repo.full_name == github.repository + uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b # v6.0.1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + sync-labels: true + + # NOTE: added for PRs from external contributors + commenter: + name: Suggest labels if none assigned + runs-on: ubuntu-latest + permissions: + contents: read # needed to read existing labels on the pull request + pull-requests: write # needed for comment action + steps: + - name: Suggest to add labels + uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 + # Execute only when no labels have been applied to the pull request + if: toJSON(github.event.pull_request.labels.*.name) == '{}' + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + Please add one of the following labels to add this contribution to the Release Notes :point_down: + - [bug](https://github.com/ansys/python-usd-viewer/pulls?q=label%3Abug+) + - [documentation](https://github.com/ansys/python-usd-viewer/pulls?q=label%3Adocumentation+) + - [enhancement](https://github.com/ansys/python-usd-viewer/pulls?q=label%3Aenhancement+) + - [good first issue](https://github.com/ansys/python-usd-viewer/pulls?q=label%3Agood+first+issue) + - [maintenance](https://github.com/ansys/python-usd-viewer/pulls?q=label%3Amaintenance+) + - [release](https://github.com/ansys/python-usd-viewer/pulls?q=label%3Arelease+) + + # 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@41f86da4c9ead510db9135e428e33df9cc6f92e1 # v10.2.3 + # with: + # python-version: ${{ env.MAIN_PYTHON_VERSION }} + # python-package-name: ${{ env.PACKAGE_NAME }} + # token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + # upload-reports: true + + # - name: PyAnsys Vulnerability check (on dev mode) + # if: github.ref != 'refs/heads/main' + # uses: ansys/actions/check-vulnerabilities@41f86da4c9ead510db9135e428e33df9cc6f92e1 # v10.2.3 + # with: + # python-version: ${{ env.MAIN_PYTHON_VERSION }} + # python-package-name: ${{ env.PACKAGE_NAME }} + # token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + # dev-mode: true + # upload-reports: true + # hide-log: false + + code-style: + name: Code style + runs-on: ubuntu-latest + steps: + - uses: ansys/actions/code-style@3931ac9351b13ae11b1203c2ef6b51e5c75502ea # v10.2.5 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + doc-style: + name: Doc style + runs-on: ubuntu-latest + steps: + - uses: ansys/actions/doc-style@3931ac9351b13ae11b1203c2ef6b51e5c75502ea # v10.2.5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + actions-style: + name: Actions style + runs-on: ubuntu-latest + steps: + - uses: ansys/actions/check-actions-security@3931ac9351b13ae11b1203c2ef6b51e5c75502ea # v10.2.5 + with: + generate-summary: true + token: ${{ secrets.GITHUB_TOKEN }} + auditing-level: high + + wheelhouse: + name: Wheelhouse / ${{ matrix.os }} / ${{ matrix.python }} + runs-on: ${{ matrix.os }} + needs: code-style + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python: ['3.10', '3.11', '3.12', '3.13'] + steps: + - uses: ansys/actions/build-wheelhouse@3931ac9351b13ae11b1203c2ef6b51e5c75502ea # v10.2.5 + with: + library-name: ${{ env.PACKAGE_NAME }} + operating-system: ${{ matrix.os }} + python-version: ${{ matrix.python }} + whitelist-license-check: 'PySide6, PySide6_Addons, PySide6_Essentials, shiboken6' + + doc-build: + name: Building library documentation + runs-on: ubuntu-latest + needs: doc-style + steps: + - name: Run Ansys documentation building action + uses: ansys/actions/doc-build@3931ac9351b13ae11b1203c2ef6b51e5c75502ea # v10.2.5 + with: + group-dependencies-name: "doc" + check-links: false + + tests: + name: Tests + runs-on: ubuntu-latest + needs: code-style + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + - name: Set up uv + uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0 + with: + enable-cache: false + + - name: Install python-usd-viewer and tests dependencies + run: uv sync --no-dev --group tests --frozen + + - name: Run tests + run: uv run pytest tests + + build-library: + name: Build library + runs-on: ubuntu-latest + needs: [wheelhouse] + steps: + - uses: ansys/actions/build-library@3931ac9351b13ae11b1203c2ef6b51e5c75502ea # v10.2.5 + with: + library-name: ${{ env.PACKAGE_NAME }} + python-version: ${{ env.MAIN_PYTHON_VERSION }} + + automerge-prs: + name: Automerge PRs (dependabot and pre-commit.ci only) + runs-on: ubuntu-latest + needs: [build-library, tests] + permissions: + contents: write # needed for automerge action + pull-requests: write # needed for automerge action + steps: + - name: Automerge PRs + uses: ansys/actions/hk-automerge-prs@3931ac9351b13ae11b1203c2ef6b51e5c75502ea # v10.2.5 + with: + approver: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} + approver-token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} + + - name: If pre-commit PR, add assignee + if: startsWith(github.head_ref, 'pre-commit-ci-update-config') + run: gh pr edit --add-assignee pyansys-ci-bot "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GH_TOKEN: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} diff --git a/.github/workflows/cicd.yml b/.github/workflows/ci-release.yml similarity index 67% rename from .github/workflows/cicd.yml rename to .github/workflows/ci-release.yml index 8171e5c..040f2e7 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/ci-release.yml @@ -1,17 +1,9 @@ -name: GitHub CI +name: CI - Release on: - pull_request: - workflow_dispatch: push: tags: - - '*' - branches: - - main - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + - "v*.*.*" env: PACKAGE_NAME: ansys-tools-usdviewer @@ -21,6 +13,10 @@ env: permissions: contents: read +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: changelog: @@ -30,34 +26,13 @@ jobs: contents: write # Required for the changelog pull-requests: write # Required for the changelog steps: - - name: Create fragment - if: github.event_name == 'pull_request' - uses: ansys/actions/doc-changelog@3931ac9351b13ae11b1203c2ef6b51e5c75502ea # v10.2.5 - with: - token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} - bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} - bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} - - name: Deploy changelog - if: github.event_name == 'push' && contains(github.ref, 'refs/tags') - uses: ansys/actions/doc-deploy-changelog@3931ac9351b13ae11b1203c2ef6b51e5c75502ea # v10.2.5 + uses: ansys/actions/doc-deploy-changelog@21c9de9bee9692173780696d4a39964f20b9cfa3 # v10.1.5 with: token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} - pr-name: - if: github.event_name == 'pull_request' - name: Check the name of the PR - runs-on: ubuntu-latest - permissions: - pull-requests: read # Required for check-pr-title action - steps: - - name: Check commit name - uses: ansys/actions/check-pr-title@3931ac9351b13ae11b1203c2ef6b51e5c75502ea # v10.2.5 - with: - token: ${{ secrets.GITHUB_TOKEN }} - # vulnerabilities: # name: Vulnerabilities # runs-on: ubuntu-latest @@ -126,18 +101,18 @@ jobs: whitelist-license-check: 'PySide6, PySide6_Addons, PySide6_Essentials, shiboken6' doc-build: - name: "Building library documentation" + name: Building library documentation runs-on: ubuntu-latest needs: doc-style steps: - - name: "Run Ansys documentation building action" + - name: Run Ansys documentation building action uses: ansys/actions/doc-build@3931ac9351b13ae11b1203c2ef6b51e5c75502ea # v10.2.5 with: group-dependencies-name: "doc" check-links: false tests: - name: "Tests" + name: Tests runs-on: ubuntu-latest needs: code-style steps: @@ -172,26 +147,9 @@ jobs: library-name: ${{ env.PACKAGE_NAME }} python-version: ${{ env.MAIN_PYTHON_VERSION }} - upload_dev_docs: - name: Upload dev documentation - if: github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - needs: [build-library] - permissions: - contents: write # Needed to update files on the gh-pages branch - steps: - - name: Deploy the latest documentation - uses: ansys/actions/doc-deploy-dev@3931ac9351b13ae11b1203c2ef6b51e5c75502ea # v10.2.5 - 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 }} - release: name: Release project - if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags') }} - needs: build-library + needs: [build-library, tests, doc-build, changelog] runs-on: ubuntu-latest environment: release permissions: @@ -221,9 +179,8 @@ jobs: doc-deploy-stable: name: Deploy stable docs - if: github.event_name == 'push' && contains(github.ref, 'refs/tags') runs-on: ubuntu-latest - needs: [release, doc-build] + needs: [release] steps: - uses: ansys/actions/doc-deploy-stable@3931ac9351b13ae11b1203c2ef6b51e5c75502ea # v10.2.5 with: @@ -231,25 +188,3 @@ jobs: token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }} - - automerge-prs: - name: Automerge PRs (dependabot and pre-commit.ci only) - runs-on: ubuntu-latest - needs: [build-library] - if: github.event_name == 'pull_request' - permissions: - contents: write # needed for automerge action - pull-requests: write # needed for automerge action - steps: - - name: Automerge PRs - uses: ansys/actions/hk-automerge-prs@3931ac9351b13ae11b1203c2ef6b51e5c75502ea # v10.2.5 - with: - approver: ${{ secrets.PYANSYS_CI_BOT_USERNAME }} - approver-token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} - - - name: If pre-commit PR, add assignee - if: startsWith(github.head_ref, 'pre-commit-ci-update-config') - run: gh pr edit --add-assignee pyansys-ci-bot "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GH_TOKEN: ${{ secrets.PYANSYS_CI_BOT_TOKEN }} diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml deleted file mode 100644 index dca0782..0000000 --- a/.github/workflows/label.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: Labeler -on: - pull_request: - # opened, reopened, and synchronize are default for pull_request - # edited - when PR title or body is changed - # labeled - when labels are added to PR - types: [opened, reopened, synchronize, edited, labeled] - push: - branches: [main] - paths: - - ../labels.yml - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: {} # Disable default permissions - -jobs: - - label-syncer: - name: Syncer - runs-on: ubuntu-latest - permissions: - contents: write # needed for label sync - pull-requests: write # needed for label sync - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false - - uses: micnncim/action-label-syncer@3abd5ab72fda571e69fffd97bd4e0033dd5f495c # v1.3.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - labeler: - name: Set labels - needs: [label-syncer] - permissions: - contents: read - pull-requests: write # needed to add labels to PR - runs-on: ubuntu-latest - steps: - - # Label based on modified files - - name: Label based on changed files - uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b # v6.0.1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - sync-labels: true - - # Label based on branch name - - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf # v1.1.3 - if: | - startsWith(github.event.pull_request.head.ref, 'doc') || - startsWith(github.event.pull_request.head.ref, 'docs') - with: - labels: documentation - github_token: ${{ secrets.GITHUB_TOKEN }} - - - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf # v1.1.3 - if: | - startsWith(github.event.pull_request.head.ref, 'maint') || - startsWith(github.event.pull_request.head.ref, 'no-ci') || - startsWith(github.event.pull_request.head.ref, 'ci') - with: - labels: maintenance - github_token: ${{ secrets.GITHUB_TOKEN }} - - - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf # v1.1.3 - if: startsWith(github.event.pull_request.head.ref, 'feat') - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - labels: | - enhancement - - - uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf # v1.1.3 - if: | - startsWith(github.event.pull_request.head.ref, 'fix') || - startsWith(github.event.pull_request.head.ref, 'patch') - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - labels: bug - - commenter: - name: Suggest labels if none assigned - runs-on: ubuntu-latest - permissions: - contents: read # needed for comment action - pull-requests: write # needed for comment action - steps: - - name: Suggest to add labels - uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 - # Execute only when no labels have been applied to the pull request - if: toJSON(github.event.pull_request.labels.*.name) == '{}' - with: - issue-number: ${{ github.event.pull_request.number }} - body: | - Please add one of the following labels to add this contribution to the Release Notes :point_down: - - [bug](https://github.com/ansys/python-usd-viewer/pulls?q=label%3Abug+) - - [documentation](https://github.com/ansys/python-usd-viewer/pulls?q=label%3Adocumentation+) - - [enhancement](https://github.com/ansys/python-usd-viewer/pulls?q=label%3Aenhancement+) - - [good first issue](https://github.com/ansys/python-usd-viewer/pulls?q=label%3Agood+first+issue) - - [maintenance](https://github.com/ansys/python-usd-viewer/pulls?q=label%3Amaintenance+) - - [release](https://github.com/ansys/python-usd-viewer/pulls?q=label%3Arelease+) diff --git a/doc/source/changelog/28.miscellaneous.md b/doc/source/changelog/28.miscellaneous.md new file mode 100644 index 0000000..32f4069 --- /dev/null +++ b/doc/source/changelog/28.miscellaneous.md @@ -0,0 +1 @@ +Ci: split logic into multiple workflows