ci_ut.yml 5.2 KB
Newer Older
K
khadgarmage 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

K
khadgarmage 已提交
18 19 20 21 22
on:
  pull_request:
  push:
    branches:
      - dev
23 24
env:
  LOG_DIR: /tmp/dolphinscheduler
K
khadgarmage 已提交
25

K
khadgarmage 已提交
26
name: Unit Test
K
khadgarmage 已提交
27 28 29 30 31 32 33 34

jobs:

  build:
    name: Build
    runs-on: ubuntu-latest
    steps:

K
khadgarmage 已提交
35
      - uses: actions/checkout@v2
36 37 38
        with:
          submodule: true
      - name: Check License Header
39
        uses: apache/skywalking-eyes@ec88b7d850018c8983f87729ea88549e100c5c82
40 41
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Only enable review / suggestion here
K
khadgarmage 已提交
42 43 44 45 46 47
      - uses: actions/cache@v1
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-maven-
48
      - name: Bootstrap database
X
xiaochun.liu 已提交
49
        run: |
50 51
          sed -i "/image: bitnami\/postgresql/a\    ports:\n    - 5432:5432" $(pwd)/docker/docker-swarm/docker-compose.yml
          sed -i "/image: bitnami\/zookeeper/a\    ports:\n    - 2181:2181" $(pwd)/docker/docker-swarm/docker-compose.yml
X
xiaochun.liu 已提交
52
          docker-compose -f $(pwd)/docker/docker-swarm/docker-compose.yml up -d dolphinscheduler-zookeeper dolphinscheduler-postgresql
53 54
          until docker logs docker-swarm_dolphinscheduler-postgresql_1 2>&1 | grep 'listening on IPv4 address'; do echo "waiting for postgresql ready ..."; sleep 1; done
          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"
K
khadgarmage 已提交
55 56 57 58
      - name: Set up JDK 1.8
        uses: actions/setup-java@v1
        with:
          java-version: 1.8
K
khadgarmage 已提交
59 60 61 62 63
      - name: Git fetch unshallow
        run: |
          git fetch --unshallow
          git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
          git fetch origin
K
khadgarmage 已提交
64 65
      - name: Compile
        run: |
D
dailidong 已提交
66
          export MAVEN_OPTS='-Dmaven.repo.local=.m2/repository -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:-UseGCOverheadLimit -Xmx5g'
K
khadgarmage 已提交
67
          mvn test -B -Dmaven.test.skip=false
K
khadgarmage 已提交
68 69
      - name: Upload coverage report to codecov
        run: |
K
khadgarmage 已提交
70
          CODECOV_TOKEN="09c2663f-b091-4258-8a47-c981827eb29a" bash <(curl -s https://codecov.io/bash)
71 72 73 74 75
      # Set up JDK 11 for SonarCloud.
      - name: Set up JDK 1.11
        uses: actions/setup-java@v1
        with:
          java-version: 1.11
76
      - name: Run SonarCloud Analysis
77
        run: >
78
          mvn --batch-mode verify sonar:sonar
K
khadgarmage 已提交
79
          -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml
80
          -Dmaven.test.skip=true
81 82
          -Dsonar.host.url=https://sonarcloud.io
          -Dsonar.organization=apache
K
khadgarmage 已提交
83
          -Dsonar.core.codeCoveragePlugin=jacoco
84 85
          -Dsonar.projectKey=apache-dolphinscheduler
          -Dsonar.login=e4058004bc6be89decf558ac819aa1ecbee57682
C
CalvinKirs 已提交
86
          -Dsonar.exclusions=dolphinscheduler-ui/src/**/i18n/locale/*.js,dolphinscheduler-microbench/src/**/*
87
        env:
88 89
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
90 91 92
      - name: Collect logs
        run: |
          mkdir -p ${LOG_DIR}
X
xiaochun.liu 已提交
93
          docker-compose -f $(pwd)/docker/docker-swarm/docker-compose.yml logs dolphinscheduler-postgresql > ${LOG_DIR}/db.txt
94
        continue-on-error: true
95 96 97 98 99 100 101

  Checkstyle:
    name: Check code style
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
102 103
        with:
          submodule: true
104 105 106 107 108 109 110
      - name: check code style
        env:
          WORKDIR: ./
          REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          CHECKSTYLE_CONFIG: style/checkstyle.xml
          REVIEWDOG_VERSION: v0.10.2
        run: |
111
          wget -O - -q https://github.com/checkstyle/checkstyle/releases/download/checkstyle-8.43/checkstyle-8.43-all.jar > /opt/checkstyle.jar
112 113 114 115 116
          wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b /opt ${REVIEWDOG_VERSION}
          java -jar /opt/checkstyle.jar "${WORKDIR}" -c "${CHECKSTYLE_CONFIG}"  -f xml \
               | /opt/reviewdog -f=checkstyle \
                    -reporter="${INPUT_REPORTER:-github-pr-check}" \
                    -filter-mode="${INPUT_FILTER_MODE:-added}" \
117
                    -fail-on-error="${INPUT_FAIL_ON_ERROR:-false}"