-
-
Notifications
You must be signed in to change notification settings - Fork 10
171 lines (154 loc) · 4.88 KB
/
automation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Android CI & CD
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
types: [opened, synchronize, reopened]
workflow_dispatch:
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Grant Permission to Execute
run: chmod +x gradlew
- name: Run lint
run: ./gradlew lintDebug
- name: Upload html test report
uses: actions/upload-artifact@v3.1.1
with:
name: lint.html
path: app/build/reports/lint-results-debug.html
unit-test:
name: Run Unit Tests
needs: [lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Cache gradle
- name: Cache Gradle and wrapper
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: cache-${{ runner.os }}-${{ matrix.jdk }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Run Unit tests
run: bash ./gradlew test --stacktrace
- name: Upload test report
uses: actions/upload-artifact@v3.1.1
with:
name: unit_test_report
path: app/build/reports/tests/testDebugUnitTest/
instrumentation-test:
needs: [unit-test]
runs-on: macos-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Grant Permission to Execute
run: chmod +x gradlew
- name: run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
script: ./gradlew connectedCheck
- name: generate report
uses: actions/upload-artifact@v3.1.1
with:
name: report
path: app/build/reports/coverage/debug
- name: Download Test Reports Folder
uses: actions/download-artifact@v3
with:
name: report
path: app/build/reports/coverage/debug
- name: Upload Test Report
uses: codecov/codecov-action@v3
with:
files: "app/build/reports/coverage/debug/report.xml"
static-code-analysis:
name: Build and analyze
needs: [unit-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Grant Permission to Execute
run: chmod +x gradlew
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build sonarqube --info
package:
name: Generate APK
needs: [static-code-analysis]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Java JDK
uses: actions/setup-java@v3.8.0
with:
java-version: 11
distribution: 'temurin'
- name: Grant Permission to Execute
run: chmod +x gradlew
- name: Build debug APK
run: bash ./gradlew assembleDebug --stacktrace
- name: Upload APK to Github Artifacts
uses: actions/upload-artifact@v3.1.1
with:
name: app
path: app/build/outputs/apk/debug/app-debug.apk
delevery-on-telegram:
name: Send Results on Telegram
needs: [ package ]
runs-on: ubuntu-latest
steps:
- name: Download Apk Stored Artifact
uses: actions/download-artifact@v3
with:
name: app
- name: send Apk on telegram message on push
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
Hi Guys,
${{ github.actor }} created commit:
Commit message: ${{ github.event.commits[0].message }}
Repository: ${{ github.repository }}
See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}}
Created By @JahidHasanCo
document: app-debug.apk