Skip to content

Commit d7067cb

Browse files
authored
Merge branch 'master' into #860-firebaseopensource
2 parents b6d2c84 + 2d7df89 commit d7067cb

14 files changed

Lines changed: 385 additions & 11 deletions

File tree

.github/workflows/release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ jobs:
3232
else
3333
echo "::set-env name=RELEASE_TAG::flank_snapshot";
3434
echo "::set-env name=MVN_VERSION::flank_snapshot";
35-
fi;
35+
fi;
36+
37+
- name: Store version variables to file
38+
run: |
3639
echo "$GITHUB_SHA" > ./test_runner/src/main/resources/revision.txt
3740
echo "$RELEASE_TAG" > ./test_runner/src/main/resources/version.txt
3841

flank-scripts/src/main/kotlin/flank/scripts/release/hub/DeleteOldRelease.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ class DeleteOldReleaseCommand : CliktCommand(name = "deleteOldRelease", help = "
1414
}
1515
}
1616

17-
fun deleteOldRelease(tag: String) = "$DELETE_RELEASE_COMMAND \"$tag\"".runCommand()
17+
fun deleteOldRelease(tag: String) = "$DELETE_RELEASE_COMMAND $tag".runCommand()
1818

1919
private const val DELETE_RELEASE_COMMAND = "hub release delete"

