|
| 1 | +name: Android CI |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [ master ] |
| 5 | + pull_request: |
| 6 | + branches: [ master ] |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + SNAPSHOT: |
| 10 | + type: boolean |
| 11 | + description: Set SNAPSHOT true to publish |
| 12 | + |
| 13 | +jobs: |
| 14 | + lint_markdown_files: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v2 |
| 18 | + - name: Set up Ruby |
| 19 | + uses: ruby/setup-ruby@v1 |
| 20 | + with: |
| 21 | + ruby-version: '2.6' |
| 22 | + bundler-cache: true # runs 'bundle install' and caches installed gems automatically |
| 23 | + - name: Install gem |
| 24 | + run: | |
| 25 | + gem install awesome_bot |
| 26 | + - name: Run tests |
| 27 | + run: find . -type f -name '*.md' -exec awesome_bot {} \; |
| 28 | + integration_tests: |
| 29 | + if: ${{ github.event.inputs.SNAPSHOT != 'true' }} |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v2 |
| 33 | + with: |
| 34 | + # You should create a personal access token and store it in your repository |
| 35 | + token: ${{ secrets.CI_USER_TOKEN }} |
| 36 | + repository: 'optimizely/travisci-tools' |
| 37 | + path: 'home/runner/travisci-tools' |
| 38 | + ref: 'master' |
| 39 | + |
| 40 | + - name: set SDK Branch if PR |
| 41 | + if: ${{ github.event_name == 'pull_request' }} |
| 42 | + run: | |
| 43 | + echo "SDK_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV |
| 44 | + echo "TRAVIS_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV |
| 45 | + - name: set SDK Branch if not pull request |
| 46 | + if: ${{ github.event_name != 'pull_request' }} |
| 47 | + run: | |
| 48 | + echo "SDK_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV |
| 49 | + echo "TRAVIS_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV |
| 50 | + - name: Trigger build |
| 51 | + env: |
| 52 | + SDK: android |
| 53 | + BUILD_NUMBER: ${{ github.run_id }} |
| 54 | + TESTAPP_BRANCH: master |
| 55 | + GITHUB_TOKEN: ${{ secrets.CI_USER_TOKEN }} |
| 56 | + TRAVIS_EVENT_TYPE: ${{ github.event_name }} |
| 57 | + GITHUB_CONTEXT: ${{ toJson(github) }} |
| 58 | + TRAVIS_REPO_SLUG: ${{ github.repository }} |
| 59 | + TRAVIS_PULL_REQUEST_SLUG: ${{ github.repository }} |
| 60 | + UPSTREAM_REPO: ${{ github.repository }} |
| 61 | + TRAVIS_COMMIT: ${{ github.sha }} |
| 62 | + TRAVIS_PULL_REQUEST_SHA: ${{ github.event.pull_request.head.sha }} |
| 63 | + TRAVIS_PULL_REQUEST: ${{ github.event.pull_request.number }} |
| 64 | + UPSTREAM_SHA: ${{ github.sha }} |
| 65 | + TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }} |
| 66 | + EVENT_MESSAGE: ${{ github.event.message }} |
| 67 | + HOME: 'home/runner' |
| 68 | + run: | |
| 69 | + echo "$GITHUB_CONTEXT" |
| 70 | + home/runner/travisci-tools/trigger-script-with-status-update.sh |
| 71 | + build: |
| 72 | + runs-on: ubuntu-latest |
| 73 | + steps: |
| 74 | + - uses: actions/checkout@v2 |
| 75 | + - name: set up JDK 11 |
| 76 | + uses: actions/setup-java@v2 |
| 77 | + with: |
| 78 | + java-version: '11' |
| 79 | + distribution: 'temurin' |
| 80 | + cache: gradle |
| 81 | + - name: Grant execute permission for gradlew |
| 82 | + run: chmod +x gradlew |
| 83 | + - name: Clean all modules |
| 84 | + run: ./gradlew cleanAllModules |
| 85 | + - name: Build with Gradle |
| 86 | + run: ./gradlew build |
| 87 | + test: |
| 88 | + runs-on: macos-latest |
| 89 | + strategy: |
| 90 | + fail-fast: false |
| 91 | + matrix: |
| 92 | + api-level: [21, 25, 26, 29] |
| 93 | + steps: |
| 94 | + - name: checkout |
| 95 | + uses: actions/checkout@v2 |
| 96 | + |
| 97 | + - name: set up JDK 11 |
| 98 | + uses: actions/setup-java@v1 |
| 99 | + with: |
| 100 | + java-version: 11 |
| 101 | + |
| 102 | + - name: Grant execute permission for gradlew |
| 103 | + run: chmod +x gradlew |
| 104 | + |
| 105 | + - name: Gradle cache |
| 106 | + uses: actions/cache@v2 |
| 107 | + with: |
| 108 | + path: | |
| 109 | + ~/.gradle/caches |
| 110 | + ~/.gradle/wrapper |
| 111 | + key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }} |
| 112 | + |
| 113 | + - name: AVD cache |
| 114 | + uses: actions/cache@v2 |
| 115 | + id: avd-cache |
| 116 | + with: |
| 117 | + path: | |
| 118 | + ~/.android/avd/* |
| 119 | + ~/.android/adb* |
| 120 | + ~/.android/debug.keystore |
| 121 | + key: avd-${{ matrix.api-level }} |
| 122 | + |
| 123 | + - name: create AVD and generate snapshot for caching |
| 124 | + if: steps.avd-cache.outputs.cache-hit != 'true' |
| 125 | + uses: reactivecircus/android-emulator-runner@v2 |
| 126 | + with: |
| 127 | + api-level: ${{ matrix.api-level }} |
| 128 | + force-avd-creation: false |
| 129 | + emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none |
| 130 | + disable-animations: false |
| 131 | + script: echo "Generated AVD snapshot for caching." |
| 132 | + |
| 133 | + - name: run tests |
| 134 | + uses: reactivecircus/android-emulator-runner@v2 |
| 135 | + with: |
| 136 | + api-level: ${{ matrix.api-level }} |
| 137 | + force-avd-creation: false |
| 138 | + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none |
| 139 | + disable-animations: true |
| 140 | + script: ./gradlew testAllModulesTravis |
| 141 | + publish: |
| 142 | + if: startsWith(github.ref, 'refs/tags/v') |
| 143 | + runs-on: ubuntu-latest |
| 144 | + steps: |
| 145 | + - uses: actions/checkout@v2 |
| 146 | + - name: Set env |
| 147 | + run: echo "TRAVIS_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV |
| 148 | + - name: set up JDK 11 |
| 149 | + uses: actions/setup-java@v2 |
| 150 | + with: |
| 151 | + java-version: '11' |
| 152 | + distribution: 'temurin' |
| 153 | + cache: gradle |
| 154 | + - name: Grant execute permission for gradlew |
| 155 | + run: chmod +x gradlew |
| 156 | + - name: Ship |
| 157 | + env: |
| 158 | + MAVEN_SIGNING_KEY_BASE64: ${{ secrets.MAVEN_SIGNING_KEY_BASE64 }} |
| 159 | + MAVEN_SIGNING_PASSPHRASE: ${{ secrets.MAVEN_SIGNING_PASSPHRASE }} |
| 160 | + MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} |
| 161 | + MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} |
| 162 | + run: TRAVIS_TAG=${{ env.TRAVIS_TAG }} ./gradlew ship |
| 163 | + |
| 164 | + snapshot: |
| 165 | + if: ${{ github.event.inputs.SNAPSHOT == 'true' && github.event_name == 'workflow_dispatch' }} |
| 166 | + runs-on: ubuntu-latest |
| 167 | + steps: |
| 168 | + - uses: actions/checkout@v2 |
| 169 | + - name: set up JDK 11 |
| 170 | + uses: actions/setup-java@v2 |
| 171 | + with: |
| 172 | + java-version: '11' |
| 173 | + distribution: 'temurin' |
| 174 | + cache: gradle |
| 175 | + - name: Grant execute permission for gradlew |
| 176 | + run: chmod +x gradlew |
| 177 | + - name: Ship |
| 178 | + env: |
| 179 | + MAVEN_SIGNING_KEY_BASE64: ${{ secrets.MAVEN_SIGNING_KEY_BASE64 }} |
| 180 | + MAVEN_SIGNING_PASSPHRASE: ${{ secrets.MAVEN_SIGNING_PASSPHRASE }} |
| 181 | + MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} |
| 182 | + MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} |
| 183 | + run: TRAVIS_TAG=BB-SNAPSHOT ./gradlew ship |
0 commit comments