1name: CI 2 3on: 4 push: 5 branches: 6 - master 7 pull_request: 8 9jobs: 10 bazel-test: 11 name: 'Bazel tests' 12 runs-on: ubuntu-latest 13 steps: 14 - name: 'Check out repository' 15 uses: actions/checkout@v2 16 - name: 'Cache local Maven repository' 17 uses: actions/cache@v2 18 with: 19 path: | 20 ~/.m2/repository 21 !~/.m2/repository/com/google/dagger 22 key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} 23 restore-keys: | 24 ${{ runner.os }}-maven- 25 - name: 'Cache Bazel files' 26 uses: actions/cache@v2 27 with: 28 path: ~/.cache/bazel 29 key: ${{ runner.os }}-bazel-${{ github.sha }} 30 restore-keys: | 31 ${{ runner.os }}-bazel- 32 - name: 'Cache Gradle files' 33 uses: actions/cache@v2 34 with: 35 path: | 36 ~/.gradle/caches 37 ~/.gradle/wrapper 38 key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} 39 restore-keys: | 40 ${{ runner.os }}-gradle- 41 - name: 'Run Bazel tests' 42 run: bazel test --test_output=errors //... 43 shell: bash 44 - name: 'Install local snapshot' 45 run: ./util/install-local-snapshot.sh 46 shell: bash 47 - name: 'Upload local snapshot for tests' 48 uses: actions/upload-artifact@v2 49 with: 50 name: local-snapshot 51 path: ~/.m2/repository/com/google/dagger 52 artifact-java-local-tests: 53 name: 'Artifact Java local tests' 54 needs: bazel-test 55 runs-on: ubuntu-latest 56 steps: 57 - name: 'Check out repository' 58 uses: actions/checkout@v2 59 - name: 'Cache Gradle files' 60 uses: actions/cache@v2 61 with: 62 path: | 63 ~/.gradle/caches 64 ~/.gradle/wrapper 65 key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} 66 restore-keys: | 67 ${{ runner.os }}-gradle- 68 - name: 'Download local snapshot for tests' 69 uses: actions/download-artifact@v2 70 with: 71 name: local-snapshot 72 path: ~/.m2/repository/com/google/dagger 73 - name: 'Gradle Java local tests' 74 run: ./util/run-local-gradle-tests.sh 75 shell: bash 76 artifact-android-local-tests: 77 name: 'Artifact Android local tests (AGP ${{ matrix.agp }})' 78 needs: bazel-test 79 runs-on: ubuntu-latest 80 strategy: 81 matrix: 82 agp: ['4.1.0', '4.2.0-beta04'] 83 steps: 84 - name: 'Check out repository' 85 uses: actions/checkout@v2 86 - name: 'Cache Gradle files' 87 uses: actions/cache@v2 88 with: 89 path: | 90 ~/.gradle/caches 91 ~/.gradle/wrapper 92 key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} 93 restore-keys: | 94 ${{ runner.os }}-gradle- 95 - name: 'Download local snapshot for tests' 96 uses: actions/download-artifact@v2 97 with: 98 name: local-snapshot 99 path: ~/.m2/repository/com/google/dagger 100 - name: 'Gradle Android local tests (AGP ${{ matrix.agp }})' 101 run: ./util/run-local-gradle-android-tests.sh "${{ matrix.agp }}" 102 shell: bash 103 artifact-android-emulator-tests: 104 name: 'Artifact Android emulator tests (API 30)' 105 needs: bazel-test 106 # It's recommended to run emulator tests on macOS 107 # See https://github.com/marketplace/actions/android-emulator-runner 108 runs-on: macos-latest 109 steps: 110 - name: 'Check out repository' 111 uses: actions/checkout@v2 112 - name: 'Cache Gradle files' 113 uses: actions/cache@v2 114 with: 115 path: | 116 ~/.gradle/caches 117 ~/.gradle/wrapper 118 key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} 119 restore-keys: | 120 ${{ runner.os }}-gradle- 121 - name: 'Download local snapshot for tests' 122 uses: actions/download-artifact@v2 123 with: 124 name: local-snapshot 125 path: ~/.m2/repository/com/google/dagger 126 - name: 'Gradle Android emulator tests (API 30)' 127 uses: reactivecircus/android-emulator-runner@v2 128 timeout-minutes: 25 129 with: 130 api-level: 30 131 target: google_apis 132 script: ./util/run-local-emulator-tests.sh 133 publish-snapshot: 134 name: 'Publish snapshot' 135 # TODO(bcorso): Consider also waiting on artifact-android-emulator-tests 136 # and artifact-android-emulator-legacy-api-tests after checking flakiness. 137 needs: [bazel-test, artifact-java-local-tests, artifact-android-local-tests] 138 if: github.event_name == 'push' && github.repository == 'google/dagger' && github.ref == 'refs/heads/master' 139 runs-on: ubuntu-latest 140 steps: 141 - name: 'Check out repository' 142 uses: actions/checkout@v2 143 - name: 'Cache local Maven repository' 144 uses: actions/cache@v2 145 with: 146 path: | 147 ~/.m2/repository 148 !~/.m2/repository/com/google/dagger 149 key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} 150 restore-keys: | 151 ${{ runner.os }}-maven- 152 - name: 'Cache Bazel files' 153 uses: actions/cache@v2 154 with: 155 path: ~/.cache/bazel 156 key: ${{ runner.os }}-bazel-${{ github.sha }} 157 restore-keys: | 158 ${{ runner.os }}-bazel- 159 - name: 'Cache Gradle files' 160 uses: actions/cache@v2 161 with: 162 path: | 163 ~/.gradle/caches 164 ~/.gradle/wrapper 165 key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} 166 restore-keys: | 167 ${{ runner.os }}-gradle- 168 - name: 'Publish latest docs' 169 run: ./util/generate-latest-docs.sh 170 shell: bash 171 env: 172 GH_TOKEN: ${{ github.token }} 173 - name: 'Publish latest snapshot' 174 run: ./util/publish-snapshot-on-commit.sh 175 shell: bash 176 env: 177 CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} 178 CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} 179 artifact-android-emulator-legacy-api-tests: 180 name: 'Artifact Android emulator tests (API ${{ matrix.api-level }})' 181 # We only run this on master push (essentially a postsubmit) since these 182 # can take a while to run 183 if: github.event_name == 'push' && github.repository == 'google/dagger' && github.ref == 'refs/heads/master' 184 needs: bazel-test 185 # It's recommended to run emulator tests on macOS 186 # See https://github.com/marketplace/actions/android-emulator-runner 187 runs-on: macos-latest 188 strategy: 189 matrix: 190 api-level: [16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 29] 191 steps: 192 - name: 'Check out repository' 193 uses: actions/checkout@v2 194 - name: 'Cache Gradle files' 195 uses: actions/cache@v2 196 with: 197 path: | 198 ~/.gradle/caches 199 ~/.gradle/wrapper 200 key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} 201 restore-keys: | 202 ${{ runner.os }}-gradle- 203 - name: 'Download local snapshot for tests' 204 uses: actions/download-artifact@v2 205 with: 206 name: local-snapshot 207 path: ~/.m2/repository/com/google/dagger 208 - name: 'Gradle Android emulator tests (API ${{ matrix.api-level }})' 209 uses: reactivecircus/android-emulator-runner@v2 210 timeout-minutes: 25 211 with: 212 api-level: ${{ matrix.api-level }} 213 target: google_apis 214 script: ./util/run-local-emulator-tests.sh 215