unit-test.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. paths-ignore:
  21. - '**/*.md'
  22. - 'dolphinscheduler-ui'
  23. push:
  24. paths-ignore:
  25. - '**/*.md'
  26. - 'dolphinscheduler-ui'
  27. branches:
  28. - dev
  29. env:
  30. LOG_DIR: /tmp/dolphinscheduler
  31. concurrency:
  32. group: unit-test-${{ github.event.pull_request.number || github.ref }}
  33. cancel-in-progress: true
  34. jobs:
  35. unit-test:
  36. name: Unit Test
  37. runs-on: ubuntu-latest
  38. steps:
  39. - uses: actions/checkout@v2
  40. with:
  41. submodules: true
  42. - name: Sanity Check
  43. uses: ./.github/actions/sanity-check
  44. - name: Set up JDK 1.8
  45. uses: actions/setup-java@v2
  46. with:
  47. java-version: 8
  48. distribution: 'adopt'
  49. - uses: actions/cache@v2
  50. with:
  51. path: ~/.m2/repository
  52. key: ${{ runner.os }}-maven
  53. - name: Bootstrap database
  54. run: |
  55. sed -i "/image: bitnami\/postgresql/a\ ports:\n - 5432:5432" $(pwd)/docker/docker-swarm/docker-compose.yml
  56. sed -i "/image: bitnami\/zookeeper/a\ ports:\n - 2181:2181" $(pwd)/docker/docker-swarm/docker-compose.yml
  57. docker-compose -f $(pwd)/docker/docker-swarm/docker-compose.yml up -d dolphinscheduler-zookeeper dolphinscheduler-postgresql
  58. until docker logs docker-swarm_dolphinscheduler-postgresql_1 2>&1 | grep 'listening on IPv4 address'; do echo "waiting for postgresql ready ..."; sleep 1; done
  59. docker run --rm --network docker-swarm_dolphinscheduler -v $(pwd)/sql/dolphinscheduler_postgre.sql:/docker-entrypoint-initdb.d/dolphinscheduler_postgre.sql bitnami/postgresql:11.11.0 bash -c "PGPASSWORD=root psql -h docker-swarm_dolphinscheduler-postgresql_1 -U root -d dolphinscheduler -v ON_ERROR_STOP=1 -f /docker-entrypoint-initdb.d/dolphinscheduler_postgre.sql"
  60. - name: Run Unit tests
  61. run: ./mvnw clean verify -B -Dmaven.test.skip=false
  62. - name: Upload coverage report to codecov
  63. run: CODECOV_TOKEN="09c2663f-b091-4258-8a47-c981827eb29a" bash <(curl -s https://codecov.io/bash)
  64. # Set up JDK 11 for SonarCloud.
  65. - name: Set up JDK 11
  66. uses: actions/setup-java@v2
  67. with:
  68. java-version: 11
  69. distribution: 'adopt'
  70. - name: Run SonarCloud Analysis
  71. run: >
  72. ./mvnw --batch-mode verify sonar:sonar
  73. -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml
  74. -Dmaven.test.skip=true
  75. -Dcheckstyle.skip=true
  76. -Dsonar.host.url=https://sonarcloud.io
  77. -Dsonar.organization=apache
  78. -Dsonar.core.codeCoveragePlugin=jacoco
  79. -Dsonar.projectKey=apache-dolphinscheduler
  80. -Dsonar.login=e4058004bc6be89decf558ac819aa1ecbee57682
  81. -Dsonar.exclusions=dolphinscheduler-ui/src/**/i18n/locale/*.js,dolphinscheduler-microbench/src/**/*
  82. -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120
  83. env:
  84. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  85. SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
  86. - name: Collect logs
  87. continue-on-error: true
  88. run: |
  89. mkdir -p ${LOG_DIR}
  90. docker-compose -f $(pwd)/docker/docker-swarm/docker-compose.yml logs dolphinscheduler-postgresql > ${LOG_DIR}/db.txt
  91. - name: Upload logs
  92. uses: actions/upload-artifact@v2
  93. continue-on-error: true
  94. with:
  95. name: unit-test-logs
  96. path: ${LOG_DIR}