Skip to content

Commit

Permalink
Revert some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nirinchev committed May 22, 2024
1 parent 5260e89 commit dedfcbe
Show file tree
Hide file tree
Showing 13 changed files with 109 additions and 340 deletions.
4 changes: 2 additions & 2 deletions .github/pkl-workflows/helpers/BaaS.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function deploy(differentiators: Listing<Common.SyncDifferentiator>): gha.Matrix
}
`if` = Common.ifNotCanceledCondition
steps {
...Steps.checkout()
...Steps.checkout(false)
Steps.setupDotnet("6.0.x")
...deployStep("${{ matrix.differentiator }}", true)
}
Expand All @@ -36,7 +36,7 @@ function cleanup(differentiators: Listing<Common.SyncDifferentiator>): gha.Matri
}
`if` = Common.ifNotCanceledCondition
steps {
...Steps.checkout()
...Steps.checkout(false)
Steps.setupDotnet("6.0.x")
new gha.Step {
name = "Terminate Baas"
Expand Down
4 changes: 2 additions & 2 deletions .github/pkl-workflows/helpers/Lint.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function lint(): gha.Job = new {
name = "Verify TODOs"
`runs-on` = new gha.UbuntuLatest{}
steps {
Steps.checkoutWithoutMatchers()
Steps.checkoutWithoutMatchers(false)
new gha.Step {
uses = "nirinchev/verify-todo@9be6f76daddad71433e5deb1b58c517490e5c66e"
with {
Expand All @@ -28,7 +28,7 @@ function verifyNamespaces(): gha.Job = new {
Common.job_Packages
}
steps {
Steps.checkoutWithoutMatchers()
Steps.checkoutWithoutMatchers(false)
...Steps.fetchPackages(Common.job_Packages, null)
new {
run = "dotnet tool install ilspycmd -g --version 8.0.0.7345"
Expand Down
35 changes: 21 additions & 14 deletions .github/pkl-workflows/helpers/Steps.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,30 @@ const actionRunSimulator = "realm/ci-actions/run-ios-simulator@6418e15ed9bbdb19b
const actionSetupJDK = "actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0"
const actionAWSConfigureCredentials = "aws-actions/configure-aws-credentials@v4.0.2"
const actionCoveralls = "coverallsapp/github-action@v2.3.0"

const function checkout(): Listing<gha.Step> = new Listing {
checkoutWithoutMatchers()
const actionCheckout = "actions/checkout@v4"
const actionUploadArtifact = "actions/upload-artifact@v4"
const actionDownloadArtifact = "actions/download-artifact@v4"
const actionSetupXcode = "maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd"
const actionSetupDotnet = "actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a"
const actionSetupMsBuild = "microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497"

const function checkout(submodules: (Boolean | "recursive")): Listing<gha.Step> = new Listing {
checkoutWithoutMatchers(submodules)
registerProblemMatchers()
}

const function checkoutWithoutMatchers(): gha.Step = new {
const function checkoutWithoutMatchers(submodules: (Boolean | "recursive")): gha.Step = new {
name = "Checkout Code"
uses = "actions/checkout@v4"
uses = actionCheckout
with {
["submodules"] = "recursive"
["submodules"] = submodules
["ref"] = "${{ github.event.pull_request.head.sha }}"
}
}

const function uploadArtifacts(artifactName: String, relPath: String): gha.Step = new {
name = "Store artifacts for \(artifactName)"
uses = "actions/upload-artifact@v4"
uses = actionUploadArtifact
with {
["name"] = artifactName
["path"] = "${{ github.workspace }}/\(relPath)"
Expand All @@ -33,7 +39,7 @@ const function uploadArtifacts(artifactName: String, relPath: String): gha.Step

const function setupXcode(version: String): gha.Step = new gha.Step {
name = "Setup Xcode"
uses = "maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd"
uses = actionSetupXcode
with {
["xcode-version"] = version
}
Expand All @@ -46,14 +52,14 @@ const function setupMSVC(edition: String): gha.Step = new {
}

const function setupDotnet(version: String?): gha.Step = new {
uses = "actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a"
uses = actionSetupDotnet
with {
["dotnet-version"] = version ?? "8.0.x"
}
}

const function registerProblemMatchers(): gha.Step = new {
name = "Register csc problem matcher"
name = "Register problem matchers"
run = """
echo "::add-matcher::.github/problem-matchers/csc.json"
echo "::add-matcher::.github/problem-matchers/msvc.json"
Expand All @@ -62,16 +68,16 @@ const function registerProblemMatchers(): gha.Step = new {

const function fetchPackages(packageJob: String, _packages: List<String>?): List<gha.Step> = (_packages ?? Common.packages).map((package) -> new gha.Step {
name = "Fetch \(package)"
uses = "actions/download-artifact@v4"
uses = actionDownloadArtifact
with {
["name"] = "\(package).${{ needs.\(packageJob).outputs.package_version }}"
["path"] = "${{ github.workspace }}/Realm/packages/"
}
})

const function fetchWrappers(): List<gha.Step> = Common.wrapperBinaryNames.map((wrapper) -> new gha.Step {
const function fetchWrappers(wrappers: List<String>(every((wrapper) -> Common.wrapperBinaryNames.contains(wrapper)))): List<gha.Step> = wrappers.map((wrapper) -> new gha.Step {
name = "Fetch wrappers for \(wrapper)"
uses = "actions/download-artifact@v4"
uses = actionDownloadArtifact
with {
["name"] = "wrappers-\(wrapper)"
["path"] = "wrappers/build"
Expand Down Expand Up @@ -109,6 +115,7 @@ class MSBuildConfig {
project: String
target: String?
properties: Mapping<String, String> = new Mapping{}
standaloneExe: Boolean = false

function getTargetForInvocation(): String = if (target != null) " -t:\(target)" else ""
function getPropertiesForInvocation(): String = "-p:Configuration=\(Common.configuration)\(propertiesToString(properties))"
Expand Down Expand Up @@ -194,7 +201,7 @@ class DeviceFarmConfig {

local const function addMSBuildToPath(): gha.Step = new {
name = "Add msbuild to PATH"
uses = "microsoft/setup-msbuild@0b44c6745b7e81956596964100aadb92d667c497"
uses = actionSetupMsBuild
`if` = "${{ runner.os == 'Windows' }}"
}

Expand Down
44 changes: 23 additions & 21 deletions .github/pkl-workflows/helpers/Test.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function netCore(frameworks: Listing<Common.NetFramework>): gha.StepJobBase = te
shell = "bash"
}
Steps.setupDotnet("${{ steps.get-net-version.outputs.version }}")
...Steps.dotnetPublish("Tests/Realm.Tests", "${{ matrix.framework }}", "${{ matrix.os.runtime }}", getTestProps())
...Steps.dotnetPublish("Tests/Realm.Tests", "${{ matrix.framework }}", "${{ matrix.os.runtime }}", getTestProps(true))
...dotnetRunTests(true)
...reportTestResults(config)
})
Expand All @@ -94,7 +94,7 @@ function weaver(): gha.StepJobBase = testJob(
}
},
(config) -> new Listing<gha.Step> {
...Steps.checkout()
...Steps.checkout(false)
...Steps.setupWorkloads(null, "6.0.x")
...Steps.dotnetPublish("Tests/Weaver/Realm.Fody.Tests", "net6.0", "${{ matrix.os.runtime }}", new Mapping{}).toList()
...dotnetRunTests(false)
Expand All @@ -109,7 +109,7 @@ function sourceGeneration(): gha.StepJobBase = testJob(
new gha.WindowsLatest{},
null,
(config) -> new Listing<gha.Step> {
...Steps.checkout()
...Steps.checkout(false)
...Steps.setupWorkloads(null, "6.0.x")
...Steps.dotnetPublish("Tests/SourceGenerators/Realm.SourceGenerator.Tests", "net6.0", "win-x64", new Mapping{}).toList()
...dotnetRunTests(false)
Expand All @@ -125,7 +125,7 @@ function wovenClasses(): gha.StepJobBase = testJob(
null,
(config) -> new Listing<gha.Step> {
...prepareTests(config)
...Steps.dotnetPublish("Tests/Realm.Tests", "net8.0", "win-x64", (getTestProps()) {
...Steps.dotnetPublish("Tests/Realm.Tests", "net8.0", "win-x64", (getTestProps(true)) {
["TestWeavedClasses"] = "true"
})
...dotnetRunTests(false)
Expand Down Expand Up @@ -193,15 +193,15 @@ function iOS_Maui(_syncDifferentiators: Listing<Common.SyncDifferentiator>): gha
syncDifferentiators = _syncDifferentiators
transformResults = true
},
"macos-14",
"macos-13",
null,
(config) -> new Listing<gha.Step> {
...prepareTests(config)
...Steps.setupWorkloads("maui", null)
Steps.setupXcode("latest-stable")
Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-ios", null, getTestProps())
Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-ios", null, getTestProps(false))
Steps.runSimulator(new Steps.SimulatorConfig{
appPath = "Tests/Tests.Maui/bin/\(Common.configuration)/net8.0-ios/iossimulator-arm64/Tests.Maui.app"
appPath = "Tests/Tests.Maui/bin/\(Common.configuration)/net8.0-ios/iossimulator-x64/Tests.Maui.app"
arguments = "--headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))"
bundleId = "io.realm.mauitests"
iphoneToSimulate = "iPhone-15"
Expand Down Expand Up @@ -237,16 +237,16 @@ function macOS_Maui(_syncDifferentiators: Listing<Common.SyncDifferentiator>): g
syncDifferentiators = _syncDifferentiators
transformResults = true
},
"macos-14",
"macos-13",
null,
(config) -> new Listing<gha.Step> {
...prepareTests(config)
...Steps.setupWorkloads("maui", null)
Steps.setupXcode("latest-stable")
Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-maccatalyst", null, getTestProps())
Steps.dotnetBuild("Tests/Tests.Maui", "net8.0-maccatalyst", null, getTestProps(false))
new {
name = "Run the tests"
run = "Tests/Tests.Maui/bin/\(Common.configuration)/net8.0-maccatalyst/maccatalyst-arm64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))"
run = "Tests/Tests.Maui/bin/\(Common.configuration)/net8.0-maccatalyst/maccatalyst-x64/Tests.Maui.app/Contents/MacOS/Tests.Maui --headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))"
}
...reportTestResults(config)
})
Expand Down Expand Up @@ -329,7 +329,7 @@ function android_Maui(_syncDifferentiators: Listing<Common.SyncDifferentiator>):
Steps.setupJDK()
...prepareTests(config)
...Steps.setupWorkloads("maui", null)
...Steps.dotnetPublish("Tests/Tests.Maui", "net8.0-android", /* runtime */ null, getTestProps())
...Steps.dotnetPublish("Tests/Tests.Maui", "net8.0-android", /* runtime */ null, getTestProps(false))
...Steps.runDeviceFarm(new Steps.DeviceFarmConfig {
apkPath = "${{ github.workspace }}/Tests/Tests.Maui/bin/Release/net8.0-android/publish/io.realm.mauitests-Signed.apk"
appId = "io.realm.mauitests"
Expand All @@ -342,7 +342,7 @@ function codeCoverage(wrappersJob: String, _syncDifferentiators: Listing<Common.
title = "Code Coverage"
syncDifferentiator = "code-coverage"
syncDifferentiators = _syncDifferentiators
useWrappers = true
usedWrappers = List("linux-x86_64")
},
new gha.UbuntuLatest{},
null,
Expand Down Expand Up @@ -389,10 +389,10 @@ local function testJob(config: TestConfig, runsOn: gha.Machine | String, _strate
steps = _steps.apply(config)
}

local function prepareTests(config: TestConfig(needsPackages == true || useWrappers == true)): Listing<gha.Step> = new Listing {
...Steps.checkout()
local function prepareTests(config: TestConfig(needsPackages == true || !usedWrappers.isEmpty)): Listing<gha.Step> = new Listing {
...Steps.checkout(false)
...cleanWorkspace(config.shouldCleanWorkspace)
...fetchTestArtifacts(Common.job_Packages, config.useWrappers)
...fetchTestArtifacts(Common.job_Packages, config.usedWrappers)
...BaaS.deployStep(config.syncDifferentiator, config.runSyncTests)
}

Expand All @@ -405,13 +405,13 @@ local function cleanWorkspace(shouldClean: Boolean): Listing<gha.Step> = new Lis
}
}

local function fetchTestArtifacts(packageJob: String, useWrappers: Boolean): List<gha.Step> = if (useWrappers)
Steps.fetchWrappers()
local function fetchTestArtifacts(packageJob: String, wrappers: List<String>(every((wrapper) -> Common.wrapperBinaryNames.contains(wrapper)))): List<gha.Step> =
if (!wrappers.isEmpty) Steps.fetchWrappers(wrappers)
else Steps.fetchPackages(packageJob, Common.nugetPackages)

local function buildTests(config: Steps.MSBuildConfig): List<gha.Step> = Steps.msbuild((config) {
properties {
...getTestProps()
...getTestProps(config.standaloneExe)
}
})

Expand Down Expand Up @@ -442,10 +442,12 @@ local function reportTestResultsWithCustomFile(_outputFile: String, config: Test
}
}

local function getTestProps(): Mapping<String, String> = new Mapping {
local function getTestProps(standaloneExe: Boolean): Mapping<String, String> = new Mapping {
["RestoreConfigFile"] = "Tests/Test.NuGet.Config"
["UseRealmNupkgsWithVersion"] = "${{ needs.\(Common.job_Packages).outputs.package_version }}"
["RealmTestsStandaloneExe"] = "true"
when (standaloneExe) {
["RealmTestsStandaloneExe"] = "true"
}
}

local function dotnetRunTests(enableCoreDumps: Boolean): Listing<gha.Step> = new Listing {
Expand Down Expand Up @@ -485,7 +487,7 @@ local class MatrixOS {
local class TestConfig {
title: String
needsPackages: Boolean = false
useWrappers: Boolean = false
usedWrappers: List<String>(every((wrapper) -> Common.wrapperBinaryNames.contains(wrapper)))
shouldCleanWorkspace: Boolean = false
syncDifferentiator: Common.SyncDifferentiator? = null
transformResults: Boolean = false
Expand Down
4 changes: 2 additions & 2 deletions .github/pkl-workflows/wrappers.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs {
.toMap((platform) -> "wrappers-\(platform)",(platform) -> "${{ steps.check-cache-\(platform).outputs.cache-hit }}")
.toMapping()
steps {
Steps.checkoutWithoutMatchers()
Steps.checkoutWithoutMatchers("recursive")
for (platform in Common.wrapperBinaryNames) {
restoreCache(platform) |> withCondition(platform, null)
Steps.uploadArtifacts("wrappers-\(platform)", "wrappers/build/**") |> withCondition(platform, "steps.check-cache-\(platform).outputs.cache-hit == 'true'")
Expand Down Expand Up @@ -176,7 +176,7 @@ local function wrappersJob(config: JobConfig) = new Mixin<StepJobBase> {
}
`if` = config.ifCondition
steps {
Steps.checkoutWithoutMatchers()
Steps.checkoutWithoutMatchers("recursive")
checkCache(config.platform)
...config.intermediateSteps.toList().map((step) -> (step) {
`if` = WrappersCacheCondition
Expand Down
Loading

0 comments on commit dedfcbe

Please sign in to comment.