release_notes.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
## next (unreleased)
22
- [#978](https://github.com/Flank/flank/pull/978) Firebaseopensource.com addition ([sloox](https://github.com/Sloox))
3-
- [#952](https://github.com/Flank/flank/pull/952) Fix version printing on Flank release
3+
- [#937](https://github.com/Flank/flank/pull/968) Improve error message on iOS when test or xctestrun-file not found ([sloox](https://github.com/Sloox))
4+
- [#952](https://github.com/Flank/flank/pull/952) Fix version printing on Flank release ([sloox](https://github.com/Sloox))
45
- [#950](https://github.com/Flank/flank/pull/950) Fix crash when --legacy-junit-result set. ([adamfilipow92](https://github.com/adamfilipow92))
56
- [#948](https://github.com/Flank/flank/pull/948) Increment retry tries and change sync tag for jfrogSync. ([piotradamczyk5](https://github.com/piotradamczyk5))
67
- [#946](https://github.com/Flank/flank/pull/946) Added tests for flank scripts. ([piotradamczyk5](https://github.com/piotradamczyk5))
78
- [#935](https://github.com/Flank/flank/pull/935) Process junit xml even when full junit is not enabled. ([kozaxinan](https://github.com/kozaxinan))
89
- [#962](https://github.com/Flank/flank/pull/962) Make table text left aligned. ([pawelpasterz](https://github.com/pawelpasterz))
10+
- [#965](https://github.com/Flank/flank/pull/965) Fast fail when full-junit-result and legacy-junit-result. ([adamfilipow92](https://github.com/adamfilipow92))
11+
- [#970](https://github.com/Flank/flank/pull/970) Fixing Flood of snapshot releases. ([piotradamczyk5](https://github.com/piotradamczyk5))
12+
- [#972](https://github.com/Flank/flank/pull/972) Fix printing release version. ([piotradamczyk5](https://github.com/piotradamczyk5))
13+
- [#964](https://github.com/Flank/flank/pull/964) Implement network-profiles describe feature. ([pawelpasterz](https://github.com/pawelpasterz))
914
-
1015
-
1116

test_runner/src/main/kotlin/ftl/args/ValidateAndroidArgs.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ fun AndroidArgs.validate() {
1919
assertRoboTest()
2020
assertDirectoriesToPull()
2121
assertMaxTestShardsByDeviceType()
22+
assertParametersConflict()
2223
}
2324

2425
private fun AndroidArgs.assertAdditionalAppTestApks() {
@@ -99,3 +100,8 @@ private fun AndroidArgs.throwMaxTestShardsLimitExceeded(): Nothing {
99100
"max-test-shards must be >= ${IArgs.AVAILABLE_VIRTUAL_SHARD_COUNT_RANGE.first} and <= ${IArgs.AVAILABLE_VIRTUAL_SHARD_COUNT_RANGE.last} for virtual devices, for physical devices max-test-shards must be >= ${IArgs.AVAILABLE_PHYSICAL_SHARD_COUNT_RANGE.first} and <= ${IArgs.AVAILABLE_PHYSICAL_SHARD_COUNT_RANGE.last}, or -1. But current is $maxTestShards"
100101
)
101102
}
103+
104+
private fun AndroidArgs.assertParametersConflict() {
105+
if (useLegacyJUnitResult && fullJUnitResult)
106+
throw FlankConfigurationError("Parameters conflict, you cannot set: `--legacy-junit-result` and `--full-junit-result` at the same time.")
107+
}

test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import ftl.util.IncompatibleTestDimensionError
77
fun IosArgs.validate() {
88
assertXcodeSupported()
99
assertDevicesSupported()
10+
assertTestTypes()
1011
assertMaxTestShards()
1112
}
1213
private fun IosArgs.assertMaxTestShards() { this.maxTestShards
@@ -17,6 +18,10 @@ private fun IosArgs.assertMaxTestShards() { this.maxTestShards
1718
"max-test-shards must be >= ${IArgs.AVAILABLE_PHYSICAL_SHARD_COUNT_RANGE.first} and <= ${IArgs.AVAILABLE_PHYSICAL_SHARD_COUNT_RANGE.last}, or -1. But current is $maxTestShards"
1819
)
1920
}
21+
private fun IosArgs.assertTestTypes() {
22+
if (xctestrunFile.isBlank() or xctestrunZip.isBlank())
23+
throw FlankConfigurationError("Both of following options must be specified [test, xctestrun-file].")
24+
}
2025
private fun IosArgs.assertXcodeSupported() = when {
2126
xcodeVersion == null -> Unit
2227
IosCatalog.supportedXcode(xcodeVersion, project) -> Unit

test_runner/src/main/kotlin/ftl/cli/firebase/test/NetworkProfilesCommand.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package ftl.cli.firebase.test
22

3+
import ftl.cli.firebase.test.networkprofiles.NetworkProfilesDescribeCommand
34
import ftl.cli.firebase.test.networkprofiles.NetworkProfilesListCommand
45
import picocli.CommandLine
56

67
@CommandLine.Command(
78
name = "network-profiles",
89
synopsisHeading = "",
910
subcommands = [
10-
NetworkProfilesListCommand::class
11+
NetworkProfilesListCommand::class,
12+
NetworkProfilesDescribeCommand::class
1113
],
1214
usageHelpAutoWidth = true
1315
)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package ftl.cli.firebase.test.networkprofiles
2+
3+
import ftl.environment.networkProfileDescription
4+
import ftl.util.FlankConfigurationError
5+
import picocli.CommandLine
6+
7+
@CommandLine.Command(
8+
name = "describe",
9+
sortOptions = false,
10+
headerHeading = "",
11+
synopsisHeading = "%n",
12+
descriptionHeading = "%n@|bold,underline Description:|@%n%n",
13+
parameterListHeading = "%n@|bold,underline Parameters:|@%n",
14+
optionListHeading = "%n@|bold,underline Options:|@%n",
15+
header = ["Describe a network profile "],
16+
usageHelpAutoWidth = true
17+
)
18+
class NetworkProfilesDescribeCommand : Runnable {
19+
override fun run() {
20+
if (profileId.isBlank()) throw FlankConfigurationError("Argument PROFILE_ID must be specified.")
21+
println(networkProfileDescription(profileId))
22+
}
23+
24+
@CommandLine.Parameters(
25+
index = "0",
26+
arity = "1",
27+
paramLabel = "PROFILE_ID",
28+
defaultValue = "",
29+
description = ["The network profile to describe, found" +
30+
" using \$ gcloud beta firebase test network-profiles list."])
31+
var profileId: String = ""
32+
}

test_runner/src/main/kotlin/ftl/environment/NetworkConfigurationCatalog.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import ftl.environment.common.asPrintableTable
44
import ftl.gc.GcTesting
55
import ftl.http.executeWithRetry
66

7-
fun networkConfigurationAsTable() = networkConfiguration().asPrintableTable()
7+
fun networkConfigurationAsTable() = getNetworkConfiguration().asPrintableTable()
88

9-
private fun networkConfiguration() = GcTesting.get.testEnvironmentCatalog()
9+
fun getNetworkConfiguration() = GcTesting.get.testEnvironmentCatalog()
1010
.get("NETWORK_CONFIGURATION")
1111
.executeWithRetry()
1212
?.networkConfigurationCatalog
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package ftl.environment
2+
3+
import com.google.api.services.testing.model.NetworkConfiguration
4+
import com.google.api.services.testing.model.TrafficRule
5+
6+
fun networkProfileDescription(profile: String) = getNetworkConfiguration()
7+
.find { it.id?.toUpperCase() == profile.toUpperCase() }
8+
.toNullProof()
9+
.prepareDescription()
10+
?: "Unable to fetch profile [$profile] description"
11+
12+
private fun NetworkConfiguration?.toNullProof() = this?.run {
13+
NetworkConfigurationWrapper(
14+
downRule = wrappedOrEmpty(downRule),
15+
upRule = wrappedOrEmpty(upRule),
16+
id = id.toStringOrUnableToFetch()
17+
)
18+
}
19+
20+
private fun wrappedOrEmpty(rule: TrafficRule?) = rule?.let {
21+
Rule(
22+
bandwidth = it.bandwidth.toStringOrUnableToFetch(),
23+
delay = it.delay.toStringOrUnableToFetch(),
24+
packetLossRatio = it.packetLossRatio.toStringOrUnableToFetch()
25+
)
26+
} ?: emptyRule
27+
28+
private const val UNABLE = "[Unable to fetch]"
29+
30+
private fun Any?.toStringOrUnableToFetch() = this?.toString() ?: UNABLE
31+
32+
private val emptyRule: Rule
33+
get() = Rule(UNABLE, UNABLE, UNABLE)
34+
35+
private fun NetworkConfigurationWrapper?.prepareDescription() = this?.run {
36+
"""
37+
downRule:
38+
bandwidth: ${downRule.bandwidth}
39+
delay: ${downRule.delay}
40+
packetLossRatio: ${downRule.packetLossRatio}
41+
id: $id
42+
upRule:
43+
bandwidth: ${upRule.bandwidth}
44+
delay: ${upRule.delay}
45+
packetLossRatio: ${upRule.packetLossRatio}
46+
""".trimIndent()
47+
}
48+
49+
private data class NetworkConfigurationWrapper(val downRule: Rule, val upRule: Rule, val id: String)
50+
51+
private data class Rule(val bandwidth: String, val delay: String, val packetLossRatio: String)

test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,6 +1566,74 @@ AndroidArgs
15661566
val args = AndroidArgs.load(yaml)
15671567
assertEquals(AVAILABLE_PHYSICAL_SHARD_COUNT_RANGE.last, args.maxTestShards)
15681568
}
1569+
1570+
@Test(expected = FlankConfigurationError::class)
1571+
fun `should throw when --legacy-junit-result and --full-junit-result set`() {
1572+
val yaml = """
1573+
gcloud:
1574+
app: $appApk
1575+
test: $testApk
1576+
device:
1577+
- model: blueline
1578+
version: 28
1579+
locale: en
1580+
orientation: portrait
1581+
- model: Nexus6
1582+
version: 25
1583+
locale: en
1584+
orientation: portrait
1585+
flank:
1586+
max-test-shards: -1
1587+
full-junit-result: true
1588+
legacy-junit-result: true
1589+
""".trimIndent()
1590+
AndroidArgs.load(yaml)
1591+
}
1592+
@Test
1593+
fun `should not throw when --legacy-junit-result set and --full-junit-result not set`() {
1594+
val yaml = """
1595+
gcloud:
1596+
app: $appApk
1597+
test: $testApk
1598+
device:
1599+
- model: blueline
1600+
version: 28
1601+
locale: en
1602+
orientation: portrait
1603+
- model: Nexus6
1604+
version: 25
1605+
locale: en
1606+
orientation: portrait
1607+
flank:
1608+
max-test-shards: -1
1609+
full-junit-result: false
1610+
legacy-junit-result: true
1611+
""".trimIndent()
1612+
AndroidArgs.load(yaml)
1613+
}
1614+
1615+
@Test
1616+
fun `should not throw when --legacy-junit-result not set and --full-junit-result set`() {
1617+
val yaml = """
1618+
gcloud:
1619+
app: $appApk
1620+
test: $testApk
1621+
device:
1622+
- model: blueline
1623+
version: 28
1624+
locale: en
1625+
orientation: portrait
1626+
- model: Nexus6
1627+
version: 25
1628+
locale: en
1629+
orientation: portrait
1630+
flank:
1631+
max-test-shards: -1
1632+
full-junit-result: true
1633+
legacy-junit-result: false
1634+
""".trimIndent()
1635+
AndroidArgs.load(yaml)
1636+
}
15691637
}
15701638

15711639
private fun AndroidArgs.Companion.load(yamlData: String, cli: AndroidRunCommand? = null): AndroidArgs =

0 commit comments

Comments
 (0)