Skip to content

Commit c4bdf1c

Browse files
committed
Merge branch 'master' into version_update_20220623
2 parents 1a85117 + 7d64cde commit c4bdf1c

File tree

38 files changed

+1105
-210
lines changed

38 files changed

+1105
-210
lines changed

.github/workflows/build-src-check.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: build-src-check
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'buildSrc/**'
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
build-src-check:
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- uses: actions/[email protected]
17+
- name: Setup NDK
18+
run: |
19+
ANDROID_ROOT=/usr/local/lib/android
20+
ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk
21+
ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle
22+
ln -sfn $ANDROID_SDK_ROOT/ndk/21.4.7075529 $ANDROID_NDK_ROOT
23+
24+
- name: Set up JDK 11
25+
uses: actions/setup-java@v2
26+
with:
27+
java-version: 11
28+
distribution: temurin
29+
cache: gradle
30+
- name: buildSrc Tests
31+
env:
32+
FIREBASE_CI: 1
33+
run: |
34+
./gradlew -b buildSrc/build.gradle -PenablePluginTests=true check
35+
- name: Publish Test Results
36+
uses: EnricoMi/publish-unit-test-result-action@v1
37+
with:
38+
files: "**/build/test-results/**/*.xml"
39+
check_name: "buildSrc Test Results"
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
name: CI Tests (Experimental)
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
4+
cancel-in-progress: true
5+
on:
6+
pull_request:
7+
branches:
8+
- '*'
9+
push:
10+
branches:
11+
- master
12+
13+
jobs:
14+
determine_changed:
15+
name: "Determine changed modules"
16+
runs-on: ubuntu-22.04
17+
if: (github.repository == 'Firebase/firebase-android-sdk' && github.event_name == 'push') || github.event_name == 'pull_request'
18+
outputs:
19+
modules: ${{ steps.changed-modules.outputs.modules }}
20+
steps:
21+
- uses: actions/[email protected]
22+
with:
23+
fetch-depth: 2
24+
submodules: true
25+
- name: Setup NDK
26+
run: |
27+
ANDROID_ROOT=/usr/local/lib/android
28+
ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk
29+
ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle
30+
ln -sfn $ANDROID_SDK_ROOT/ndk/21.4.7075529 $ANDROID_NDK_ROOT
31+
32+
- name: Set up JDK 11
33+
uses: actions/setup-java@v2
34+
with:
35+
java-version: 11
36+
distribution: temurin
37+
cache: gradle
38+
39+
- id: changed-modules
40+
run: |
41+
git diff --name-only HEAD~1 | xargs printf -- '--changed-git-paths %s\n' | xargs ./gradlew writeChangedProjects --output-file-path=modules.json
42+
echo ::set-output name=modules::$(cat modules.json)
43+
44+
unit_tests:
45+
name: "Unit Tests"
46+
runs-on: ubuntu-22.04
47+
needs:
48+
- determine_changed
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
module: ${{ fromJSON(needs.determine_changed.outputs.modules) }}
53+
54+
steps:
55+
- uses: actions/[email protected]
56+
with:
57+
fetch-depth: 2
58+
submodules: true
59+
- name: Setup NDK
60+
run: |
61+
ANDROID_ROOT=/usr/local/lib/android
62+
ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk
63+
ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle
64+
ln -sfn $ANDROID_SDK_ROOT/ndk/21.4.7075529 $ANDROID_NDK_ROOT
65+
66+
- name: Set up JDK 11
67+
uses: actions/setup-java@v2
68+
with:
69+
java-version: 11
70+
distribution: temurin
71+
cache: gradle
72+
73+
- name: ${{ matrix.module }} Unit Tests
74+
env:
75+
FIREBASE_CI: 1
76+
run: |
77+
./gradlew ${{matrix.module}}:check withErrorProne
78+
- name: Upload Test Results
79+
uses: actions/upload-artifact@v3
80+
if: always()
81+
with:
82+
name: Unit Test Results
83+
path: "**/build/test-results/**/*.xml"
84+
85+
# A job that fails if any job in the unit_tests matrix fails,
86+
# to be used as a required check for merging.
87+
check_all:
88+
runs-on: ubuntu-22.04
89+
if: always()
90+
name: Unit Tests (matrix)
91+
needs: unit_tests
92+
steps:
93+
- name: Check test matrix
94+
if: needs.unit_tests.result != 'success'
95+
run: exit 1
96+
97+
98+
integ_tests:
99+
name: "Instrumentation Tests"
100+
# only run on post submit or PRs not originating from forks.
101+
if: (github.repository == 'Firebase/firebase-android-sdk' && github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
102+
runs-on: ubuntu-22.04
103+
needs:
104+
- determine_changed
105+
strategy:
106+
fail-fast: false
107+
matrix:
108+
module: ${{ fromJSON(needs.determine_changed.outputs.modules) }}
109+
110+
steps:
111+
- uses: actions/[email protected]
112+
with:
113+
fetch-depth: 2
114+
submodules: true
115+
- name: Setup NDK
116+
run: |
117+
ANDROID_ROOT=/usr/local/lib/android
118+
ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk
119+
ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle
120+
ln -sfn $ANDROID_SDK_ROOT/ndk/21.4.7075529 $ANDROID_NDK_ROOT
121+
122+
- name: Set up JDK 11
123+
uses: actions/setup-java@v2
124+
with:
125+
java-version: 11
126+
distribution: temurin
127+
cache: gradle
128+
129+
- name: Add google-services.json
130+
env:
131+
INTEG_TESTS_GOOGLE_SERVICES: ${{ secrets.INTEG_TESTS_GOOGLE_SERVICES }}
132+
run: |
133+
echo $INTEG_TESTS_GOOGLE_SERVICES | base64 -d > google-services.json
134+
- uses: google-github-actions/auth@v0
135+
with:
136+
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }}
137+
- uses: google-github-actions/setup-gcloud@v0
138+
- name: ${{ matrix.module }} Integ Tests
139+
env:
140+
FIREBASE_CI: 1
141+
FTL_RESULTS_BUCKET: android-ci
142+
FTL_RESULTS_DIR: ${{ github.event_name == 'pull_request' && format('pr-logs/pull/{0}/{1}/{2}/{3}_{4}/artifacts/', github.repository, github.event.pull_request.number, github.job, github.run_id, github.run_attempt) || format('logs/{0}/{1}_{2}/artifacts/', github.workflow, github.run_id, github.run_attempt)}}
143+
FIREBASE_APP_CHECK_DEBUG_SECRET: ${{ secrets.FIREBASE_APP_CHECK_DEBUG_SECRET }}
144+
run: |
145+
./gradlew ${{matrix.module}}:deviceCheck withErrorProne -PuseProdBackendForTests=true
146+
147+
publish-test-results:
148+
name: "Publish Tests Results"
149+
needs:
150+
- unit_tests
151+
runs-on: ubuntu-22.04
152+
153+
permissions:
154+
checks: write
155+
156+
# only needed unless run with comment_mode: off
157+
pull-requests: write
158+
159+
if: always()
160+
161+
steps:
162+
- name: Download Artifacts
163+
uses: actions/download-artifact@v3
164+
with:
165+
path: artifacts
166+
167+
- name: Publish Test Results
168+
uses: EnricoMi/publish-unit-test-result-action@v1
169+
with:
170+
files: "artifacts/**/*.xml"

.github/workflows/copyright-check.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Copyright check
2+
3+
on: pull_request
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
copyright-check:
11+
runs-on: ubuntu-22.04
12+
steps:
13+
- uses: actions/[email protected]
14+
- uses: actions/setup-python@v2
15+
with:
16+
python-version: '3.9'
17+
- run: |
18+
pip install -e "ci/fireci"
19+
- run: |
20+
fireci copyright_check \
21+
-e py \
22+
-e gradle \
23+
-e java \
24+
-e groovy \
25+
-e sh \
26+
-e proto

.github/workflows/fireci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: fireci
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'ci/**'
7+
- '.github/workflows/fireci.yml'
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
fireci:
15+
name: "fireci tests"
16+
runs-on: ubuntu-22.04
17+
steps:
18+
- uses: actions/[email protected]
19+
- uses: actions/setup-python@v2
20+
with:
21+
python-version: '3.9'
22+
- run: |
23+
pip install -e "ci/fireci[test]"
24+
- run: |
25+
pytest ci/fireci

buildSrc/src/main/java/com/google/firebase/gradle/plugins/ci/AffectedProjectFinder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public AffectedProjectFinder(Project project, List<Pattern> ignorePaths) {
3939
this(project, changedPaths(project.getRootDir()), ignorePaths);
4040
}
4141

