|
| 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 | + |
| 18 | +name: Build and Run Tests |
| 19 | + |
| 20 | +on: |
| 21 | + push: |
| 22 | + # Publish only on `master` |
| 23 | + branches: |
| 24 | + - master |
| 25 | + pull_request: |
| 26 | + branches: |
| 27 | + - master |
| 28 | + release: |
| 29 | + types: [published, edited] |
| 30 | + |
| 31 | +jobs: |
| 32 | + build: |
| 33 | + name: Build repository |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - name: Check out the repo |
| 37 | + uses: actions/checkout@v2 |
| 38 | + - name: Set up JDK 1.8 |
| 39 | + uses: actions/setup-java@v1 |
| 40 | + with: |
| 41 | + java-version: 1.8 |
| 42 | + # Stores external dependencies, can be further improved with Gradle 6.1 |
| 43 | + - name: Cache Gradle Dependencies |
| 44 | + uses: actions/cache@v2 |
| 45 | + with: |
| 46 | + path: | |
| 47 | + ~/.gradle/caches |
| 48 | + ~/.gradle/wrapper |
| 49 | + # Only rebuild cache if build.gradle is changed |
| 50 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} |
| 51 | + restore-keys: ${{ runner.os }}-gradle |
| 52 | + - name: Build repository |
| 53 | + run: | |
| 54 | + ./gradlew --no-daemon clean build -x test -x javadoc -x findbugsMain -x findbugsTest -x checkstyleMain -x checkstyleJmh -x checkstyleTest -Dorg.gradle.parallel=true |
| 55 | +
|
| 56 | + test_coverage: |
| 57 | + runs-on: ubuntu-latest |
| 58 | + name: Generate test coverage |
| 59 | + needs: build |
| 60 | + steps: |
| 61 | + - name: Check out the repo |
| 62 | + uses: actions/checkout@v2 |
| 63 | + - name: Set up JDK 1.8 |
| 64 | + uses: actions/setup-java@v1 |
| 65 | + with: |
| 66 | + java-version: 1.8 |
| 67 | + - name: Cache Gradle Dependencies |
| 68 | + uses: actions/cache@v2 |
| 69 | + with: |
| 70 | + path: | |
| 71 | + ~/.gradle/caches |
| 72 | + ~/.gradle/wrapper |
| 73 | + # Only rebuild cache if build.gradle is changed |
| 74 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} |
| 75 | + restore-keys: ${{ runner.os }}-gradle |
| 76 | + - name: Generate code coverage |
| 77 | + run: | |
| 78 | + ./gradlew -PskipTestGroup=disabledOnCI -Dorg.gradle.parallel=false -DjacocoBuild=1 $GOBBLIN_GRADLE_OPTS jacocoTestCoverage |
| 79 | +
|
| 80 | + static_checks: |
| 81 | + name: Run static checks |
| 82 | + runs-on: ubuntu-latest |
| 83 | + needs: build |
| 84 | + steps: |
| 85 | + - name: Check out the repo |
| 86 | + uses: actions/checkout@v2 |
| 87 | + - name: Set up JDK 1.8 |
| 88 | + uses: actions/setup-java@v1 |
| 89 | + with: |
| 90 | + java-version: 1.8 |
| 91 | + # Stores external dependencies, can be further improved with Gradle 6.1 |
| 92 | + - name: Cache Gradle Dependencies |
| 93 | + uses: actions/cache@v2 |
| 94 | + with: |
| 95 | + path: | |
| 96 | + ~/.gradle/caches |
| 97 | + ~/.gradle/wrapper |
| 98 | + # Only rebuild cache if build.gradle is changed |
| 99 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} |
| 100 | + restore-keys: ${{ runner.os }}-gradle |
| 101 | + - name: Run CheckStyle and FindBugs |
| 102 | + run: | |
| 103 | + ./gradlew --no-daemon -x javadoc findbugsMain checkstyleMain checkstyleTest checkstyleJmh |
| 104 | +
|
| 105 | + run_tests: |
| 106 | + timeout-minutes: 60 |
| 107 | + env: |
| 108 | + GOBBLIN_GRADLE_OPTS: "--no-daemon -Dgobblin.metastore.testing.embeddedMysqlEnabled=false -PusePreinstalledMysql=true" |
| 109 | + strategy: |
| 110 | + matrix: |
| 111 | + test-group: ["Core Tests", "Service Tests", "Module Tests", "Other Tests"] |
| 112 | + fail-fast: false |
| 113 | + runs-on: ubuntu-latest |
| 114 | + needs: build |
| 115 | + services: |
| 116 | + mysql: |
| 117 | + image: mysql:5.7.32 |
| 118 | + env: |
| 119 | + MYSQL_USER: testUser |
| 120 | + MYSQL_PASSWORD: testPassword |
| 121 | + MYSQL_DATABASE: test |
| 122 | + MYSQL_ROOT_PASSWORD: password |
| 123 | + ports: |
| 124 | + - 3306:3306 |
| 125 | + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 |
| 126 | + steps: |
| 127 | + - name: Check out the repo |
| 128 | + uses: actions/checkout@v2 |
| 129 | + - name: Set up JDK 1.8 |
| 130 | + uses: actions/setup-java@v1 |
| 131 | + with: |
| 132 | + java-version: 1.8 |
| 133 | + - name: Verify mysql connection |
| 134 | + run: | |
| 135 | + sudo apt-get install -y mysql-client |
| 136 | + mysql --host 127.0.0.1 --port 3306 -uroot -ppassword -e "SHOW DATABASES" |
| 137 | + - name: Cache Gradle Dependencies |
| 138 | + uses: actions/cache@v2 |
| 139 | + with: |
| 140 | + path: | |
| 141 | + ~/.gradle/caches |
| 142 | + ~/.gradle/wrapper |
| 143 | + # Only rebuild cache if build.gradle is changed |
| 144 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} |
| 145 | + restore-keys: ${{ runner.os }}-gradle |
| 146 | + - name: Run test group ${{ matrix.test-group }} |
| 147 | + # Write retry logic as integration tests can fail due to timing out or network problems |
| 148 | + run: | |
| 149 | + ./gradlew getGroupedTests -PgroupName="${{matrix.test-group}}" > temp.txt |
| 150 | + TASKS=$(sed -n 's/CI Task: //p' temp.txt) |
| 151 | + echo $TASKS |
| 152 | +
|
| 153 | + n=0 |
| 154 | + until [ "$n" -ge 3 ] |
| 155 | + do |
| 156 | + ./gradlew -PskipTestGroup=disabledOnCI $GOBBLIN_GRADLE_OPTS $TASKS -Dorg.gradle.parallel=false && break |
| 157 | + n=$((n+1)) |
| 158 | + if [[ $n -lt 3 ]]; then |
| 159 | + echo "Tests failed, retry attempt number $n" |
| 160 | + else |
| 161 | + exit 1 |
| 162 | + fi |
| 163 | + sleep 10 |
| 164 | + done |
0 commit comments