|
| 1 | +# check spelling, codestyle |
| 2 | +name: GitHub CI |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + pull_request: |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - "*" |
| 10 | + branches: |
| 11 | + - main |
| 12 | + |
| 13 | +env: |
| 14 | + DOCUMENTATION_CNAME: 'engineeringworkflow.docs.pyansys.com' |
| 15 | + MAIN_PYTHON_VERSION: '3.11' |
| 16 | + PACKAGE_NAME: 'ansys-engineeringworkflow-api' |
| 17 | + PACKAGE_NAMESPACE: 'ansys.engineeringworkflow.api' |
| 18 | + |
| 19 | +jobs: |
| 20 | + code-style: |
| 21 | + name: "Code style" |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: PyAnsys code style checks |
| 25 | + uses: ansys/actions/code-style@v5 |
| 26 | + with: |
| 27 | + python-version: ${{ env.MAIN_PYTHON_VERSION }} |
| 28 | + |
| 29 | + doc-style: |
| 30 | + name: "Documentation Style Check" |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + - name: PyAnsys documentation style checks |
| 34 | + uses: ansys/actions/doc-style@v5 |
| 35 | + with: |
| 36 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + |
| 38 | + smoke-tests: |
| 39 | + name: "Build and Smoke tests" |
| 40 | + runs-on: ${{ matrix.os }} |
| 41 | + needs: [code-style] |
| 42 | + strategy: |
| 43 | + fail-fast: false |
| 44 | + matrix: |
| 45 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 46 | + python-version: ['3.9', '3.10', '3.11', '3.12'] |
| 47 | + should-release: |
| 48 | + - ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags') }} |
| 49 | + exclude: |
| 50 | + - should-release: false |
| 51 | + os: macos-latest |
| 52 | + |
| 53 | + steps: |
| 54 | + - name: Build wheelhouse and perform smoke test |
| 55 | + uses: ansys/actions/build-wheelhouse@v5 |
| 56 | + with: |
| 57 | + library-name: ${{ env.PACKAGE_NAME }} |
| 58 | + operating-system: ${{ matrix.os }} |
| 59 | + python-version: ${{ matrix.python-version }} |
| 60 | + |
| 61 | + build-test: |
| 62 | + name: "Build and unit testing" |
| 63 | + runs-on: ubuntu-latest |
| 64 | + needs: [smoke-tests] |
| 65 | + steps: |
| 66 | + - name: Run pytest |
| 67 | + uses: ansys/actions/tests-pytest@v5 |
| 68 | + with: |
| 69 | + python-version: ${{ env.MAIN_PYTHON_VERSION }} |
| 70 | + pytest-extra-args: -v --durations=10 --maxfail=10 --cov=${{ env.PACKAGE_NAMESPACE }} --cov-report=xml:coverage.xml --cov-report=html --cov-report term |
| 71 | + |
| 72 | + - name: "Upload coverage to Codecov" |
| 73 | + uses: codecov/codecov-action@v4 |
| 74 | + with: |
| 75 | + files: coverage.xml |
| 76 | + |
| 77 | + - name: "Upload coverage artifacts" |
| 78 | + uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: coverage-html |
| 81 | + path: htmlcov |
| 82 | + |
| 83 | + doc-build: |
| 84 | + name: "Documentation building" |
| 85 | + runs-on: ubuntu-latest |
| 86 | + needs: [doc-style] |
| 87 | + steps: |
| 88 | + - name: "Run Ansys documentation building action" |
| 89 | + uses: ansys/actions/doc-build@v5 |
| 90 | + with: |
| 91 | + python-version: ${{ env.MAIN_PYTHON_VERSION }} |
| 92 | + |
| 93 | + package: |
| 94 | + name: Package library |
| 95 | + needs: [doc-build, build-test] |
| 96 | + runs-on: ubuntu-latest |
| 97 | + steps: |
| 98 | + - name: Build library source and wheel artifacts |
| 99 | + uses: ansys/actions/build-library@v5 |
| 100 | + with: |
| 101 | + library-name: ${{ env.PACKAGE_NAME }} |
| 102 | + python-version: ${{ env.MAIN_PYTHON_VERSION }} |
| 103 | + |
| 104 | + doc-deploy-dev: |
| 105 | + name: "Deploy development documentation" |
| 106 | + # Deploy development only when merging to main |
| 107 | + if: github.ref == 'refs/heads/main' |
| 108 | + runs-on: ubuntu-latest |
| 109 | + needs: [package] |
| 110 | + steps: |
| 111 | + - name: "Deploy the latest documentation" |
| 112 | + uses: ansys/actions/doc-deploy-dev@v5 |
| 113 | + with: |
| 114 | + cname: ${{ env.DOCUMENTATION_CNAME }} |
| 115 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 116 | + |
| 117 | + release: |
| 118 | + name: "Release project to public PyPI and GitHub" |
| 119 | + if: github.event_name == 'push' && contains(github.ref, 'refs/tags') |
| 120 | + needs: [package] |
| 121 | + runs-on: ubuntu-latest |
| 122 | + steps: |
| 123 | + |
| 124 | + - name: "Release to the public PyPI repository" |
| 125 | + uses: ansys/actions/release-pypi-public@v5 |
| 126 | + with: |
| 127 | + library-name: ${{ env.PACKAGE_NAME }} |
| 128 | + twine-username: "__token__" |
| 129 | + twine-token: ${{ secrets.PYPI_TOKEN }} |
| 130 | + |
| 131 | + - name: "Release to GitHub" |
| 132 | + uses: ansys/actions/release-github@v5 |
| 133 | + with: |
| 134 | + library-name: ${{ env.PACKAGE_NAME }} |
| 135 | + |
| 136 | + doc-deploy-stable: |
| 137 | + name: "Deploy stable documentation" |
| 138 | + # Deploy release documentation when creating a new tag |
| 139 | + if: github.event_name == 'push' && contains(github.ref, 'refs/tags') |
| 140 | + runs-on: ubuntu-latest |
| 141 | + needs: [release] |
| 142 | + steps: |
| 143 | + - name: "Deploy the stable documentation" |
| 144 | + uses: ansys/actions/doc-deploy-stable@v5 |
| 145 | + with: |
| 146 | + cname: ${{ env.DOCUMENTATION_CNAME }} |
| 147 | + token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments