-
Notifications
You must be signed in to change notification settings - Fork 1
186 lines (156 loc) · 5.57 KB
/
main.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# This is a basic workflow to help you get started with Actions
name: Android-CI-CD
# Controls when the workflow will run (the event that triggers the workflow)
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
# Specify one or more jobs to run for the workflow
jobs:
# This workflow contains a single job called "build"
# Pick up the job name
lint:
# The type of runner that the job will run on
# to run the job on latest ubuntu machine. (the machine each job should run (e.g. ubuntu-latest))
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
# Determine a sequence of tasks will be executed for each job
steps:
- name: Checkout the code
uses: actions/checkout@v3 # It is an official GitHub Action used to check-out a repository so a workflow can access it.
# Just a message
- name: Run lint
run: echo lint
# (run) One of step parameters, and use it to execute or hitting a command
- name: Run lint
run: ./gradlew lintDebug
# (uses) it is a step parameters, and use it to install environment or a repo from any marketplace
# Publish the lint report as a github artifact
- name: Upload html test report
uses: actions/upload-artifact@v3
with:
name: lint.html
path: app/build/reports/lint-results-debug.html
unit-test:
# (needs) to make the current job wait another one (sequential principle)
needs: [ lint ]
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Run unit-test
run: echo unit-test
# (./gradlew test) to run the unit tests
- name: Run tests
run: ./gradlew test
# upload test report
- name: Upload test report
uses: actions/upload-artifact@v3
with:
name: unit_test_report
path: app/build/reports/tests/testDebugUnitTest/
instrumentation-test:
needs: [ unit-test ]
# we are running this job on mac-latest machine. That is because the modern Intel Atom (x86 and x86_64) emulators
# require hardware acceleration from the host to run fast.
runs-on: macos-latest
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Run espresso tests
run: echo espresso tests
# set up java jdk
- name: set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
#start the android emulator using
- name: Run espresso tests
uses: reactivecircus/android-emulator-runner@v2
with:
# specify api level, and 29 is recommended because the upper leads to some issues
api-level: 29
#running the instrumentation tests using
script: ./gradlew connectedCheck
# upload instrumentation test report
- name: Upload instrumentation test report
uses: actions/upload-artifact@v3
with:
name: instrumentation_test_report
path: app/build/reports/androidTests/connected/
static-code-analysis:
needs: [instrumentation-test]
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Run static code analysis
run: echo static code analysis
- name: set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
# report to SonarCloud platform
- name: SonarCloud Scan
run: ./gradlew app:sonarqube -Dsonar.login=${{ secrets.SONAR_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
package:
needs: [ static-code-analysis ]
name: Generate APK
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build debug APK
run: ./gradlew assembleDebug
# generate and upload an APK to GitHupAction
- name: Upload APK
uses: actions/upload-artifact@v2
with:
name: app-debug.apk
path: app/build/outputs/apk/debug/app-debug.apk
# This is important for mac os
build-ios:
needs: [ package ]
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Java JDK
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build Gradle
run: ./gradlew build
distribute-ios:
# This is important for mac os
needs: build-ios
name: Upload apk to QA team
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: build release
run: bash ./gradlew assembleDebug
# create apk for QA team
- name: Upload Artifact To Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: ${{ secrets.FIREBASE_APP_ID }}
token: ${{ secrets.FIREBASE_TOKEN }}
groups: QA
releaseNotes: "Hello QA team!! kindly try the first integration Firebase Distributions with Github Actions."
file: app/build/outputs/apk/debug/app-debug.apk