py-ci.yml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. name: Python API
  16. on:
  17. push:
  18. branches:
  19. - dev
  20. paths:
  21. - 'dolphinscheduler-python/**'
  22. pull_request:
  23. concurrency:
  24. group: py-${{ github.event.pull_request.number || github.ref }}
  25. cancel-in-progress: true
  26. defaults:
  27. run:
  28. working-directory: dolphinscheduler-python/pydolphinscheduler
  29. # We have to update setuptools wheel to package with package_data, LICENSE, NOTICE
  30. env:
  31. DEPENDENCES: pip setuptools wheel tox
  32. jobs:
  33. paths-filter:
  34. name: Python-Path-Filter
  35. runs-on: ubuntu-latest
  36. outputs:
  37. not-docs: ${{ steps.filter.outputs.not-docs }}
  38. py-change: ${{ steps.filter.outputs.py-change }}
  39. steps:
  40. - uses: actions/checkout@v2
  41. - uses: dorny/paths-filter@b2feaf19c27470162a626bd6fa8438ae5b263721
  42. id: filter
  43. with:
  44. filters: |
  45. not-docs:
  46. - '!(docs/**)'
  47. py-change:
  48. - 'dolphinscheduler-python/pydolphinscheduler/**'
  49. lint:
  50. name: Lint
  51. if: ${{ (needs.paths-filter.outputs.py-change == 'true') || (github.event_name == 'push') }}
  52. timeout-minutes: 15
  53. needs: paths-filter
  54. runs-on: ubuntu-latest
  55. steps:
  56. - uses: actions/checkout@v2
  57. - name: Set up Python 3.7
  58. uses: actions/setup-python@v4
  59. with:
  60. python-version: 3.7
  61. - name: Install Dependences
  62. run: |
  63. python -m pip install --upgrade ${{ env.DEPENDENCES }}
  64. - name: Run All Lint Check
  65. run: |
  66. python -m tox -vv -e lint
  67. pytest:
  68. name: Pytest
  69. timeout-minutes: 15
  70. needs: lint
  71. runs-on: ${{ matrix.os }}
  72. strategy:
  73. fail-fast: false
  74. matrix:
  75. # YAML parse `3.10` to `3.1`, so we have to add quotes for `'3.10'`, see also:
  76. # https://github.com/actions/setup-python/issues/160#issuecomment-724485470
  77. python-version: [3.6, 3.7, 3.8, 3.9, '3.10', 3.11-dev]
  78. os: [ubuntu-latest, macOS-latest, windows-latest]
  79. # Skip because dependence [py4j](https://pypi.org/project/py4j/) not work on those environments
  80. exclude:
  81. - os: windows-latest
  82. python-version: '3.10'
  83. - os: windows-latest
  84. python-version: 3.11-dev
  85. steps:
  86. - uses: actions/checkout@v2
  87. - name: Set up Python ${{ matrix.python-version }}
  88. uses: actions/setup-python@v4
  89. with:
  90. python-version: ${{ matrix.python-version }}
  91. - name: Install Dependences
  92. run: |
  93. python -m pip install --upgrade ${{ env.DEPENDENCES }}
  94. - name: Run All Tests
  95. run: |
  96. python -m tox -vv -e code-test
  97. doc-build:
  98. name: Docs Build Test
  99. timeout-minutes: 15
  100. needs: lint
  101. runs-on: ubuntu-latest
  102. strategy:
  103. fail-fast: false
  104. matrix:
  105. env-list: [doc-build, doc-build-multi]
  106. steps:
  107. - uses: actions/checkout@v2
  108. - name: Set up Python 3.7
  109. uses: actions/setup-python@v4
  110. with:
  111. python-version: 3.7
  112. - name: Install Dependences
  113. run: |
  114. python -m pip install --upgrade ${{ env.DEPENDENCES }}
  115. - name: Run Build Docs Tests ${{ matrix.env-list }}
  116. run: |
  117. python -m tox -vv -e ${{ matrix.env-list }}
  118. local-ci:
  119. name: Local CI
  120. timeout-minutes: 15
  121. needs:
  122. - pytest
  123. - doc-build
  124. runs-on: ubuntu-latest
  125. steps:
  126. - uses: actions/checkout@v2
  127. - name: Set up Python 3.7
  128. uses: actions/setup-python@v4
  129. with:
  130. python-version: 3.7
  131. - name: Install Dependences
  132. run: |
  133. python -m pip install --upgrade ${{ env.DEPENDENCES }}
  134. - name: Run Tests Build Docs
  135. run: |
  136. python -m tox -vv -e local-ci
  137. integrate-test:
  138. name: Integrate Test
  139. if: ${{ (needs.paths-filter.outputs.not-docs == 'true') || (github.event_name == 'push') }}
  140. runs-on: ubuntu-latest
  141. needs: paths-filter
  142. timeout-minutes: 30
  143. steps:
  144. - uses: actions/checkout@v2
  145. with:
  146. submodules: true
  147. - name: Sanity Check
  148. uses: ./.github/actions/sanity-check
  149. with:
  150. token: ${{ secrets.GITHUB_TOKEN }}
  151. - name: Cache local Maven repository
  152. uses: actions/cache@v3
  153. with:
  154. path: ~/.m2/repository
  155. key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
  156. restore-keys: ${{ runner.os }}-maven-
  157. # Switch to project root directory to run mvnw command
  158. - name: Build Image
  159. working-directory: ./
  160. run: |
  161. ./mvnw -B clean install \
  162. -Dmaven.test.skip \
  163. -Dmaven.javadoc.skip \
  164. -Dcheckstyle.skip=true \
  165. -Pdocker,release -Ddocker.tag=ci \
  166. -pl dolphinscheduler-standalone-server -am
  167. - name: Set up Python 3.7
  168. uses: actions/setup-python@v4
  169. with:
  170. python-version: 3.7
  171. - name: Install Dependences
  172. run: |
  173. python -m pip install --upgrade ${{ env.DEPENDENCES }}
  174. - name: Run Integrate Tests
  175. run: |
  176. python -m tox -vv -e integrate-test
  177. result:
  178. name: Python
  179. runs-on: ubuntu-latest
  180. timeout-minutes: 30
  181. needs: [ paths-filter, local-ci, integrate-test ]
  182. if: always()
  183. steps:
  184. - name: Status
  185. # We need change CWD to current directory to avoid global default working directory not exists
  186. working-directory: ./
  187. run: |
  188. if [[ ${{ needs.paths-filter.outputs.not-docs }} == 'false' && ${{ github.event_name }} == 'pull_request' ]]; then
  189. echo "Only document change, skip both python unit and integrate test!"
  190. exit 0
  191. fi
  192. if [[ ${{ needs.paths-filter.outputs.py-change }} == 'false' && ${{ needs.integrate-test.result }} == 'success' && ${{ github.event_name }} == 'pull_request' ]]; then
  193. echo "No python code change, and integrate test pass!"
  194. exit 0
  195. fi
  196. if [[ ${{ needs.integrate-test.result }} != 'success' || ${{ needs.local-ci.result }} != 'success' ]]; then
  197. echo "py-ci Failed!"
  198. exit -1
  199. fi