Skip to content

Commit

Permalink
Fix gha workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
nirinchev committed Aug 19, 2024
1 parent 43808aa commit 6e1c22b
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 283 deletions.
47 changes: 0 additions & 47 deletions .github/pkl-workflows/helpers/BaaS.pkl

This file was deleted.

21 changes: 8 additions & 13 deletions .github/pkl-workflows/helpers/Common.pkl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module common

import "../GithubAction/GithubAction.pkl" as gha
import "BaaS.pkl"
import "Lint.pkl"
import "Package.pkl"
import "Test.pkl" as TestJobs
Expand Down Expand Up @@ -50,12 +49,11 @@ const packages: List<String> = nugetPackages + List("Realm.UnityUtils", "Realm.U

const testTimeout: Int = 60

const function defaultBuildJobs(baasDifferentiators: Listing<SyncDifferentiator>, netCoreVersions: Listing<NetFramework>): Mapping<String, gha.JobBase> = new {
const function defaultBuildJobs(netCoreVersions: Listing<NetFramework>): Mapping<String, gha.JobBase> = new {
[job_Wrappers] = new gha.ReusableWorkflowJob {
uses = "./.github/workflows/wrappers.yml"
name = "Wrappers"
}
[job_Baas] = BaaS.deploy(baasDifferentiators)
[job_Packages] = (Package.nuget("contains(github.head_ref, 'release')")){
needs {
job_Wrappers
Expand All @@ -68,23 +66,20 @@ const function defaultBuildJobs(baasDifferentiators: Listing<SyncDifferentiator>
...TestJobs.unity(new TestJobs.UnityTestConfig {
os = "windows"
})
["test-net-framework"] = TestJobs.netFramework(baasDifferentiators)
["test-uwp"] = TestJobs.uwp(baasDifferentiators)
["test-net-framework"] = TestJobs.netFramework()
["test-uwp"] = TestJobs.uwp()
["test-net-core"] = TestJobs.netCore(netCoreVersions)
["test-macos-xamarin"] = TestJobs.macOS_Xamarin()
["test-macos-maui"] = TestJobs.macOS_Maui(baasDifferentiators)
["test-macos-maui"] = TestJobs.macOS_Maui()
["test-ios-xamarin"] = TestJobs.iOS_Xamarin()
["test-ios-maui"] = TestJobs.iOS_Maui(baasDifferentiators)
["test-tvos"] = TestJobs.tvOS(baasDifferentiators)
["test-ios-maui"] = TestJobs.iOS_Maui()
["test-tvos"] = TestJobs.tvOS()
["test-android-xamarin"] = TestJobs.android_Xamarin()
["test-android-maui"] = TestJobs.android_Maui(baasDifferentiators)
["test-android-maui"] = TestJobs.android_Maui()
["test-woven-classes"] = TestJobs.wovenClasses()
["test-source-generation"] = TestJobs.sourceGeneration()
["test-weaver"] = TestJobs.weaver()
["test-code-coverage"] = TestJobs.codeCoverage(job_Wrappers, baasDifferentiators)
["cleanup-baas"] = (BaaS.cleanup(baasDifferentiators)) {
needs = baasDifferentiators.toList().map((d) -> "test-\(d)").toListing()
}
["test-code-coverage"] = TestJobs.codeCoverage(job_Wrappers)
["verify-namespaces"] = Lint.verifyNamespaces()
["lint"] = Lint.lint()
}
52 changes: 14 additions & 38 deletions .github/pkl-workflows/helpers/Test.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module test
import "../GithubAction/GithubAction.pkl" as gha
import "Common.pkl"
import "Steps.pkl"
import "BaaS.pkl"
import "Package.pkl"

local const actionReportTestResults = "dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5"
Expand All @@ -12,12 +11,10 @@ local const outputFile = "TestResults.xml"
local const executableExpression = "${{ steps.dotnet-publish.outputs.executable-path }}"

// Public test targets
function netFramework(_syncDifferentiators: Listing<String>): gha.StepJobBase = testJob(
function netFramework(): gha.StepJobBase = testJob(
new TestConfig {
title = ".NET Framework"
needsPackages = true
syncDifferentiator = "net-framework"
syncDifferentiators = _syncDifferentiators
},
new gha.WindowsLatest{},
null,
Expand All @@ -34,7 +31,7 @@ function netFramework(_syncDifferentiators: Listing<String>): gha.StepJobBase =
})
new {
name = "Run the tests"
run = "./Tests/Realm.Tests/bin/\(Common.configuration)/net461/Realm.Tests.exe --result=\(outputFile) --labels=After \(baasTestArgs(config))"
run = "./Tests/Realm.Tests/bin/\(Common.configuration)/net461/Realm.Tests.exe --result=\(outputFile) --labels=After"
}
...reportTestResults(config)
})
Expand Down Expand Up @@ -155,12 +152,10 @@ function wovenClasses(): gha.StepJobBase = testJob(
}
)

function tvOS(_syncDifferentiators: Listing<Common.SyncDifferentiator>): gha.StepJobBase = testJob(
function tvOS(): gha.StepJobBase = testJob(
new TestConfig {
needsPackages = true
title = "Xamarin.tvOS"
syncDifferentiator = "tvos"
syncDifferentiators = _syncDifferentiators
},
"macos-12",
null,
Expand All @@ -176,7 +171,7 @@ function tvOS(_syncDifferentiators: Listing<Common.SyncDifferentiator>): gha.Ste
})
Steps.runSimulator(new Steps.SimulatorConfig{
appPath = "Tests/Tests.XamarinTVOS/bin/iPhoneSimulator/\(Common.configuration)/Tests.XamarinTVOS.app"
arguments = "--headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))"
arguments = "--headless --result=${{ github.workspace }}/\(outputFile) --labels=All"
bundleId = "io.realm.Tests-XamarinTVOS"
iphoneToSimulate = "Apple-TV-1080p"
os = "tvOS"
Expand All @@ -203,20 +198,18 @@ function iOS_Xamarin(): gha.StepJobBase = testJob(
})
Steps.runSimulator(new Steps.SimulatorConfig{
appPath = "Tests/Tests.iOS/bin/iPhoneSimulator/\(Common.configuration)/Tests.iOS.app"
arguments = "--headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))"
arguments = "--headless --result=${{ github.workspace }}/\(outputFile) --labels=All "
bundleId = "io.realm.dotnettests"
iphoneToSimulate = "iPhone-8"
os = "iOS"
})
...reportTestResults(config)
})

function iOS_Maui(_syncDifferentiators: Listing<Common.SyncDifferentiator>): gha.StepJobBase = testJob(
function iOS_Maui(): gha.StepJobBase = testJob(
new TestConfig {
needsPackages = true
title = "Maui.iOS"
syncDifferentiator = "ios-maui"
syncDifferentiators = _syncDifferentiators
transformResults = true
},
"macos-13",
Expand All @@ -228,7 +221,7 @@ function iOS_Maui(_syncDifferentiators: Listing<Common.SyncDifferentiator>): gha
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-x64/Tests.Maui.app"
arguments = "--headless --result=${{ github.workspace }}/\(outputFile) --labels=All \(baasTestArgs(config))"
arguments = "--headless --result=${{ github.workspace }}/\(outputFile) --labels=All"
bundleId = "io.realm.mauitests"
iphoneToSimulate = "iPhone-15"
os = "iOS"
Expand Down Expand Up @@ -257,12 +250,10 @@ function macOS_Xamarin(): gha.StepJobBase = testJob(
...reportTestResults(config)
})

function macOS_Maui(_syncDifferentiators: Listing<Common.SyncDifferentiator>): gha.StepJobBase = testJob(
function macOS_Maui(): gha.StepJobBase = testJob(
new TestConfig {
needsPackages = true
title = "Maui.MacCatalyst"
syncDifferentiator = "macos-maui"
syncDifferentiators = _syncDifferentiators
transformResults = true
},
"macos-13",
Expand All @@ -274,17 +265,15 @@ function macOS_Maui(_syncDifferentiators: Listing<Common.SyncDifferentiator>): g
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-x64/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"
}
...reportTestResults(config)
})

function uwp(_syncDifferentiators: Listing<Common.SyncDifferentiator>): gha.StepJobBase = testJob(
function uwp(): gha.StepJobBase = testJob(
new TestConfig {
needsPackages = true
title = "UWP"
syncDifferentiators = _syncDifferentiators
syncDifferentiator = "uwp"
},
new gha.WindowsLatest{},
null,
Expand Down Expand Up @@ -314,7 +303,7 @@ function uwp(_syncDifferentiators: Listing<Common.SyncDifferentiator>): gha.Step
})
new {
name = "Run the tests"
run = "./Tests/Tests.UWP/RunTests.ps1 -ExtraAppArgs '\(baasTestArgs(config))'"
run = "./Tests/Tests.UWP/RunTests.ps1 -ExtraAppArgs"
shell = "powershell"
}
...reportTestResultsWithCustomFile("${{ env.TEST_RESULTS }}", config)
Expand Down Expand Up @@ -347,12 +336,10 @@ function android_Xamarin(): gha.StepJobBase = testJob(
...reportTestResultsWithCustomFile("${{ steps.run_tests.outputs.test-results-path }}", config)
})

