diff --git a/.cirrus.yml b/.cirrus.yml index 967fa43..af5b4b0 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,18 +1,23 @@ -freebsd_instance: - image: freebsd-12-2-release-amd64 +#task: +# name: Julia on FreeBSD +# freebsd_instance: +# image: freebsd-12-2-release-amd64 +# env: +# matrix: +# - JULIA_VERSION: 1.6 +# - JULIA_VERSION: 1 +# - JULIA_VERSION: nightly +# allow_failures: $JULIA_VERSION == 'nightly' +# install_script: +# - sh bin/install.sh +# build_script: +# - cirrusjl build +# test_script: +# - cirrusjl test +# coverage_script: +# - cirrusjl coverage codecov coveralls task: - name: FreeBSD - env: - matrix: - - JULIA_VERSION: 1.6 - - JULIA_VERSION: 1 - - JULIA_VERSION: nightly - allow_failures: $JULIA_VERSION == 'nightly' - install_script: - - sh bin/install.sh - build_script: - - cirrusjl build - test_script: - - cirrusjl test - coverage_script: - - cirrusjl coverage codecov coveralls + name: Starlark setup + container: + image: gcr.io/cirrus-ci-community/cirrus-cli:latest + script: cirrus internal test diff --git a/lib.star b/lib.star new file mode 100644 index 0000000..dc60481 --- /dev/null +++ b/lib.star @@ -0,0 +1,51 @@ +load("cirrus", environ="env") +load("github.com/cirrus-modules/helpers", "powershell", "script", "task") + +def _os_from_instance(instance): + # Instances are `dict`s formatted as `{ type: descriptors }` where `type` is + # one of Cirrus' predefined execution environment names + if instance.get("container") or instance.get("arm_container"): + return "Linux" + elif instance.get("macos_instance"): + return "macOS" + elif instance.get("freebsd_instance"): + return "FreeBSD" + elif instance.get("windows_container"): + return "Windows" + else: + return "Unknown OS" + +def cirrusjl_install(os): + base = "https://raw.githubusercontent.com/ararslan/CirrusCI.jl/master/bin" + if os == "Windows": + file = base + "/install.ps1" + cmd = "iex ((New-Object System.Net.WebClient).DownloadString('%s'))" % file + return powershell("install", cmd) + file = base + "/install.sh" + if os == "macOS": + download = "curl " + file + elif os == "FreeBSD": + download = "fetch %s -o -" % file + else: + download = "wget %s -q -O-" % file + cmd = "sh -c \"$(%s)\"" % download + return script("install", cmd) + +def julia_instructions(os, coverage=None): + steps = [cirrusjl_install(os), + script("build", "cirrusjl build"), + script("test", "cirrusjl test")] + if coverage: + steps.append(script("coverage", "cirrusjl coverage %s" % coverage)) + return steps + +def julia_tasks(versions, instances, env={}, coverage=None, allow_failures=None): + tasks = [] + for instance in instances: + os = _os_from_instance(instance) + instructions = julia_instructions(os, coverage=coverage) + for version in versions: + v = {"JULIA_VERSION": version}.update(env) + t = task(name=os, instance=instance, instructions=instructions, env=v) + tasks.append(t) + return tasks diff --git a/test/cirrusjl_install/.cirrus.expected.yml b/test/cirrusjl_install/.cirrus.expected.yml new file mode 100644 index 0000000..8270934 --- /dev/null +++ b/test/cirrusjl_install/.cirrus.expected.yml @@ -0,0 +1,34 @@ +task: + name: FreeBSD + freebsd_instance: + image_family: freebsd-13-0 + install_script: + - sh -c "$(fetch https://raw.githubusercontent.com/ararslan/CirrusCI.jl/master/bin/install.sh -o -)" +task: + name: Linux AArch64 + arm_container: + image: ubuntu:latest + cpu: 2 + memory: 4096 + install_script: + - sh -c "$(wget https://raw.githubusercontent.com/ararslan/CirrusCI.jl/master/bin/install.sh -q -O-)" +task: + name: Linux musl + container: + image: alpine:3.14 + cpu: 2 + memory: 4096 + install_script: + - sh -c "$(wget https://raw.githubusercontent.com/ararslan/CirrusCI.jl/master/bin/install.sh -q -O-)" +task: + name: Windows + windows_container: + image: cirrusci/windowsservercore + install_script: + - ps: iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/ararslan/CirrusCI.jl/master/bin/install.ps1')) +task: + name: macOS + macos_instance: + image: big-sur-xcode + install_script: + - sh -c "$(curl https://raw.githubusercontent.com/ararslan/CirrusCI.jl/master/bin/install.sh)" diff --git a/test/cirrusjl_install/.cirrus.star b/test/cirrusjl_install/.cirrus.star new file mode 100644 index 0000000..c21279d --- /dev/null +++ b/test/cirrusjl_install/.cirrus.star @@ -0,0 +1,14 @@ +load("../../lib.star", "cirrusjl_install") +load("github.com/cirrus-modules/helpers", "task", "windows_container", "freebsd_instance", + "macos_instance", "container", "arm_container") + +def _task(name, instance): + os = name.split(" ")[0] + return task(name, instance, instructions=[cirrusjl_install(os)]) + +def main(ctx): + return [_task("FreeBSD", freebsd_instance("freebsd-13-0")), + _task("Linux AArch64", arm_container("ubuntu:latest")), + _task("Linux musl", container("alpine:3.14")), + _task("Windows", windows_container("cirrusci/windowsservercore")), + _task("macOS", macos_instance("big-sur-xcode"))] diff --git a/test/julia_instructions/.cirrus.expected.yml b/test/julia_instructions/.cirrus.expected.yml new file mode 100644 index 0000000..996455e --- /dev/null +++ b/test/julia_instructions/.cirrus.expected.yml @@ -0,0 +1,22 @@ +task: + name: No coverage + freebsd_instance: + image_family: freebsd-13-0 + install_script: + - sh -c "$(fetch https://raw.githubusercontent.com/ararslan/CirrusCI.jl/master/bin/install.sh -o -)" + build_script: + - cirrusjl build + test_script: + - cirrusjl test +task: + name: Codecov + freebsd_instance: + image_family: freebsd-13-0 + install_script: + - sh -c "$(fetch https://raw.githubusercontent.com/ararslan/CirrusCI.jl/master/bin/install.sh -o -)" + build_script: + - cirrusjl build + test_script: + - cirrusjl test + coverage_script: + - cirrusjl coverage codecov diff --git a/test/julia_instructions/.cirrus.star b/test/julia_instructions/.cirrus.star new file mode 100644 index 0000000..f171954 --- /dev/null +++ b/test/julia_instructions/.cirrus.star @@ -0,0 +1,8 @@ +load("../../lib.star", "julia_instructions") +load("github.com/cirrus-modules/helpers", "task", "freebsd_instance") + +def main(ctx): + return [task("No coverage", freebsd_instance("freebsd-13-0"), + instructions=julia_instructions("FreeBSD")), + task("Codecov", freebsd_instance("freebsd-13-0"), + instructions=julia_instructions("FreeBSD", coverage="codecov"))]