Skip to content

Commit

Permalink
ci: Added Windows workflow (#1534)
Browse files Browse the repository at this point in the history
  • Loading branch information
piotradamczyk5 authored Jan 27, 2021
1 parent 6f47461 commit 79d26e1
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 22 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/windows_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: windows-workflow

on:
pull_request:
branches:
- '*'

jobs:
build:
runs-on: windows-latest

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
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"
4 changes: 4 additions & 0 deletions common/src/main/kotlin/flank/common/Files.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down Expand Up @@ -37,7 +37,7 @@ private fun neededFilesListByOs(): List<String> = 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)
Expand All @@ -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)
Expand Down
37 changes: 21 additions & 16 deletions test_runner/src/test/kotlin/ftl/analytics/UsageStatisticsTest.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")
)
)
Expand All @@ -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")
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class ParseObjTestsKtTest {

@Test(expected = FlankGeneralError::class)
fun `parseObjcTests fileNotFound`() {
assumeFalse(isWindows)

parseObjcTests("./BinaryThatDoesNotExist")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down

0 comments on commit 79d26e1

Please sign in to comment.