ci_ut.yml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. on:
  18. pull_request:
  19. push:
  20. branches:
  21. - dev
  22. env:
  23. LOG_DIR: /tmp/dolphinscheduler
  24. name: Unit Test
  25. jobs:
  26. build:
  27. name: Build
  28. runs-on: ubuntu-latest
  29. steps:
  30. - uses: actions/checkout@v2
  31. with:
  32. submodule: true
  33. - name: Check License Header
  34. uses: apache/skywalking-eyes@ec88b7d850018c8983f87729ea88549e100c5c82
  35. env:
  36. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Only enable review / suggestion here
  37. - uses: actions/cache@v1
  38. with:
  39. path: ~/.m2/repository
  40. key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
  41. restore-keys: |
  42. ${{ runner.os }}-maven-
  43. - name: Bootstrap database
  44. run: |
  45. sed -i "/image: bitnami\/postgresql/a\ ports:\n - 5432:5432" $(pwd)/docker/docker-swarm/docker-compose.yml
  46. sed -i "/image: bitnami\/zookeeper/a\ ports:\n - 2181:2181" $(pwd)/docker/docker-swarm/docker-compose.yml
  47. docker-compose -f $(pwd)/docker/docker-swarm/docker-compose.yml up -d dolphinscheduler-zookeeper dolphinscheduler-postgresql
  48. until docker logs docker-swarm_dolphinscheduler-postgresql_1 2>&1 | grep 'listening on IPv4 address'; do echo "waiting for postgresql ready ..."; sleep 1; done
  49. docker run --rm --network docker-swarm_dolphinscheduler -v $(pwd)/sql/dolphinscheduler_postgre.sql:/docker-entrypoint-initdb.d/dolphinscheduler_postgre.sql bitnami/postgresql:latest 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"
  50. - name: Set up JDK 1.8
  51. uses: actions/setup-java@v1
  52. with:
  53. java-version: 1.8
  54. - name: Git fetch unshallow
  55. run: |
  56. git fetch --unshallow
  57. git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
  58. git fetch origin
  59. - name: Compile
  60. run: |
  61. export MAVEN_OPTS='-Dmaven.repo.local=.m2/repository -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:-UseGCOverheadLimit -Xmx5g'
  62. mvn test -B -Dmaven.test.skip=false
  63. - name: Upload coverage report to codecov
  64. run: |
  65. CODECOV_TOKEN="09c2663f-b091-4258-8a47-c981827eb29a" bash <(curl -s https://codecov.io/bash)
  66. # Set up JDK 11 for SonarCloud.
  67. - name: Set up JDK 1.11
  68. uses: actions/setup-java@v1
  69. with:
  70. java-version: 1.11
  71. - name: Run SonarCloud Analysis
  72. run: >
  73. mvn --batch-mode verify sonar:sonar
  74. -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml
  75. -Dmaven.test.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. env:
  83. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  84. SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
  85. - name: Collect logs
  86. run: |
  87. mkdir -p ${LOG_DIR}
  88. docker-compose -f $(pwd)/docker/docker-swarm/docker-compose.yml logs dolphinscheduler-postgresql > ${LOG_DIR}/db.txt
  89. continue-on-error: true
  90. Checkstyle:
  91. name: Check code style
  92. runs-on: ubuntu-latest
  93. steps:
  94. - name: Checkout
  95. uses: actions/checkout@v2
  96. with:
  97. submodule: true
  98. - name: check code style
  99. env:
  100. WORKDIR: ./
  101. REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  102. CHECKSTYLE_CONFIG: style/checkstyle.xml
  103. REVIEWDOG_VERSION: v0.10.2
  104. run: |
  105. wget -O - -q https://github.com/checkstyle/checkstyle/releases/download/checkstyle-8.43/checkstyle-8.43-all.jar > /opt/checkstyle.jar
  106. wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b /opt ${REVIEWDOG_VERSION}
  107. java -jar /opt/checkstyle.jar "${WORKDIR}" -c "${CHECKSTYLE_CONFIG}" -f xml \
  108. | /opt/reviewdog -f=checkstyle \
  109. -reporter="${INPUT_REPORTER:-github-pr-check}" \
  110. -filter-mode="${INPUT_FILTER_MODE:-added}" \
  111. -fail-on-error="${INPUT_FAIL_ON_ERROR:-false}"