mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 20:55:50 +00:00
Compare commits
4 Commits
v7.7.0-rc.
...
plugin-tes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47db569c52 | ||
|
|
1d3f8c8e9d | ||
|
|
a894313a4b | ||
|
|
7f73ae80dc |
21
.github/workflows/ci.yml
vendored
21
.github/workflows/ci.yml
vendored
@@ -83,6 +83,27 @@ jobs:
|
|||||||
target
|
target
|
||||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
|
test-plugin:
|
||||||
|
name: Test Plugin
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
|
||||||
|
- name: Setup Rokit
|
||||||
|
uses: CompeyDev/setup-rokit@v0.1.2
|
||||||
|
with:
|
||||||
|
version: 'v1.1.0'
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: lune run test-plugin
|
||||||
|
env:
|
||||||
|
RBX_API_KEY: ${{ secrets.PLUGIN_TEST_API_KEY }}
|
||||||
|
RBX_UNIVERSE_ID: ${{ vars.PLUGIN_TEST_UNIVERSE_ID }}
|
||||||
|
RBX_PLACE_ID: ${{ vars.PLUGIN_TEST_PLACE_ID }}
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
name: Rustfmt, Clippy, Stylua, & Selene
|
name: Rustfmt, Clippy, Stylua, & Selene
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -16,3 +16,6 @@
|
|||||||
[submodule "plugin/Packages/Highlighter"]
|
[submodule "plugin/Packages/Highlighter"]
|
||||||
path = plugin/Packages/Highlighter
|
path = plugin/Packages/Highlighter
|
||||||
url = https://github.com/boatbomber/highlighter.git
|
url = https://github.com/boatbomber/highlighter.git
|
||||||
|
[submodule ".lune/opencloud-execute"]
|
||||||
|
path = .lune/opencloud-execute
|
||||||
|
url = https://github.com/Dekkonot/opencloud-luau-execute-lune.git
|
||||||
|
|||||||
5
.lune/.luaurc
Normal file
5
.lune/.luaurc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"aliases": {
|
||||||
|
"lune": "~/.lune/.typedefs/0.10.2/"
|
||||||
|
}
|
||||||
|
}
|
||||||
1
.lune/opencloud-execute
Submodule
1
.lune/opencloud-execute
Submodule
Submodule .lune/opencloud-execute added at 8ae86dd3ad
112
.lune/test-plugin.luau
Normal file
112
.lune/test-plugin.luau
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
local serde = require("@lune/serde")
|
||||||
|
local net = require("@lune/net")
|
||||||
|
local stdio = require("@lune/stdio")
|
||||||
|
local process = require("@lune/process")
|
||||||
|
local fs = require("@lune/fs")
|
||||||
|
|
||||||
|
local luau_execute = require("./opencloud-execute")
|
||||||
|
|
||||||
|
local TEST_SCRIPT = fs.readFile("plugin/run-tests.server.lua")
|
||||||
|
|
||||||
|
local PATH_VERSION_MATCH = "assets/%d+/versions/(.+)"
|
||||||
|
|
||||||
|
local UNIVERSE_ID = process.env["RBX_UNIVERSE_ID"]
|
||||||
|
local PLACE_ID = process.env["RBX_PLACE_ID"]
|
||||||
|
local API_KEY = process.env["RBX_API_KEY"]
|
||||||
|
|
||||||
|
if not UNIVERSE_ID then
|
||||||
|
error("no universe ID specified. try providing one with the env var `RBX_UNIVERSE_ID`")
|
||||||
|
end
|
||||||
|
if not PLACE_ID then
|
||||||
|
error("no place ID specified. try providing one with the env var `RBX_PLACE_ID`")
|
||||||
|
end
|
||||||
|
if not API_KEY then
|
||||||
|
error("no API key specified. try providing one with the env var `RBX_API_KEY`")
|
||||||
|
end
|
||||||
|
|
||||||
|
--stylua: ignore
|
||||||
|
local upload_result = process.exec("cargo", {
|
||||||
|
"run", "--",
|
||||||
|
"upload", "plugin/test-place.project.json",
|
||||||
|
"--api_key", API_KEY,
|
||||||
|
"--universe_id", UNIVERSE_ID,
|
||||||
|
"--asset_id", PLACE_ID
|
||||||
|
}, {
|
||||||
|
stdio = "none"
|
||||||
|
})
|
||||||
|
|
||||||
|
if not upload_result.ok then
|
||||||
|
print("Failed to upload plugin test place")
|
||||||
|
print("Not dumping stdout or stderr to avoid leaking secrets")
|
||||||
|
process.exit(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- This is /probably/ not necessary because Rojo generally does not have enough
|
||||||
|
-- activity that there will be multiple CI runs happening at once, but
|
||||||
|
-- it's better safe than sorry.
|
||||||
|
local version_response = net.request({
|
||||||
|
method = "GET",
|
||||||
|
url = `https://apis.roblox.com/assets/v1/assets/{PLACE_ID}/versions`,
|
||||||
|
query = {
|
||||||
|
maxPageSize = 1,
|
||||||
|
},
|
||||||
|
headers = {
|
||||||
|
["User-Agent"] = `Rojo/PluginTesting 1.0.0; {_VERSION}`,
|
||||||
|
["x-api-key"] = API_KEY,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if not version_response.ok then
|
||||||
|
error(
|
||||||
|
`Failed to fetch version of Roblox place to run tests on because: {version_response.statusCode} - {version_response.statusMessage}\n{version_response.body}`
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
local place_version_raw = serde.decode("json", version_response.body).assetVersions[1].path
|
||||||
|
assert(typeof(place_version_raw) == "string", "the result from asset version endpoint was not as expected")
|
||||||
|
|
||||||
|
local place_version = string.match(place_version_raw, PATH_VERSION_MATCH)
|
||||||
|
|
||||||
|
local task = luau_execute.create_task_versioned(UNIVERSE_ID, PLACE_ID, place_version, TEST_SCRIPT)
|
||||||
|
print(`Running test script on {UNIVERSE_ID}/{PLACE_ID}@{place_version}`)
|
||||||
|
print(`Task ID: {luau_execute.task_id(task)}`)
|
||||||
|
|
||||||
|
luau_execute.await_finish(task)
|
||||||
|
print("Output from task:\n")
|
||||||
|
local logs = luau_execute.get_structured_logs(task)
|
||||||
|
for _, log in logs do
|
||||||
|
if log.messageType == "OUTPUT" or log.messageType == "MESSAGE_TYPE_UNSPECIFIED" then
|
||||||
|
stdio.write(stdio.color("reset"))
|
||||||
|
elseif log.messageType == "INFO" then
|
||||||
|
stdio.write(stdio.color("cyan"))
|
||||||
|
elseif log.messageType == "WARNING" then
|
||||||
|
stdio.write(stdio.color("yellow"))
|
||||||
|
elseif log.messageType == "ERROR" then
|
||||||
|
stdio.write(stdio.color("red"))
|
||||||
|
end
|
||||||
|
stdio.write(log.message)
|
||||||
|
stdio.write(`{stdio.color("reset")}\n`)
|
||||||
|
end
|
||||||
|
|
||||||
|
local results = luau_execute.get_output(task)[1]
|
||||||
|
if not results then
|
||||||
|
error("plugin tests did not return any results")
|
||||||
|
end
|
||||||
|
|
||||||
|
local status = luau_execute.check_status(task)
|
||||||
|
if status == "COMPLETE" then
|
||||||
|
if results.failureCount == 0 then
|
||||||
|
process.exit(0)
|
||||||
|
else
|
||||||
|
process.exit(1)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
print()
|
||||||
|
print("Task did not finish successfully")
|
||||||
|
local err = luau_execute.get_error(task)
|
||||||
|
if err then
|
||||||
|
print(`Error from task: {err.code}`)
|
||||||
|
print(err.message)
|
||||||
|
end
|
||||||
|
process.exit(1)
|
||||||
|
end
|
||||||
@@ -8,4 +8,12 @@ local Settings = require(Rojo.Plugin.Settings)
|
|||||||
Settings:set("logLevel", "Trace")
|
Settings:set("logLevel", "Trace")
|
||||||
Settings:set("typecheckingEnabled", true)
|
Settings:set("typecheckingEnabled", true)
|
||||||
|
|
||||||
require(Rojo.Plugin.runTests)(TestEZ)
|
local results = require(Rojo.Plugin.runTests)(TestEZ)
|
||||||
|
|
||||||
|
-- Roblox's Luau execution gets mad about cyclical tables.
|
||||||
|
-- Rather than making TestEZ not do that, we just send back the important info.
|
||||||
|
return {
|
||||||
|
failureCount = results.failureCount,
|
||||||
|
successCount = results.successCount,
|
||||||
|
skippedCount = results.skippedCount,
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ return function(TestEZ)
|
|||||||
local Rojo = script.Parent.Parent
|
local Rojo = script.Parent.Parent
|
||||||
local Packages = Rojo.Packages
|
local Packages = Rojo.Packages
|
||||||
|
|
||||||
TestEZ.TestBootstrap:run({ Rojo.Plugin, Packages.Http, Packages.Log, Packages.RbxDom })
|
return TestEZ.TestBootstrap:run({ Rojo.Plugin, Packages.Http, Packages.Log, Packages.RbxDom })
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,3 +3,4 @@ rojo = "rojo-rbx/rojo@7.5.1"
|
|||||||
selene = "Kampfkarren/selene@0.29.0"
|
selene = "Kampfkarren/selene@0.29.0"
|
||||||
stylua = "JohnnyMorganz/stylua@2.1.0"
|
stylua = "JohnnyMorganz/stylua@2.1.0"
|
||||||
run-in-roblox = "rojo-rbx/run-in-roblox@0.3.0"
|
run-in-roblox = "rojo-rbx/run-in-roblox@0.3.0"
|
||||||
|
lune = "lune-org/lune@0.10.2"
|
||||||
|
|||||||
Reference in New Issue
Block a user