From 79d26e1bcfa01a0443fdff850b58d9083a386d57 Mon Sep 17 00:00:00 2001 From: piotradamczyk5 <65554637+piotradamczyk5@users.noreply.github.com> Date: Wed, 27 Jan 2021 11:17:20 +0100 Subject: [PATCH] ci: Added Windows workflow (#1534) --- .github/workflows/windows_workflow.yml | 32 ++++++++++++++++ common/src/main/kotlin/flank/common/Files.kt | 4 ++ .../ios/xctest/common/InstallParseBinaries.kt | 6 +-- .../ftl/analytics/UsageStatisticsTest.kt | 37 +++++++++++-------- .../src/test/kotlin/ftl/args/IosArgsTest.kt | 9 +++++ .../xctest/common/InstallParseBinariesTest.kt | 6 +-- .../ios/xctest/common/ParseObjTestsKtTest.kt | 2 + .../xctest/common/ParseSwiftTestsKtTest.kt | 4 ++ 8 files changed, 78 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/windows_workflow.yml diff --git a/.github/workflows/windows_workflow.yml b/.github/workflows/windows_workflow.yml new file mode 100644 index 0000000000..8991924012 --- /dev/null +++ b/.github/workflows/windows_workflow.yml @@ -0,0 +1,32 @@ +name: windows-workflow + +on: + pull_request: + branches: + - '*' + +jobs: + build: + runs-on: windows-latest + + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.5.0 + with: + access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/checkout@v2 + - uses: gradle/wrapper-validation-action@v1 + - uses: actions/cache@v2 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-2-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-2-gradle- + + - name: Gradle clean build + uses: eskatos/gradle-command-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HEAD_REF: ${{ github.head_ref }} + with: + arguments: "clean build" diff --git a/common/src/main/kotlin/flank/common/Files.kt b/common/src/main/kotlin/flank/common/Files.kt index bcbe5023b3..db771f53b7 100644 --- a/common/src/main/kotlin/flank/common/Files.kt +++ b/common/src/main/kotlin/flank/common/Files.kt @@ -13,6 +13,10 @@ val userHome: String by lazy { if (isWindows) System.getenv("HOMEPATH") else System.getProperty("user.home") } +val appDataDirectory: String by lazy { + if (isWindows) System.getenv("APPDATA") else System.getProperty("user.home") +} + fun linkFiles( link: String, target: String diff --git a/test_runner/src/main/kotlin/ftl/ios/xctest/common/InstallParseBinaries.kt b/test_runner/src/main/kotlin/ftl/ios/xctest/common/InstallParseBinaries.kt index 353e34ad00..595b0dc2e2 100644 --- a/test_runner/src/main/kotlin/ftl/ios/xctest/common/InstallParseBinaries.kt +++ b/test_runner/src/main/kotlin/ftl/ios/xctest/common/InstallParseBinaries.kt @@ -1,6 +1,7 @@ package ftl.ios.xctest.common import flank.common.OutputLogLevel +import flank.common.appDataDirectory import flank.common.createDirectoryIfNotExist import flank.common.createSymbolicLinkToFile import flank.common.downloadFile @@ -9,7 +10,6 @@ import flank.common.isMacOS import flank.common.isWindows import flank.common.logLn import flank.common.unzipFile -import flank.common.userHome import java.nio.file.Files import java.nio.file.Paths @@ -37,7 +37,7 @@ private fun neededFilesListByOs(): List = if (isWindows) { listOf("nm", "swift-demangle", "libatomic.so.1", "libatomic.so.1.2.0") } -private val flankBinariesDirectory = Paths.get(userHome, ".flank") +private val flankBinariesDirectory = Paths.get(appDataDirectory, ".flank").toAbsolutePath() private fun downloadAndUnzip(osname: String) { createDirectoryIfNotExist(flankBinariesDirectory) @@ -47,7 +47,7 @@ private fun downloadAndUnzip(osname: String) { sourceUrl = "https://github.com/Flank/binaries/releases/download/$osname/binaries.zip", destinationPath = destinationFile ) - createDirectoryIfNotExist(flankBinariesDirectory) + unzipFile(destinationFile.toFile().absoluteFile, flankBinariesDirectory.toString()) .forEach { logLn("Binary file $it copied to $flankBinariesDirectory", OutputLogLevel.DETAILED) diff --git a/test_runner/src/test/kotlin/ftl/analytics/UsageStatisticsTest.kt b/test_runner/src/test/kotlin/ftl/analytics/UsageStatisticsTest.kt index 360aa6cca8..09a211381a 100644 --- a/test_runner/src/test/kotlin/ftl/analytics/UsageStatisticsTest.kt +++ b/test_runner/src/test/kotlin/ftl/analytics/UsageStatisticsTest.kt @@ -1,8 +1,9 @@ package ftl.analytics -import com.google.common.truth.Truth +import com.google.common.truth.Truth.assertThat import ftl.args.AndroidArgs import ftl.args.IosArgs +import ftl.test.util.FlankTestRunner import ftl.util.readVersion import io.mockk.every import io.mockk.mockkStatic @@ -11,7 +12,9 @@ import io.mockk.verify import org.json.JSONObject import org.junit.After import org.junit.Test +import org.junit.runner.RunWith +@RunWith(FlankTestRunner::class) class UsageStatisticsTest { @After @@ -22,12 +25,14 @@ class UsageStatisticsTest { @Test fun `should filter default args for android`() { val default = AndroidArgs.default() - val args = default.copy(appApk = "test").objectToMap() + val args = default.copy( + appApk = "test" + ).objectToMap() val nonDefaultArgs = args.filterNonCommonArgs().getNonDefaultArgs(default.objectToMap()) - Truth.assertThat(nonDefaultArgs).containsKey("appApk") - Truth.assertThat(nonDefaultArgs.count()).isEqualTo(1) + assertThat(nonDefaultArgs).containsKey("appApk") + assertThat(nonDefaultArgs.count()).isEqualTo(1) } @Test @@ -37,8 +42,8 @@ class UsageStatisticsTest { val nonDefaultArgs = args.filterNonCommonArgs().getNonDefaultArgs(default.objectToMap()) - Truth.assertThat(nonDefaultArgs).containsKey("xctestrunFile") - Truth.assertThat(nonDefaultArgs.count()).isEqualTo(1) + assertThat(nonDefaultArgs).containsKey("xctestrunFile") + assertThat(nonDefaultArgs.count()).isEqualTo(1) } @Test @@ -49,9 +54,9 @@ class UsageStatisticsTest { val nonDefaultArgs = args.createEventMap(default) - Truth.assertThat(nonDefaultArgs).containsKey("xctestrunFile") - Truth.assertThat(nonDefaultArgs).containsKey("resultsBucket") - Truth.assertThat(nonDefaultArgs.count()).isEqualTo(2) + assertThat(nonDefaultArgs).containsKey("xctestrunFile") + assertThat(nonDefaultArgs).containsKey("resultsBucket") + assertThat(nonDefaultArgs.count()).isEqualTo(2) } @Test @@ -61,9 +66,9 @@ class UsageStatisticsTest { val nonDefaultArgs = args.createEventMap(default) - Truth.assertThat(nonDefaultArgs).containsKey("testApk") - Truth.assertThat(nonDefaultArgs).containsKey("resultsBucket") - Truth.assertThat(nonDefaultArgs.count()).isEqualTo(2) + assertThat(nonDefaultArgs).containsKey("testApk") + assertThat(nonDefaultArgs).containsKey("resultsBucket") + assertThat(nonDefaultArgs.count()).isEqualTo(2) } @Test @@ -73,12 +78,12 @@ class UsageStatisticsTest { val nonDefaultArgs = args.createEventMap(default) (nonDefaultArgs["environmentVariables"] as? Map<*, *>)?.let { environmentVariables -> - Truth.assertThat(environmentVariables.count()).isEqualTo(2) - Truth.assertThat(environmentVariables.values.all { it == "..." }).isTrue() + assertThat(environmentVariables.count()).isEqualTo(2) + assertThat(environmentVariables.values.all { it == "..." }).isTrue() } - Truth.assertThat(nonDefaultArgs.count()).isEqualTo(1) - Truth.assertThat(nonDefaultArgs.keys).containsExactly("environmentVariables") + assertThat(nonDefaultArgs.count()).isEqualTo(1) + assertThat(nonDefaultArgs.keys).containsExactly("environmentVariables") } @Test diff --git a/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt b/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt index 0de2e8294e..1f21d0eb9d 100644 --- a/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt +++ b/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt @@ -22,6 +22,7 @@ import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Assume +import org.junit.Assume.assumeFalse import org.junit.Rule import org.junit.Test import org.junit.contrib.java.lang.system.SystemErrRule @@ -1262,6 +1263,8 @@ IosArgs @Test(expected = FlankConfigurationError::class) fun `should throw exception when only-test-configuration is specified for xctestrun v1`() { + assumeFalse(isWindows) + val yaml = """ gcloud: test: $testPath @@ -1274,6 +1277,8 @@ IosArgs @Test(expected = FlankConfigurationError::class) fun `should throw exception when skip-test-configuration is specified for xctestrun v1`() { + assumeFalse(isWindows) + val yaml = """ gcloud: test: $testPath @@ -1286,6 +1291,8 @@ IosArgs @Test fun `should not throw exception when only-test-configuration is specified for xctestrun v2`() { + assumeFalse(isWindows) + val yaml = """ gcloud: test: $testPlansPath @@ -1298,6 +1305,8 @@ IosArgs @Test fun `should not throw exception when skip-test-configuration is specified for xctestrun v2`() { + assumeFalse(isWindows) + val yaml = """ gcloud: test: $testPlansPath diff --git a/test_runner/src/test/kotlin/ftl/ios/xctest/common/InstallParseBinariesTest.kt b/test_runner/src/test/kotlin/ftl/ios/xctest/common/InstallParseBinariesTest.kt index 67f915c23c..ed81c72e3f 100644 --- a/test_runner/src/test/kotlin/ftl/ios/xctest/common/InstallParseBinariesTest.kt +++ b/test_runner/src/test/kotlin/ftl/ios/xctest/common/InstallParseBinariesTest.kt @@ -1,9 +1,9 @@ package ftl.ios.xctest.common +import flank.common.appDataDirectory import flank.common.hasAllFiles import flank.common.isMacOS import flank.common.isWindows -import flank.common.userHome import org.junit.Assert.assertTrue import org.junit.Assume.assumeTrue import org.junit.Test @@ -21,7 +21,7 @@ internal class InstallParseBinariesTest { // then assertTrue( - Paths.get(userHome, ".flank").toFile().hasAllFiles( + Paths.get(appDataDirectory, ".flank").toFile().hasAllFiles( listOf("libatomic.so.1", "libatomic.so.1.2.0") ) ) @@ -37,7 +37,7 @@ internal class InstallParseBinariesTest { // then assertTrue( - Paths.get(userHome, ".flank").toFile().hasAllFiles( + Paths.get(appDataDirectory, ".flank").toFile().hasAllFiles( listOf("nm", "swift-demangle", "libatomic.so.1", "libatomic.so.1.2.0") ) ) diff --git a/test_runner/src/test/kotlin/ftl/ios/xctest/common/ParseObjTestsKtTest.kt b/test_runner/src/test/kotlin/ftl/ios/xctest/common/ParseObjTestsKtTest.kt index 61a9d2a805..ec194f0f10 100644 --- a/test_runner/src/test/kotlin/ftl/ios/xctest/common/ParseObjTestsKtTest.kt +++ b/test_runner/src/test/kotlin/ftl/ios/xctest/common/ParseObjTestsKtTest.kt @@ -20,6 +20,8 @@ class ParseObjTestsKtTest { @Test(expected = FlankGeneralError::class) fun `parseObjcTests fileNotFound`() { + assumeFalse(isWindows) + parseObjcTests("./BinaryThatDoesNotExist") } diff --git a/test_runner/src/test/kotlin/ftl/ios/xctest/common/ParseSwiftTestsKtTest.kt b/test_runner/src/test/kotlin/ftl/ios/xctest/common/ParseSwiftTestsKtTest.kt index 0409ccdeab..d977d1f709 100644 --- a/test_runner/src/test/kotlin/ftl/ios/xctest/common/ParseSwiftTestsKtTest.kt +++ b/test_runner/src/test/kotlin/ftl/ios/xctest/common/ParseSwiftTestsKtTest.kt @@ -20,11 +20,15 @@ class ParseSwiftTestsKtTest { @Test(expected = FlankGeneralError::class) fun `parseSwiftTests fileNotFound`() { + assumeFalse(isWindows) + parseSwiftTests("./BinaryThatDoesNotExist") } @Test(expected = FlankGeneralError::class) fun `parseSwiftTests tmpFolder`() { + assumeFalse(isWindows) + parseSwiftTests("/tmp") }