local U=require("\064\108\117\110\101\047\112\114\111\099\101\115\115")local d=require("\046\047\108\105\098\047\099\111\109\112\105\108\101")local N=require("\046\047\108\105\098\047\112\097\114\115\101\065\114\103\115")local C=require("\046\046\047\112\114\111\106\101\099\116")local T=require("\046\047\108\105\098\047\114\117\110")local I=N(U.args)local X=assert(I.apiKey,"--\097\112\105\075\101\121 \109\117\115\116 \098\101 \115\117\112\112\108\105\101\100 \119\105\116\104 \097 \118\097\108\105\100 \079\112\101\110 \067\108\111\117\100 \065\080\073 \107\101\121")local t="\116\101\115\116-\112\108\097\099\101\046\114\098\120\108"d("\100\101\118")T("\114\111\106\111",{"\098\117\105\108\100";C.ROJO_TESTS_PROJECT;"-\111",t})local E,u=T("\112\121\116\104\111\110\051",{"\046\108\117\110\101\047\111\112\101\110-\099\108\111\117\100\047\117\112\108\111\097\100\095\097\110\100\095\114\117\110\095\116\097\115\107\046\112\121";t;"\116\101\115\116\115\047\114\117\110-\116\101\115\116\115\046\108\117\097\117"},{env={ROBLOX_UNIVERSE_ID="\054\053\057\057\049\048\048\049\053\054";ROBLOX_PLACE_ID="\049\050\051\053\048\054\049\057\048\055\050\053\055\055\049";ROBLOX_API_KEY=X}})T("\114\109",{t})if not u then print(E)U.exit(1)end
local process = require("@lune/process")

local compile = require("./lib/compile")
local parseArgs = require("./lib/parseArgs")
local project = require("../project")
local run = require("./lib/run")

local args = parseArgs(process.args)
local apiKey = assert(args.apiKey, "--apiKey must be supplied with a valid Open Cloud API key")

local testPlaceFile = "test-place.rbxl"

compile("dev")
run("rojo", { "build", project.ROJO_TESTS_PROJECT, "-o", testPlaceFile })

local output, success = run("python3", {
	".lune/open-cloud/upload_and_run_task.py",
	testPlaceFile,
	"tests/run-tests.luau",
}, {
	env = {
		ROBLOX_UNIVERSE_ID = "6599100156",
		ROBLOX_PLACE_ID = "123506190725771",
		ROBLOX_API_KEY = apiKey,
	},
})

run("rm", { testPlaceFile })

if not success then
	print(output)
	process.exit(1)
end
