Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Added Windows workflow #1534

Merged
merged 3 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Sloox marked this conversation as resolved.
Show resolved Hide resolved

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 }}
Sloox marked this conversation as resolved.
Show resolved Hide resolved
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a feeling something related to HOMEPATH was going to be the issue. I assume that HOMEPATH you dont have write permissions on the VM'S right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly. User directory is for users 🎉 Just one working day to figure this out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and basically this is good practice on Windows to keep app data into app data folder instead of user one

}

fun linkFiles(
link: String,
target: String
Expand Down
4 changes: 2 additions & 2 deletions test_runner/src/main/kotlin/ftl/args/CreateCommonArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fun CommonConfig.createCommonArgs(
// gcloud
devices = gcloud::devices.require(),
resultsBucket = ArgsHelper.createGcsBucket(
projectId = flank::project.require(),
piotradamczyk5 marked this conversation as resolved.
Show resolved Hide resolved
projectId = flank.project.orEmpty(),
piotradamczyk5 marked this conversation as resolved.
Show resolved Hide resolved
bucket = gcloud::resultsBucket.require()
),
resultsDir = gcloud.resultsDir ?: uniqueObjectName(),
Expand All @@ -41,7 +41,7 @@ fun CommonConfig.createCommonArgs(
testTargetsAlwaysRun = flank::testTargetsAlwaysRun.require(),
runTimeout = flank::runTimeout.require(),
fullJUnitResult = flank::fullJUnitResult.require(),
project = flank::project.require(),
project = flank.project.orEmpty(),
piotradamczyk5 marked this conversation as resolved.
Show resolved Hide resolved
outputStyle = outputStyle,
keepFilePath = flank::keepFilePath.require(),
ignoreFailedTests = flank::ignoreFailedTests.require(),
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