42-
private AffectedProjectFinder(
42+
public AffectedProjectFinder(
4343
Project project, Set<String> changedPaths, List<Pattern> ignorePaths) {
4444
this.project = project;
4545
this.changedPaths =
@@ -68,6 +68,7 @@ Set<Project> find() {
6868

6969
private static Set<String> changedPaths(File workDir) {
7070
try {
71+
// works on Prow only.
7172
Process process =
7273
Runtime.getRuntime()
7374
.exec("git diff --name-only --submodule=diff HEAD@{0} HEAD@{1}", null, workDir);
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.google.firebase.gradle.plugins.ci
2+
3+
import com.google.gson.Gson
4+
import java.io.File
5+
import org.gradle.api.DefaultTask
6+
import org.gradle.api.artifacts.ProjectDependency
7+
import org.gradle.api.tasks.Input
8+
import org.gradle.api.tasks.OutputFile
9+
import org.gradle.api.tasks.TaskAction
10+
import org.gradle.api.tasks.options.Option
11+
12+
abstract class ChangedModulesTask : DefaultTask() {
13+
@get:Input
14+
@set:Option(option = "changed-git-paths", description = "Hellos")
15+
abstract var changedGitPaths: List<String>
16+
17+
@get:Input
18+
@set:Option(option = "output-file-path", description = "Hello")
19+
abstract var outputFilePath: String
20+
21+
@get:OutputFile
22+
val outputFile by lazy {
23+
File(outputFilePath)
24+
}
25+
26+
init {
27+
outputs.upToDateWhen { false }
28+
}
29+
30+
@TaskAction
31+
fun execute() {
32+
val projects =
33+
AffectedProjectFinder(project, changedGitPaths.toSet(), listOf()).find().map { it.path }
34+
.toSet()
35+
36+
val result = mutableMapOf<String, MutableSet<String>>()
37+
project.rootProject.subprojects.forEach { p ->
38+
p.configurations.forEach { c ->
39+
c.dependencies.filterIsInstance<ProjectDependency>().forEach {
40+
result.getOrPut(it.dependencyProject.path) { mutableSetOf() }.add(p.path)
41+
}
42+
}
43+
}
44+
val affectedProjects =
45+
result.flatMap { (key, value) ->
46+
if (projects.contains(key)) setOf(key) + value else setOf()
47+
}.toSet()
48+
49+
outputFile.writeText(Gson().toJson(affectedProjects))
50+
}
51+
}

buildSrc/src/main/java/com/google/firebase/gradle/plugins/ci/ContinuousIntegrationPlugin.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ public void apply(Project project) {
103103
setupChangedTask(project, affectedProjects, "check");
104104
setupChangedTask(project, affectedProjects, "checkCoverage");
105105
setupChangedTask(project, affectedProjects, "deviceCheck");
106+
107+
project.getTasks().register("writeChangedProjects", ChangedModulesTask.class);
106108
}
107109

108110
private static void setupChangedTask(

ci/fireci/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools ~= 58.0"]
3+
build-backend = "setuptools.build_meta"

ci/fireci/setup.cfg

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[metadata]
2+
name = fireci
3+
version = 0.1
4+
5+
[options]
6+
install_requires =
7+
protobuf==3.19
8+
click==7.0
9+
google-cloud-storage==1.44.0
10+
numpy==1.19.5
11+
PyGithub==1.55
12+
pystache==0.6.0
13+
requests==2.23.0
14+
PyYAML==6.0.0
15+
16+
[options.extras_require]
17+
test =
18+
pytest
19+
20+
[options.entry_points]
21+
console_scripts =
22+
fireci = fireci.main:cli

0 commit comments

Comments
 (0)