diff --git a/.github/workflows/xmake.yml b/.github/workflows/xmake.yml index 7d229674..f0d424dd 100644 --- a/.github/workflows/xmake.yml +++ b/.github/workflows/xmake.yml @@ -130,7 +130,7 @@ jobs: - name: Xmake configure run: | - xmake config --yes --mode=${{ matrix.build_type }} --toolchain=clang --sdk=/opt/homebrew/opt/llvm@20 + xmake config --yes --ci=y --mode=${{ matrix.build_type }} --toolchain=clang --sdk=/opt/homebrew/opt/llvm@20 - name: Build clice run: | diff --git a/xmake.lua b/xmake.lua index c2138d6e..82d64118 100644 --- a/xmake.lua +++ b/xmake.lua @@ -8,6 +8,7 @@ option("enable_test", {default = true}) option("dev", {default = true}) option("release", {default = false}) option("llvm", {default = nil, description = "Specify pre-compiled llvm binary directory."}) +option("ci", {default = false}) if has_config("dev") then set_policy("compatibility.version", "3.0") @@ -24,7 +25,10 @@ if has_config("dev") then if has_config("enable_test") then add_requires("gtest[main]") --- add_requires("python 3.12.x", {kind = "binary", system = false}) + -- TODO: fix python fetch on mac (from xmake-repo python fetch) + if not (has_config("ci") and is_plat("macosx")) then + add_requires("python >=3.12", {kind = "binary"}) + end end end @@ -117,40 +121,61 @@ target("unit_tests") ) end) --- target("integration_tests") --- set_default(false) --- set_kind("phony") --- --- add_deps("clice") --- add_packages("python", "llvm") --- --- add_tests("default", {run_timeout = 1000 * 10}) --- --- on_test(function (target, opt) --- import("private.action.run.runenvs") --- --- local envs = opt.runenvs --- if not envs then --- local addenvs, setenvs = runenvs.make(target) --- envs = runenvs.join(addenvs, setenvs) --- end --- --- local python = path.join(target:pkg("python"):installdir(), "bin/python") --- os.vrunv(python, {"-m", "pip", "install", "pytest", "pytest-asyncio", "pytest-xdist"}) --- --- os.vcp( --- path.join(target:pkg("llvm"):installdir(), "lib/clang/20"), --- path.join(path.directory(target:targetdir()), "lib/clang/20") --- ) --- --- os.vrunv(python, { --- "-m", "pytest", --- "-s", "tests/integration", --- "--executable=" .. target:dep("clice"):targetfile(), --- }, {envs = envs, timeout = opt.run_timeout, curdir = os.projectdir()}) --- --- return true --- end) +target("integration_tests") + set_default(false) + set_kind("phony") + + add_deps("clice") + add_packages("python", "llvm") + + add_tests("default", {run_timeout = 1000 * 10}) + + on_test(function (target, opt) + import("private.action.run.runenvs") + + local envs = opt.runenvs + if not envs then + local addenvs, setenvs = runenvs.make(target) + envs = runenvs.join(addenvs, setenvs) + end + + os.vcp( + path.join(target:pkg("llvm"):installdir(), "lib/clang/20"), + path.join(path.directory(target:targetdir()), "lib/clang/20") + ) + + if has_config("ci") and is_plat("macosx") then + os.vrun("pip install pytest pytest-asyncio pytest-xdist") + os.vrunv("pytest", { + "-s", "tests/integration", + "--executable=" .. target:dep("clice"):targetfile(), + }, {envs = envs, timeout = opt.run_timeout, curdir = os.projectdir()}) + else + local python + local installdir = target:pkg("python"):installdir() + if installdir then + python = path.join(installdir, "bin/python") + else + python = "python3" + end + + local ok = try { function() + os.vrunv(python, { "-c", "import pytest" }) + return true + end } + if not ok then + os.vrunv(python, {"-m", "pip", "install", "pytest", "pytest-asyncio", "pytest-xdist"}) + end + + os.vrunv(python, { + "-m", "pytest", + "-s", "tests/integration", + "--executable=" .. target:dep("clice"):targetfile(), + }, {envs = envs, timeout = opt.run_timeout, curdir = os.projectdir()}) + end + + return true + end) rule("clice_build_config") on_load(function (target)