Skip to content

Commit 08843b0

Browse files
author
Piotr Adamczyk
committed
Merge remote-tracking branch 'origin/master' into #814-auto-generating-release-notes
# Conflicts: # release_notes.md
2 parents 901afe8 + 0fc8aaa commit 08843b0

15 files changed

Lines changed: 354 additions & 9 deletions

File tree

.github/workflows/pr_checks.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: "Check Pull Request"
2+
on:
3+
pull_request:
4+
branches: master
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
jobs:
11+
check_title:
12+
runs-on: macos-latest
13+
steps:
14+
- uses: amannn/action-semantic-pull-request@v1.2.0
15+
if: github.event.pull_request.draft == false
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docs/pr_titles.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# PR title using [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/)
2+
3+
## Introduction
4+
The Conventional Commits specification is a lightweight convention on top of commit messages.
5+
It provides an easy set of rules for creating an explicit commit history; which makes it easier to write automated
6+
tools on top of.
7+
8+
## Usage
9+
Every PR which is not in draft mode should follow conventional commit convention for PR title.
10+
It allows us to generate release notes and avoid merge conflicts in [release_notes.md file](../../release_notes.md)
11+
12+
### PR title
13+
Pull request title should be: `<type>([optional scope]): <description>`
14+
15+
where
16+
`<type>` - [one of following](###Type)
17+
`[optional scope]` - additional information
18+
`<description>` - description of pr
19+
20+
### Type
21+
22+
- `build` - Changes that affect the build system or external dependencies (dependencies update)
23+
- `ci` - Changes to our CI configuration files and scripts (basically directory `.github/workflows`)
24+
- `docs` - Documentation only changes
25+
- `feat` - A new feature
26+
- `fix` - A bug fix
27+
- `chore` - Changes which does not touch the code (ex. manual update of release notes). It will not generate release notes
28+
changes
29+
- `refactor` - A code change that contains refactor
30+
- `style` - Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
31+
- `test` - Adding missing tests or correcting existing tests and also changes for our test app
32+
- `perf` - A code change that improves performance (I do not think we will use it)
33+
34+
### Examples
35+
36+
- `feat: Add locales description command for ios and android` -> https://github.com/Flank/flank/pull/969
37+
- `fix: rate limit exceeded ` -> https://github.com/Flank/flank/pull/919
38+
- `ci: Added leading V to version name ` -> https://github.com/Flank/flank/pull/980
39+
- `refactor: config entities and arguments` -> https://github.com/Flank/flank/pull/831
40+
- `docs: Add secrets and vision doc` -> https://github.com/Flank/flank/pull/922
41+
- `build: Disable Auto Doc Generation` -> https://github.com/Flank/flank/pull/942
42+
- `test: added multi modules to test app` -> https://github.com/Flank/flank/pull/857
43+
- `chore: Release v20.08.1` -> https://github.com/Flank/flank/pull/982

test_runner/src/main/kotlin/ftl/android/AndroidCatalog.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import ftl.environment.android.asPrintableTable
66
import ftl.environment.android.getDescription
77
import ftl.environment.asPrintableTable
88
import ftl.environment.common.asPrintableTable
9+
import ftl.environment.getLocaleDescription
910
import ftl.gc.GcTesting
1011
import ftl.http.executeWithRetry
1112

@@ -36,7 +37,11 @@ object AndroidCatalog {
3637

3738
fun supportedOrientationsAsTable(projectId: String) = deviceCatalog(projectId).runtimeConfiguration.orientations.asPrintableTable()
3839

39-
fun localesAsTable(projectId: String) = deviceCatalog(projectId).runtimeConfiguration.locales.asPrintableTable()
40+
fun localesAsTable(projectId: String) = getLocales(projectId).asPrintableTable()
41+
42+
fun getLocaleDescription(projectId: String, locale: String) = getLocales(projectId).getLocaleDescription(locale)
43+
44+
private fun getLocales(projectId: String) = deviceCatalog(projectId).runtimeConfiguration.locales
4045

4146
fun androidModelIds(projectId: String) =
4247
modelMap.getOrPut(projectId) { deviceCatalog(projectId).models.map { it.id } }

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
package ftl.args
22

3+
import ftl.config.Device
34
import ftl.config.FtlConstants
45
import ftl.util.FlankConfigurationError
6+
import ftl.util.FlankGeneralError
57

68
fun CommonArgs.validate() {
79
assertProjectId()
810
assertShardTime()
911
assertRepeatTests()
1012
assertSmartFlankGcsPath()
13+
assertOrientationCorrectness()
1114
}
1215

16+
private fun List<Device>.devicesWithMispeltOrientations(availableOrientations: List<String>) =
17+
filter { it.orientation !in availableOrientations }
18+
19+
private fun CommonArgs.assertOrientationCorrectness() =
20+
devices.devicesWithMispeltOrientations(listOf("portrait", "landscape", "default")).throwIfAnyMisspelt()
21+
22+
private fun List<Device>.throwIfAnyMisspelt() =
23+
if (isNotEmpty()) throw FlankGeneralError("Orientation misspelled or incorrect, found\n${joinToString(separator = "\n")} \nAborting.")
24+
else Unit
25+
1326
private fun CommonArgs.assertProjectId() {
1427
if (project.isEmpty()) throw FlankConfigurationError(
1528
"The project is not set. Define GOOGLE_CLOUD_PROJECT, set project in flank.yml\n" +

test_runner/src/main/kotlin/ftl/cli/firebase/test/android/configuration/AndroidLocalesCommand.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import picocli.CommandLine
1111
optionListHeading = "%n@|bold,underline Options:|@%n",
1212
header = ["Information about available locales on device"],
1313
description = ["Information about available locales on device. For example prints list of available locales to test against"],
14-
subcommands = [AndroidLocalesListCommand::class],
14+
subcommands = [AndroidLocalesListCommand::class, AndroidLocalesDescribeCommand::class],
1515
usageHelpAutoWidth = true
1616
)
1717
class AndroidLocalesCommand : Runnable {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package ftl.cli.firebase.test.android.configuration
2+
3+
import ftl.android.AndroidCatalog.getLocaleDescription
4+
import ftl.args.AndroidArgs
5+
import ftl.config.FtlConstants
6+
import ftl.util.FlankConfigurationError
7+
import picocli.CommandLine
8+
import java.nio.file.Paths
9+
10+
@CommandLine.Command(
11+
name = "describe",
12+
headerHeading = "",
13+
synopsisHeading = "%n",
14+
descriptionHeading = "%n@|bold,underline Description:|@%n%n",
15+
parameterListHeading = "%n@|bold,underline Parameters:|@%n",
16+
optionListHeading = "%n@|bold,underline Options:|@%n",
17+
header = ["Describe a locales "],
18+
usageHelpAutoWidth = true
19+
)
20+
class AndroidLocalesDescribeCommand : Runnable {
21+
override fun run() {
22+
if (locale.isBlank()) throw FlankConfigurationError("Argument LOCALE must be specified.")
23+
print(getLocaleDescription(AndroidArgs.loadOrDefault(Paths.get(configPath)).project, locale))
24+
}
25+
26+
@CommandLine.Parameters(
27+
index = "0",
28+
arity = "1",
29+
paramLabel = "LOCALE",
30+
defaultValue = "",
31+
description = ["The locale to describe, found" +
32+
" using \$ gcloud firebase test android locales list\n."]
33+
)
34+
var locale: String = ""
35+
36+
@CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"])
37+
var configPath: String = FtlConstants.defaultAndroidConfig
38+
}

test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/configuration/IosLocalesCommand.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import picocli.CommandLine
1111
optionListHeading = "%n@|bold,underline Options:|@%n",
1212
header = ["Information about available locales on device"],
1313
description = ["Information about available locales on device. For example prints list of available locales to test against"],
14-
subcommands = [IosLocalesListCommand::class],
14+
subcommands = [IosLocalesListCommand::class, IosLocalesDescribeCommand::class],
1515
usageHelpAutoWidth = true
1616
)
1717
class IosLocalesCommand : Runnable {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package ftl.cli.firebase.test.ios.configuration
2+
3+
import ftl.args.IosArgs
4+
import ftl.config.FtlConstants
5+
import ftl.ios.IosCatalog.getLocaleDescription
6+
import ftl.util.FlankConfigurationError
7+
import picocli.CommandLine
8+
import java.nio.file.Paths
9+
10+
@CommandLine.Command(
11+
name = "describe",
12+
headerHeading = "",
13+
synopsisHeading = "%n",
14+
descriptionHeading = "%n@|bold,underline Description:|@%n%n",
15+
parameterListHeading = "%n@|bold,underline Parameters:|@%n",
16+
optionListHeading = "%n@|bold,underline Options:|@%n",
17+
header = ["Describe a locales "],
18+
usageHelpAutoWidth = true
19+
)
20+
class IosLocalesDescribeCommand : Runnable {
21+
override fun run() {
22+
if (locale.isBlank()) throw FlankConfigurationError("Argument LOCALE must be specified.")
23+
print(getLocaleDescription(IosArgs.loadOrDefault(Paths.get(configPath)).project, locale))
24+
}
25+
26+
@CommandLine.Parameters(
27+
index = "0",
28+
arity = "1",
29+
paramLabel = "LOCALE",
30+
defaultValue = "",
31+
description = ["The locale to describe, found" +
32+
" using \$ gcloud firebase test ios locales list\n."]
33+
)
34+
var locale: String = ""
35+
36+
@CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"])
37+
var configPath: String = FtlConstants.defaultIosConfig
38+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package ftl.environment
2+
3+
import com.google.api.services.testing.model.Locale
4+
import ftl.util.FlankGeneralError
5+
6+
fun List<Locale>.getLocaleDescription(localeId: String) = findLocales(localeId)?.prepareDescription().orErrorMessage(localeId).plus("\n")
7+
8+
private fun List<Locale>.findLocales(localeId: String) = find { it.id == localeId }
9+
10+
private fun Locale.prepareDescription() = """
11+
id: $id
12+
name: $name
13+
""".trimIndent().addRegionIfExist(region).addTagsIfExists(this)
14+
15+
private fun String.addRegionIfExist(region: String?) =
16+
if (!region.isNullOrEmpty()) StringBuilder(this).appendln("\nregion: $region").trim().toString()
17+
else this
18+
19+
private fun String.addTagsIfExists(locale: Locale) =
20+
if (!locale.tags.isNullOrEmpty()) StringBuilder(this).appendln("\ntags:").appendTagsToList(locale)
21+
else this
22+
23+
private fun StringBuilder.appendTagsToList(locale: Locale) = apply {
24+
locale.tags.filterNotNull().forEach { tag -> appendln("- $tag") }
25+
}.trim().toString()
26+
27+
private fun String?.orErrorMessage(locale: String) = this ?: throw FlankGeneralError("ERROR: '$locale' is not a valid locale")

test_runner/src/main/kotlin/ftl/ios/IosCatalog.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package ftl.ios
22

33
import com.google.api.services.testing.model.IosDeviceCatalog
4-
import ftl.environment.android.asPrintableTable
54
import ftl.environment.asPrintableTable
65
import ftl.environment.common.asPrintableTable
76
import ftl.environment.ios.asPrintableTable
87
import ftl.environment.ios.getDescription
8+
import ftl.environment.getLocaleDescription
99
import ftl.gc.GcTesting
1010
import ftl.http.executeWithRetry
1111

@@ -28,6 +28,10 @@ object IosCatalog {
2828

2929
fun localesAsTable(projectId: String) = iosDeviceCatalog(projectId).runtimeConfiguration.locales.asPrintableTable()
3030

31+
fun getLocaleDescription(projectId: String, locale: String) = getLocales(projectId).getLocaleDescription(locale)
32+
33+
private fun getLocales(projectId: String) = iosDeviceCatalog(projectId).runtimeConfiguration.locales
34+
3135
fun supportedOrientationsAsTable(projectId: String) = iosDeviceCatalog(projectId).runtimeConfiguration.orientations.asPrintableTable()
3236

3337
fun supportedXcode(version: String, projectId: String) = xcodeVersions(projectId).contains(version)

0 commit comments

Comments
 (0)