unit-test.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. name: Test
  18. on:
  19. pull_request:
  20. push:
  21. paths-ignore:
  22. - '**/*.md'
  23. - 'dolphinscheduler-ui'
  24. branches:
  25. - dev
  26. env:
  27. LOG_DIR: /tmp/dolphinscheduler
  28. concurrency:
  29. group: unit-test-${{ github.event.pull_request.number || github.ref }}
  30. cancel-in-progress: true
  31. jobs:
  32. paths-filter:
  33. name: Unit-Test-Path-Filter
  34. runs-on: ubuntu-latest
  35. outputs:
  36. not-ignore: ${{ steps.filter.outputs.not-ignore }}
  37. steps:
  38. - uses: actions/checkout@v2
  39. - uses: dorny/paths-filter@b2feaf19c27470162a626bd6fa8438ae5b263721
  40. id: filter
  41. with:
  42. filters: |
  43. not-ignore:
  44. - '!(docs/**)'
  45. unit-test:
  46. name: Unit-Test
  47. needs: paths-filter
  48. if: ${{ (needs.paths-filter.outputs.not-ignore == 'true') || (github.event_name == 'push') }}
  49. runs-on: ubuntu-latest
  50. strategy:
  51. matrix:
  52. java: ['8', '11']
  53. timeout-minutes: 45
  54. steps:
  55. - uses: actions/checkout@v2
  56. with:
  57. submodules: true
  58. - name: Sanity Check
  59. uses: ./.github/actions/sanity-check
  60. with:
  61. token: ${{ secrets.GITHUB_TOKEN }}
  62. - name: Set up JDK ${{ matrix.java }}
  63. uses: actions/setup-java@v2
  64. with:
  65. java-version: ${{ matrix.java }}
  66. distribution: 'adopt'
  67. - uses: actions/cache@v3
  68. with:
  69. path: ~/.m2/repository
  70. key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-unit-test
  71. restore-keys: ${{ runner.os }}-maven-
  72. - name: Run Unit tests
  73. run: ./mvnw clean verify -B -Dmaven.test.skip=false -Dspotless.skip=true -DskipUT=false -DskipIT=false
  74. - name: Upload coverage report to codecov
  75. run: CODECOV_TOKEN="09c2663f-b091-4258-8a47-c981827eb29a" bash <(curl -s https://codecov.io/bash)
  76. # Set up JDK 17 for SonarCloud.
  77. - name: Set up JDK 17
  78. uses: actions/setup-java@v2
  79. with:
  80. java-version: 17
  81. distribution: 'adopt'
  82. - name: Run SonarCloud Analysis
  83. run: >
  84. ./mvnw --batch-mode verify sonar:sonar
  85. -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml
  86. -Dmaven.test.skip=true
  87. -Dspotless.skip=true
  88. -Dsonar.host.url=https://sonarcloud.io
  89. -Dsonar.organization=apache
  90. -Dsonar.core.codeCoveragePlugin=jacoco
  91. -Dsonar.projectKey=apache-dolphinscheduler
  92. -Dsonar.login=e4058004bc6be89decf558ac819aa1ecbee57682
  93. -Dsonar.exclusions=,dolphinscheduler-ui/src/**/i18n/locale/*.js,dolphinscheduler-microbench/src/**/*
  94. -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120
  95. -DskipUT=true -DskipIT=true
  96. env:
  97. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  98. SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
  99. - name: Collect logs
  100. continue-on-error: true
  101. run: |
  102. mkdir -p ${LOG_DIR}
  103. docker-compose -f $(pwd)/docker/docker-swarm/docker-compose.yml logs dolphinscheduler-postgresql > ${LOG_DIR}/db.txt
  104. - name: Upload logs
  105. uses: actions/upload-artifact@v2
  106. continue-on-error: true
  107. with:
  108. name: unit-test-logs
  109. path: ${LOG_DIR}
  110. result:
  111. name: Unit Test
  112. runs-on: ubuntu-latest
  113. timeout-minutes: 30
  114. needs: [ unit-test, paths-filter ]
  115. if: always()
  116. steps:
  117. - name: Status
  118. run: |
  119. if [[ ${{ needs.paths-filter.outputs.not-ignore }} == 'false' && ${{ github.event_name }} == 'pull_request' ]]; then
  120. echo "Skip Unit Test!"
  121. exit 0
  122. fi
  123. if [[ ${{ needs.unit-test.result }} != 'success' ]]; then
  124. echo "Unit Test Failed!"
  125. exit -1
  126. fi