function android_Maui(_syncDifferentiators: Listing<Common.SyncDifferentiator>): gha.StepJobBase = testJob(
function android_Maui(): gha.StepJobBase = testJob(
new TestConfig {
needsPackages = true
title = "Maui.Android"
syncDifferentiator = "android-maui"
syncDifferentiators = _syncDifferentiators
transformResults = true
},
new gha.WindowsLatest{},
Expand All @@ -369,11 +356,9 @@ function android_Maui(_syncDifferentiators: Listing<Common.SyncDifferentiator>):
...reportTestResultsWithCustomFile("${{ steps.run_tests.outputs.test-results-path }}", config)
})

function codeCoverage(wrappersJob: String, _syncDifferentiators: Listing<Common.SyncDifferentiator>): gha.StepJobBase = (testJob(
function codeCoverage(wrappersJob: String): gha.StepJobBase = (testJob(
new TestConfig {
title = "Code Coverage"
syncDifferentiator = "code-coverage"
syncDifferentiators = _syncDifferentiators
usedWrappers = List("linux-x86_64")
},
new gha.UbuntuLatest{},
Expand All @@ -391,7 +376,7 @@ function codeCoverage(wrappersJob: String, _syncDifferentiators: Listing<Common.
...Steps.dotnetPublish("Tests/Realm.Tests", "net8.0", "linux-x64", new Mapping { ["RealmTestsStandaloneExe"] = "true" })
new gha.Step {
name = "Run the tests"
run = "./tools/coverlet ./Tests/Realm.Tests/bin/\(Common.configuration)/net8.0/linux-x64 -t \(executableExpression) -a '--result=\(outputFile) --labels=After\(baasTestArgs(config))' -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*' --exclude '[Realm.PlatformHelpers]*'"
run = "./tools/coverlet ./Tests/Realm.Tests/bin/\(Common.configuration)/net8.0/linux-x64 -t \(executableExpression) -a '--result=\(outputFile) --labels=After' -f lcov -o ./report.lcov --exclude '[Realm.Tests]*' --exclude '[Realm.Fody]*' --exclude '[Realm.PlatformHelpers]*'"
} |> enableCoreDumps(true)
archiveCoreDump()
...Steps.publishCoverage("./report.lcov")
Expand Down Expand Up @@ -531,9 +516,6 @@ local function testJob(config: TestConfig, runsOn: gha.Machine | String, _strate
when (config.needsPackages) {
needs {
Common.job_Packages
when (config.runSyncTests) {
Common.job_Baas
}
}
}
`if` = Common.ifNotCanceledCondition
Expand All @@ -545,7 +527,6 @@ local function prepareTests(config: TestConfig(needsPackages == true || !usedWra
...Steps.checkout(false)
...cleanWorkspace(config.shouldCleanWorkspace)
...fetchTestArtifacts(config.usedWrappers)
...BaaS.deployStep(config.syncDifferentiator, config.runSyncTests)
}

local function cleanWorkspace(shouldClean: Boolean): Listing<gha.Step> = new Listing {
Expand All @@ -564,8 +545,6 @@ local function buildTests(config: Steps.MSBuildConfig): Listing<gha.Step> = Step
}
})

local function baasTestArgs(config: TestConfig): String = if (config.runSyncTests) " --baasaas-api-key=${{ secrets.BAASAAS_API_KEY}} --baas-differentiator=\(config.syncDifferentiator)-${{ github.run_id }}-${{ github.run_attempt }}" else ""

local function reportTestResults(config: TestConfig): Listing<gha.Step> = reportTestResultsWithCustomFile(outputFile, config)

local function reportTestResultsWithCustomFile(_outputFile: String, config: TestConfig): Listing<gha.Step> = new {
Expand Down Expand Up @@ -637,8 +616,5 @@ local class TestConfig {
needsPackages: Boolean = false
usedWrappers: List<String>(every((wrapper) -> Common.wrapperBinaryNames.contains(wrapper)))
shouldCleanWorkspace: Boolean = false
syncDifferentiator: Common.SyncDifferentiator? = null
transformResults: Boolean = false
syncDifferentiators: Listing<Common.SyncDifferentiator>?
runSyncTests: Boolean = syncDifferentiator != null && (syncDifferentiators?.toList()?.contains(syncDifferentiator) ?? false)
}
12 changes: 1 addition & 11 deletions .github/pkl-workflows/main.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ import "helpers/Common.pkl"
import "helpers/Steps.pkl"
import "helpers/Test.pkl" as TestJobs

local baasDifferentiators: Listing<Common.SyncDifferentiator> = new {
"code-coverage"
"net-framework"
"uwp"
"macos-maui"
"android-maui"
"ios-maui"
"macos-maui"
}

local netCoreFrameworks: Listing<Common.NetFramework> = new {
"net6.0"
"net8.0"
Expand Down Expand Up @@ -46,7 +36,7 @@ on {

env = Common.defaultEnv

jobs = (Common.defaultBuildJobs(baasDifferentiators, netCoreFrameworks)) {
jobs = (Common.defaultBuildJobs(netCoreFrameworks)) {
["publish-packages-to-sleet"] = new Job {
`runs-on` = new UbuntuLatest{}
name = "Publish package to S3"
Expand Down
6 changes: 1 addition & 5 deletions .github/pkl-workflows/pr.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ amends "GithubAction/GithubAction.pkl"

import "helpers/Common.pkl"

local baasDifferentiators: Listing<Common.SyncDifferentiator> = new {
"code-coverage"
}

local netCoreFrameworks: Listing<Common.NetFramework> = new {
"net6.0"
}
Expand Down Expand Up @@ -41,4 +37,4 @@ concurrency {
`cancel-in-progress` = true
}

jobs = Common.defaultBuildJobs(baasDifferentiators, netCoreFrameworks)
jobs = Common.defaultBuildJobs(netCoreFrameworks)
2 changes: 1 addition & 1 deletion .github/pkl-workflows/publish-release.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs {
Steps.downloadAllArtifacts()
Steps.readVersionFromPackage()
Steps.configureAWSCredentials("DOCS_S3_ACCESS_KEY", "DOCS_S3_SECRET_KEY", "us-east-2")
uploadDocs()
// uploadDocs()
...uploadToNuGet()
...Steps.uploadToNPM("latest")
...mergeReleasePR()
Expand Down
Loading

0 comments on commit 6e1c22b

Please sign in to comment.