Skip to content

Run tests Linux multiarch #1115

Run tests Linux multiarch

Run tests Linux multiarch #1115

name: Run tests Linux multiarch
on:
workflow_call:
pull_request:
schedule:
# Every day at 2 AM UTC
- cron: "0 2 * * *"
workflow_dispatch:
concurrency:
group: linux-multiarch-${{ github.head_ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
#Main tests grid. Builds and runs tests agains multiple combination of GC, Build mode and Scala Version
#It can be extended to test against different OS and Arch settings
test:
name: Test cross-compilation
if: "github.event_name == 'pull_request' || ((github.event_name == 'schedule' || github.event_name == 'workflow_call') && github.repository == 'scala-native/scala-native')"
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
arch: [linux-arm64, linux-x86]
# Scala 2.13 only for increased tests coverage (Scala2 partests) while keeping total number of jobs low
scala: [2.13]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/linux-setup-env
with:
scala-version: ${{matrix.scala}}
- name: Cache docker
uses: actions/cache@v4
with:
path: /tmp/docker-registry
key: docker-registry-${{ matrix.arch }}-${{ hashFiles('ci-docker/Dockerfile', format('ci-docker/env/{0}', matrix.arch)) }}
- name: Prepare native config
shell: bash
# Following envs CROSS_ are always present in docker container
run: |
SetConfigTemplate=$(cat << EOM
nativeConfig ~= { prev =>
val crossRoot = sys.env("CROSS_ROOT");
val crossTriple = sys.env("CROSS_TRIPLE");
val sysRoot: List[String] = {
assert(java.nio.file.Files.exists(java.nio.file.Paths.get(crossRoot)), "crossroot does not exist");
assert(java.nio.file.Files.exists(java.nio.file.Paths.get(crossRoot, crossTriple, "sysroot")), "sysroot does not exist");
List(
s"--sysroot=\${crossRoot}/\${crossTriple}/sysroot",
s"--gcc-toolchain=\${crossRoot}"
)
};
prev
.withTargetTriple(crossTriple)
.withCompileOptions(sysRoot)
.withLinkingOptions(sysRoot ++ List("-latomic"))
}
EOM
)
echo set-native-config=${SetConfigTemplate} >> $GITHUB_ENV
- name: Set sandbox source
run: |
cat <<EOT > sandbox/src/main/scala/Test.scala
import scala.scalanative.meta.LinktimeInfo._
import scala.scalanative.unsafe._
import scala.scalanative.runtime.Platform
object Test {
def main(args: Array[String]): Unit = {
println("Hello, World!")
println(s"is32bit=\$is32BitPlatform")
println(s"multithreading=\${isMultithreadingEnabled}")
println(s"triple=\${target.arch}-\${target.vendor}-\${target.os}-\${target.env}")
println(s"sizeOf[Ptr[_]]: \${sizeOf[Ptr[_]]}")
println(s"sizeOf[WChar]: \${Platform.SizeOfWChar}")
println(s"LittleEndian: \${Platform.littleEndian()}")
}
}
EOT
- name: Test GC + infra
env:
TEST_COMMAND: >
set sandbox.forBinaryVersion("${{env.binary-version}}")/${{env.set-native-config}};
set testInterface.forBinaryVersion("${{env.binary-version}}")/${{env.set-native-config}};
set junitTestOutputsNative.forBinaryVersion("${{env.binary-version}}")/${{env.set-native-config}};
clean;
test-gc ${{env.binary-version}}
uses: nick-fields/retry@v3
with:
timeout_minutes: 90
max_attempts: 3
retry_on: error
command: ./ci-docker/run-test-gha.sh "scala-native-testing:${{ matrix.arch }}"
- name: Test runtime
env:
# Temporaly excluded due to failures in linux-x86,
# missing __mulodi4 symbol used in j.l.Math.addExact(Long,Long)
# testsExt${{env.project-version}}/test;
SCALANATIVE_TEST_DEBUG_SIGNALS: 1
SCALANATIVE_TEST_PREFETCH_DEBUG_INFO: 1
TEST_COMMAND: >
set tests.forBinaryVersion("${{env.binary-version}}")/${{env.set-native-config}};
set scalaPartestJunitTests.forBinaryVersion("${{env.binary-version}}")/${{env.set-native-config}};
testsJVM${{env.project-version}}/test;
tests${{env.project-version}}/clean;
tests${{env.project-version}}/test;
scalaPartestJunitTests${{env.project-version}}/clean;
scalaPartestJunitTests${{env.project-version}}/test
uses: nick-fields/retry@v3
with:
timeout_minutes: 90
max_attempts: 3
retry_on: error
command: ./ci-docker/run-test-gha.sh "scala-native-testing:${{ matrix.arch }}"