|
7 | 7 | branches: [ main ] |
8 | 8 | workflow_dispatch: |
9 | 9 |
|
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
10 | 14 | jobs: |
11 | | - cancel_previous: |
| 15 | + test: |
| 16 | + name: ${{ matrix.name }} |
| 17 | + runs-on: ${{ github.event.pull_request.head.repo.fork && 'ubuntu-latest' || 'ubuntu-x64' }} |
| 18 | + environment: test_docker |
| 19 | + permissions: |
| 20 | + id-token: write |
| 21 | + contents: read |
| 22 | + timeout-minutes: 30 |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + include: |
| 27 | + - name: core-test |
| 28 | + module: core |
| 29 | + - name: android-test |
| 30 | + module: android |
| 31 | + - name: destination-test |
| 32 | + module: samples:kotlin-android-app-destinations |
12 | 33 |
|
13 | | - runs-on: ubuntu-22.04 |
14 | 34 | steps: |
15 | | - - uses: styfle/cancel-workflow-action@0.9.1 |
16 | | - with: |
17 | | - workflow_id: ${{ github.event.workflow.id }} |
18 | | - |
19 | | - core-test: |
20 | | - needs: cancel_previous |
21 | | - runs-on: ubuntu-22.04 |
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 |
22 | 37 |
|
23 | | - steps: |
24 | | - - uses: actions/checkout@v4 |
25 | | - - name: Set up JDK 11 |
26 | | - uses: actions/setup-java@v4 |
27 | | - with: |
28 | | - distribution: 'temurin' |
29 | | - java-version: '11' |
30 | | - |
31 | | - - name: Grant execute permission for gradlew |
32 | | - run: chmod +x gradlew |
33 | | - - name: cache gradle dependencies |
34 | | - uses: actions/cache@v3 |
35 | | - with: |
36 | | - path: | |
37 | | - ~/.gradle/caches |
38 | | - ~/.gradle/wrapper |
39 | | - key: ${{ runner.os }}-gradle-core-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
40 | | - restore-keys: | |
41 | | - ${{ runner.os }}-gradle-core- |
42 | | - - name: Run Tests |
43 | | - run: ./gradlew core:test |
44 | | - - name: Generate coverage report |
45 | | - run: ./gradlew core:codeCoverageReport |
46 | | - - name: Upload coverage to Codecov |
47 | | - uses: codecov/codecov-action@v2 |
48 | | - |
49 | | - android-test: |
50 | | - needs: cancel_previous |
51 | | - runs-on: ubuntu-22.04 |
| 38 | + - name: Set up Java |
| 39 | + uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1 |
| 40 | + with: |
| 41 | + distribution: "temurin" |
| 42 | + java-version: "17" |
52 | 43 |
|
53 | | - steps: |
54 | | - - uses: actions/checkout@v2 |
55 | | - - name: Grant execute permission for gradlew |
56 | | - run: chmod +x gradlew |
57 | | - - name: cache gradle dependencies |
58 | | - uses: actions/cache@v3 |
| 44 | + # Only cache if it's a fork |
| 45 | + - name: Cache Gradle dependencies |
| 46 | + if: ${{ github.event.pull_request.head.repo.fork }} |
| 47 | + uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0 |
59 | 48 | with: |
60 | 49 | path: | |
61 | 50 | ~/.gradle/caches |
62 | 51 | ~/.gradle/wrapper |
63 | | - key: ${{ runner.os }}-gradle-android-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
| 52 | + key: ${{ runner.os }}-gradle-${{ matrix.name }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
64 | 53 | restore-keys: | |
65 | | - ${{ runner.os }}-gradle-android- |
| 54 | + ${{ runner.os }}-gradle-${{ matrix.name }}- |
| 55 | +
|
| 56 | + - name: Artifactory OIDC |
| 57 | + if: ${{ !github.event.pull_request.head.repo.fork }} |
| 58 | + uses: twilio/sdk-actions/artifactory-oidc@0d27cae699ef35881ab22fd965922d3d555cab9d # java_gradle |
| 59 | + with: |
| 60 | + ecosystem: "gradle" |
| 61 | + provider-name: "github-actions-segmentio" |
| 62 | + |
66 | 63 | - name: Run Tests |
67 | | - run: ./gradlew android:test |
68 | | - - name: Generate coverage report |
69 | | - run: ./gradlew android:codeCoverageReport |
70 | | - - name: Upload coverage to Codecov |
71 | | - uses: codecov/codecov-action@v2 |
| 64 | + run: ./gradlew ${{ matrix.module }}:test |
72 | 65 |
|
73 | | - destination-test: |
74 | | - needs: cancel_previous |
75 | | - runs-on: ubuntu-22.04 |
| 66 | + build: |
| 67 | + name: Build |
| 68 | + runs-on: ${{ github.event.pull_request.head.repo.fork && 'ubuntu-latest' || 'ubuntu-x64' }} |
| 69 | + environment: test_docker |
| 70 | + permissions: |
| 71 | + id-token: write |
| 72 | + contents: read |
| 73 | + timeout-minutes: 20 |
76 | 74 |
|
77 | 75 | steps: |
78 | | - - uses: actions/checkout@v2 |
79 | | - - name: Grant execute permission for gradlew |
80 | | - run: chmod +x gradlew |
81 | | - - name: cache gradle dependencies |
82 | | - uses: actions/cache@v3 |
| 76 | + - name: Checkout |
| 77 | + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 |
| 78 | + |
| 79 | + - name: Set up Java |
| 80 | + uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1 |
| 81 | + with: |
| 82 | + distribution: "temurin" |
| 83 | + java-version: "17" |
| 84 | + |
| 85 | + # Only cache if it's a fork |
| 86 | + - name: Cache Gradle dependencies |
| 87 | + if: ${{ github.event.pull_request.head.repo.fork }} |
| 88 | + uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.5.0 |
83 | 89 | with: |
84 | 90 | path: | |
85 | 91 | ~/.gradle/caches |
86 | 92 | ~/.gradle/wrapper |
87 | | - key: ${{ runner.os }}-gradle-dest-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
| 93 | + key: ${{ runner.os }}-gradle-build-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
88 | 94 | restore-keys: | |
89 | | - ${{ runner.os }}-gradle-dest- |
90 | | - - name: Run Tests |
91 | | - run: ./gradlew samples:kotlin-android-app-destinations:test |
92 | | - - name: Generate coverage report |
93 | | - run: ./gradlew samples:kotlin-android-app-destinations:codeCoverageReport |
94 | | - - name: Upload coverage to Codecov |
95 | | - uses: codecov/codecov-action@v2 |
| 95 | + ${{ runner.os }}-gradle-build- |
| 96 | +
|
| 97 | + - name: Artifactory OIDC |
| 98 | + if: ${{ !github.event.pull_request.head.repo.fork }} |
| 99 | + uses: twilio/sdk-actions/artifactory-oidc@0d27cae699ef35881ab22fd965922d3d555cab9d # java_gradle |
| 100 | + with: |
| 101 | + ecosystem: "gradle" |
| 102 | + provider-name: "github-actions-segmentio" |
| 103 | + |
| 104 | + - name: Build |
| 105 | + run: ./gradlew assemble |
96 | 106 |
|
97 | 107 | security: |
98 | | - needs: cancel_previous |
99 | | - runs-on: ubuntu-22.04 |
| 108 | + runs-on: ${{ github.event.pull_request.head.repo.fork && 'ubuntu-latest' || 'ubuntu-x64' }} |
| 109 | + environment: test_docker |
| 110 | + permissions: |
| 111 | + id-token: write |
| 112 | + contents: read |
| 113 | + timeout-minutes: 20 |
100 | 114 |
|
101 | 115 | steps: |
102 | | - - uses: actions/checkout@v2 |
103 | | - - name: Grant execute permission for gradlew |
104 | | - run: chmod +x gradlew |
| 116 | + - name: Checkout |
| 117 | + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 |
| 118 | + |
| 119 | + - name: Set up Java |
| 120 | + uses: actions/setup-java@cf277c60eb25467037889841efdb72551f06f6c3 # v4.9.1 |
| 121 | + with: |
| 122 | + distribution: "temurin" |
| 123 | + java-version: "17" |
| 124 | + |
| 125 | + - name: Artifactory OIDC |
| 126 | + if: ${{ !github.event.pull_request.head.repo.fork }} |
| 127 | + uses: twilio/sdk-actions/artifactory-oidc@0d27cae699ef35881ab22fd965922d3d555cab9d # java_gradle |
| 128 | + with: |
| 129 | + ecosystem: "gradle" |
| 130 | + provider-name: "github-actions-segmentio" |
| 131 | + |
105 | 132 | - name: Snyk |
106 | 133 | run: ./gradlew snyk-test |
107 | 134 | env: |
|
0 commit comments