mirror of
https://github.com/pesde-pkg/tooling.git
synced 2025-05-04 10:43:58 +01:00
Merge f09a1149ad
into 865bfe1859
This commit is contained in:
commit
df2df77a8e
24 changed files with 493 additions and 221 deletions
45
.github/workflows/update-tools.yml
vendored
Normal file
45
.github/workflows/update-tools.yml
vendored
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
name: Daily Update Manifests
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-manifests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup pesde
|
||||||
|
uses: lumin-org/setup-pesde@v0.4.1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
- name: Install packages
|
||||||
|
run: pesde install
|
||||||
|
timeout-minutes: 1 # sometimes the install just hangs infinitely, so you won't want spent 12 hours of ci credit for nothing :sob:
|
||||||
|
|
||||||
|
- name: Set up Git
|
||||||
|
run: |
|
||||||
|
git config --global user.name 'github-actions[bot]'
|
||||||
|
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
||||||
|
|
||||||
|
- name: Apply updates
|
||||||
|
run: lune run .lune/update_tools -- --yes
|
||||||
|
|
||||||
|
- name: Publish updates
|
||||||
|
run: pesde publish
|
||||||
|
|
||||||
|
- name: Commit and push changes
|
||||||
|
run: |
|
||||||
|
if [[ -n "$(git status --porcelain)" ]]; then
|
||||||
|
git add .
|
||||||
|
git commit -m "chore: daily manifest update [skip ci]"
|
||||||
|
git push
|
||||||
|
else
|
||||||
|
echo "No changes to commit."
|
||||||
|
fi
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
||||||
**/*_packages/
|
**/*_packages/
|
||||||
toolchainlib/pesde.lock
|
toolchainlib/pesde.lock
|
||||||
|
|
||||||
|
**/tests/output/**
|
||||||
|
|
|
@ -1,221 +1,240 @@
|
||||||
--> Updates tooling bin versions and READMEs
|
--> Updates tooling bin versions and READMEs
|
||||||
|
|
||||||
local serde = require("@lune/serde")
|
local serde = require("@lune/serde")
|
||||||
local stdio = require("@lune/stdio")
|
local stdio = require("@lune/stdio")
|
||||||
local process = require("@lune/process")
|
local process = require("@lune/process")
|
||||||
local DateTime = require("@lune/datetime")
|
local DateTime = require("@lune/datetime")
|
||||||
|
|
||||||
local pathfs = require("../lune_packages/pathfs")
|
local pathfs = require("../lune_packages/pathfs")
|
||||||
local base64 = require("../lune_packages/base64")
|
local base64 = require("../lune_packages/base64")
|
||||||
|
|
||||||
local manifestTypes = require("../toolchainlib/src/manifest")
|
local manifestTypes = require("../toolchainlib/src/manifest")
|
||||||
local Result = require("../lune_packages/result")
|
local Result = require("../lune_packages/result")
|
||||||
local Option = require("../lune_packages/option")
|
local Option = require("../lune_packages/option")
|
||||||
type Result<T, E> = Result.Result<T, E>
|
type Result<T, E> = Result.Result<T, E>
|
||||||
type Option<T> = Option.Option<T>
|
type Option<T> = Option.Option<T>
|
||||||
|
|
||||||
local Github = require("../toolchainlib/src/github")
|
local Github = require("../toolchainlib/src/github")
|
||||||
|
|
||||||
type GithubContents = {
|
type GithubContents = {
|
||||||
name: string,
|
name: string,
|
||||||
path: string,
|
path: string,
|
||||||
sha: string,
|
sha: string,
|
||||||
size: number,
|
size: number,
|
||||||
url: string,
|
url: string,
|
||||||
html_url: string,
|
html_url: string,
|
||||||
git_url: string,
|
git_url: string,
|
||||||
download_url: string,
|
download_url: string,
|
||||||
type: "file" | "dir" | "symlink",
|
type: "file" | "dir" | "symlink",
|
||||||
content: string,
|
content: string,
|
||||||
encoding: "base64",
|
encoding: "base64",
|
||||||
_links: {
|
_links: {
|
||||||
self: string,
|
self: string,
|
||||||
git: string,
|
git: string,
|
||||||
html: string,
|
html: string,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local function isoDateToTimestamp(isoDate: string): number
|
local function isoDateToTimestamp(isoDate: string): number
|
||||||
return DateTime.fromIsoDate(isoDate).unixTimestamp
|
return DateTime.fromIsoDate(isoDate).unixTimestamp
|
||||||
end
|
end
|
||||||
|
|
||||||
local function stripLeadingVersion(version: string): string
|
local function stripLeadingVersion(version: string): string
|
||||||
local stripped = string.gsub(version, "^v", "")
|
local stripped = string.gsub(version, "^v", "")
|
||||||
return stripped
|
return stripped
|
||||||
end
|
end
|
||||||
|
|
||||||
local function confirmAndClear(msg: string, default: boolean?): boolean
|
local function confirmAndClear(msg: string, default: boolean?): boolean
|
||||||
local yes = stdio.prompt("confirm", msg, default)
|
local yes = stdio.prompt("confirm", msg, default)
|
||||||
stdio.write(
|
stdio.write(
|
||||||
-- Move to the previous line, clear it, move cursor to start of line,
|
-- Move to the previous line, clear it, move cursor to start of line,
|
||||||
-- and show cursor (if hidden)
|
-- and show cursor (if hidden)
|
||||||
"\x1b[A\x1b[K\x1b[0G\x1b[?25h"
|
"\x1b[A\x1b[K\x1b[0G\x1b[?25h"
|
||||||
)
|
)
|
||||||
|
|
||||||
return yes
|
return yes
|
||||||
end
|
end
|
||||||
|
|
||||||
local INFO_PREFIX = `{stdio.color("green")}{stdio.style("bold")}info{stdio.color("reset")}:`
|
local INFO_PREFIX = `{stdio.color("green")}{stdio.style("bold")}info{stdio.color("reset")}:`
|
||||||
local WARN_PREFIX = `{stdio.color("yellow")}{stdio.style("bold")}warn{stdio.color("reset")}:`
|
local WARN_PREFIX = `{stdio.color("yellow")}{stdio.style("bold")}warn{stdio.color("reset")}:`
|
||||||
local ERROR_PREFIX = `{stdio.color("red")}{stdio.style("bold")}error{stdio.color("reset")}:`
|
local ERROR_PREFIX = `{stdio.color("red")}{stdio.style("bold")}error{stdio.color("reset")}:`
|
||||||
|
|
||||||
local function warn(...)
|
local function warn(...)
|
||||||
stdio.ewrite(`{WARN_PREFIX} {stdio.format(...)}\n`)
|
stdio.ewrite(`{WARN_PREFIX} {stdio.format(...)}\n`)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function error(msg: string): never
|
local function error(msg: string): never
|
||||||
stdio.ewrite(`{ERROR_PREFIX} {msg}\n`)
|
stdio.ewrite(`{ERROR_PREFIX} {msg}\n`)
|
||||||
return process.exit(1)
|
return process.exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function assert(expr: boolean, msg: string)
|
local function assert(expr: boolean, msg: string)
|
||||||
if not expr then
|
if not expr then
|
||||||
error(msg)
|
error(msg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local START_TIME = os.clock()
|
local START_TIME = os.clock()
|
||||||
local BINS_SRC_DIR = pathfs.getAbsolutePathOf(pathfs.Path.from("bins"))
|
local BINS_SRC_DIR = pathfs.getAbsolutePathOf(pathfs.Path.from("bins"))
|
||||||
|
|
||||||
for _, binSrc in pathfs.readDir(BINS_SRC_DIR) do
|
for _, binSrc in pathfs.readDir(BINS_SRC_DIR) do
|
||||||
local absPath = BINS_SRC_DIR:join(binSrc)
|
local absPath = BINS_SRC_DIR:join(binSrc)
|
||||||
local binEntrypoint = absPath:join("init.luau")
|
local testsPath = absPath:join("tests/run.luau")
|
||||||
local manifestPath = absPath:join("pesde.toml")
|
local binEntrypoint = absPath:join("init.luau")
|
||||||
local readmePath = absPath:join("README.md")
|
local manifestPath = absPath:join("pesde.toml")
|
||||||
|
local readmePath = absPath:join("README.md")
|
||||||
-- Make sure our constructed entrypoint and manifest paths exist
|
|
||||||
assert(
|
-- Make sure our constructed entrypoint and manifest paths exist
|
||||||
pathfs.isFile(binEntrypoint) and pathfs.isFile(manifestPath),
|
assert(
|
||||||
"Either binary entrypoint or manifest not found"
|
pathfs.isFile(binEntrypoint) and pathfs.isFile(manifestPath),
|
||||||
)
|
"Either binary entrypoint or manifest not found"
|
||||||
|
)
|
||||||
local manifestContents = pathfs.readFile(manifestPath)
|
|
||||||
local manifest: manifestTypes.PesdeManifest = serde.decode("toml", manifestContents)
|
local manifestContents = pathfs.readFile(manifestPath)
|
||||||
local entrypointContents = pathfs.readFile(binEntrypoint)
|
local manifest: manifestTypes.PesdeManifest = serde.decode("toml", manifestContents)
|
||||||
|
local entrypointContents = pathfs.readFile(binEntrypoint)
|
||||||
local repoName = string.match(entrypointContents, 'require%("./lune_packages/core"%)%("([^"]+)"')
|
|
||||||
local version = manifest.version
|
local repoName = string.match(entrypointContents, 'require%("./lune_packages/core"%)%("([^"]+)"')
|
||||||
|
local version = manifest.version
|
||||||
-- Make sure we have a repo name and version
|
|
||||||
assert(repoName ~= nil, `Failed to get repo name for tool {binSrc}`)
|
-- Make sure we have a repo name and version
|
||||||
|
assert(repoName ~= nil, `Failed to get repo name for tool {binSrc}`)
|
||||||
local gh = Github.new(
|
|
||||||
repoName :: string,
|
local gh = Github.new(
|
||||||
Option.Some({
|
repoName :: string,
|
||||||
authToken = Option.from(process.env.GITHUB_TOKEN) :: Option<string>,
|
Option.Some({
|
||||||
retries = Option.None :: Option<number>,
|
authToken = Option.from(process.env.GITHUB_TOKEN) :: Option<string>,
|
||||||
} :: Github.Config) :: Option<Github.Config>
|
retries = Option.None :: Option<number>,
|
||||||
)
|
} :: Github.Config) :: Option<Github.Config>
|
||||||
local transactions = gh:queueTransactions({ "FetchReleases" })
|
)
|
||||||
|
local transactions = gh:queueTransactions({ "FetchReleases" })
|
||||||
-- Fetch releases, and order them by published date
|
|
||||||
local releases = transactions[1]:unwrap() :: Github.GithubReleases
|
-- Fetch releases, and order them by published date
|
||||||
table.sort(releases, function(a, b)
|
local releases = transactions[1]:unwrap() :: Github.GithubReleases
|
||||||
return isoDateToTimestamp(a.published_at) < isoDateToTimestamp(b.published_at)
|
table.sort(releases, function(a, b)
|
||||||
end)
|
return isoDateToTimestamp(a.published_at) < isoDateToTimestamp(b.published_at)
|
||||||
|
end)
|
||||||
-- Filter for only versions which are after the current version
|
|
||||||
local releasesAfter = {}
|
-- Filter for only versions which are after the current version
|
||||||
local versionIdx = math.huge
|
local releasesAfter = {}
|
||||||
for idx, release in releases do
|
local versionIdx = math.huge
|
||||||
if stripLeadingVersion(release.tag_name) == version then
|
for idx, release in releases do
|
||||||
versionIdx = idx
|
if stripLeadingVersion(release.tag_name) == version then
|
||||||
continue
|
versionIdx = idx
|
||||||
end
|
continue
|
||||||
|
end
|
||||||
if idx > versionIdx then
|
|
||||||
releasesAfter[release.tag_name] = release
|
if idx > versionIdx then
|
||||||
end
|
releasesAfter[release.tag_name] = release
|
||||||
end
|
end
|
||||||
|
end
|
||||||
for newVersion, newRelease in releasesAfter do
|
|
||||||
print(
|
for newVersion, newRelease in releasesAfter do
|
||||||
`{INFO_PREFIX} Found new tool release {stdio.style("bold")}{binSrc}{stdio.style("reset")}@{stdio.style(
|
print(
|
||||||
"dim"
|
`{INFO_PREFIX} Found new tool release {stdio.style("bold")}{binSrc}{stdio.style("reset")}@{stdio.style(
|
||||||
)}{newVersion}{stdio.style("reset")}`
|
"dim"
|
||||||
)
|
)}{newVersion}{stdio.style("reset")}`
|
||||||
|
)
|
||||||
-- HACK: To prevent messing with our existing toml ordering and formatting
|
|
||||||
-- we just replace the old version field string with the new version field
|
-- Check if the tool has any tests, and run them if they do
|
||||||
-- string
|
if pathfs.isFile(testsPath) then
|
||||||
|
local success, result = pcall(require, testsPath:toString())
|
||||||
-- the string returned by serde.encode end with newlines, so remove them to maintain compatibility with different line endings
|
if not success then
|
||||||
-- Old version field string:
|
continue
|
||||||
local oldField = string.gsub(serde.encode("toml", { version = manifest.version }), "%s+$", "")
|
end
|
||||||
|
|
||||||
-- New version field string:
|
success, result = pcall(result, newVersion)
|
||||||
local newField = string.gsub(serde.encode("toml", { version = stripLeadingVersion(newVersion) }), "%s+$", "")
|
if not success then
|
||||||
|
continue
|
||||||
local updatedManifest = string.gsub(
|
end
|
||||||
manifestContents,
|
else
|
||||||
oldField,
|
warn(`Unit tests not found for {binSrc}, assuming that they pass`)
|
||||||
newField,
|
end
|
||||||
-- Only replace the first occurrence to be safe
|
|
||||||
1
|
-- HACK: To prevent messing with our existing toml ordering and formatting
|
||||||
)
|
-- we just replace the old version field string with the new version field
|
||||||
|
-- string
|
||||||
local toWrite = table.find(process.args, "--yes")
|
|
||||||
or table.find(process.args, "-y")
|
-- the string returned by serde.encode end with newlines, so remove them to maintain compatibility with different line endings
|
||||||
or confirmAndClear(`Update manifest for {binSrc}?`, false)
|
-- Old version field string:
|
||||||
|
local oldField = string.gsub(serde.encode("toml", { version = manifest.version }), "%s+$", "")
|
||||||
if toWrite then
|
|
||||||
print(
|
-- New version field string:
|
||||||
`{INFO_PREFIX} Updated manifest {stdio.style("dim")}{manifestPath:stripPrefix(pathfs.cwd)}{stdio.style(
|
local newField = string.gsub(serde.encode("toml", { version = stripLeadingVersion(newVersion) }), "%s+$", "")
|
||||||
"reset"
|
|
||||||
)}`
|
local updatedManifest, replaces = string.gsub(
|
||||||
)
|
manifestContents,
|
||||||
|
string.gsub(oldField, "[%.%+%-]", "%%%0"),
|
||||||
pathfs.writeFile(manifestPath, updatedManifest)
|
newField,
|
||||||
end
|
-- Only replace the first occurrence to be safe
|
||||||
end
|
1
|
||||||
|
)
|
||||||
-- Fetch README for the tool repo, if present
|
if replaces == 0 then
|
||||||
transactions = gh:queueTransactions({
|
error("failed to replace version field in manifest")
|
||||||
{
|
end
|
||||||
type = "Custom",
|
|
||||||
payload = {
|
local toWrite = table.find(process.args, "--yes")
|
||||||
method = "GET",
|
or table.find(process.args, "-y")
|
||||||
url = `https://api.github.com/repos/{repoName}/readme`,
|
or confirmAndClear(`Update manifest for {binSrc}?`, false)
|
||||||
},
|
|
||||||
},
|
if toWrite then
|
||||||
})
|
print(
|
||||||
|
`{INFO_PREFIX} Updated manifest {stdio.style("dim")}{manifestPath:stripPrefix(pathfs.cwd)}{stdio.style(
|
||||||
local contentsResp = transactions[1] :: Result<GithubContents, string>
|
"reset"
|
||||||
|
)}`
|
||||||
local readmeRes = contentsResp:andThen(function(resp: GithubContents)
|
)
|
||||||
-- If there was not an error, and the contents are base64 encoded,
|
|
||||||
-- we decode the contents and return the decoded buffer
|
pathfs.writeFile(manifestPath, updatedManifest)
|
||||||
if resp.encoding == "base64" then
|
end
|
||||||
-- NOTE: Github uses a special format for encoding the contents, where it
|
end
|
||||||
-- separates the entire file into multiple lines, and encodes each line in
|
|
||||||
-- base64
|
-- Fetch README for the tool repo, if present
|
||||||
|
transactions = gh:queueTransactions({
|
||||||
-- This should be done by the base64 library, but oh well
|
{
|
||||||
local content = string.gsub(resp.content, "%s+", "")
|
type = "Custom",
|
||||||
local decoded = base64.decode(buffer.fromstring(content))
|
payload = {
|
||||||
return Result.Ok(decoded)
|
method = "GET",
|
||||||
end
|
url = `https://api.github.com/repos/{repoName}/readme`,
|
||||||
|
},
|
||||||
return Result.Err(`Unsupported encoding: {resp.encoding}`)
|
},
|
||||||
end)
|
})
|
||||||
|
|
||||||
-- NOTE: Ideally this block should be a match, but I cannot make use of
|
local contentsResp = transactions[1] :: Result<GithubContents, string>
|
||||||
-- control flow expressions from within a function
|
|
||||||
if readmeRes:isErr() then
|
local readmeRes = contentsResp:andThen(function(resp: GithubContents)
|
||||||
warn(`Failed to fetch README from tool repo {repoName}:`, readmeRes:unwrapErr())
|
-- If there was not an error, and the contents are base64 encoded,
|
||||||
continue
|
-- we decode the contents and return the decoded buffer
|
||||||
end
|
if resp.encoding == "base64" then
|
||||||
|
-- NOTE: Github uses a special format for encoding the contents, where it
|
||||||
-- Write the updated README to the tool's directory
|
-- separates the entire file into multiple lines, and encodes each line in
|
||||||
local readmeContents = readmeRes:unwrap()
|
-- base64
|
||||||
-- There used to be some issues with encoding if not deleted and recreated
|
|
||||||
pathfs.removeFile(readmePath)
|
-- This should be done by the base64 library, but oh well
|
||||||
pathfs.writeFile(readmePath, readmeContents)
|
local content = string.gsub(resp.content, "%s+", "")
|
||||||
|
local decoded = base64.decode(buffer.fromstring(content))
|
||||||
print(
|
return Result.Ok(decoded)
|
||||||
`{INFO_PREFIX} Wrote README to {stdio.style("dim")}{readmePath:stripPrefix(pathfs.cwd)}{stdio.style("reset")}`
|
end
|
||||||
)
|
|
||||||
end
|
return Result.Err(`Unsupported encoding: {resp.encoding}`)
|
||||||
|
end)
|
||||||
local timeElapsed = string.format("%.2fs", os.clock() - START_TIME)
|
|
||||||
print(`{INFO_PREFIX} Finished checking for tool updates in {stdio.style("dim")}{timeElapsed}{stdio.style("reset")}!`)
|
-- NOTE: Ideally this block should be a match, but I cannot make use of
|
||||||
|
-- control flow expressions from within a function
|
||||||
|
if readmeRes:isErr() then
|
||||||
|
warn(`Failed to fetch README from tool repo {repoName}:`, readmeRes:unwrapErr())
|
||||||
|
continue
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Write the updated README to the tool's directory
|
||||||
|
local readmeContents = readmeRes:unwrap()
|
||||||
|
-- There used to be some issues with encoding if not deleted and recreated
|
||||||
|
pathfs.removeFile(readmePath)
|
||||||
|
pathfs.writeFile(readmePath, readmeContents)
|
||||||
|
|
||||||
|
print(
|
||||||
|
`{INFO_PREFIX} Wrote README to {stdio.style("dim")}{readmePath:stripPrefix(pathfs.cwd)}{stdio.style("reset")}`
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
local timeElapsed = string.format("%.2fs", os.clock() - START_TIME)
|
||||||
|
print(`{INFO_PREFIX} Finished checking for tool updates in {stdio.style("dim")}{timeElapsed}{stdio.style("reset")}!`)
|
||||||
|
|
6
bins/argon/tests/input.project.json
Normal file
6
bins/argon/tests/input.project.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"name": "good-input",
|
||||||
|
"tree": {
|
||||||
|
"$path": "../"
|
||||||
|
}
|
||||||
|
}
|
12
bins/argon/tests/run.luau
Normal file
12
bins/argon/tests/run.luau
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
local toolchainlib = require("../lune_packages/core")
|
||||||
|
local process = require("@lune/process")
|
||||||
|
local fs = require("@lune/fs")
|
||||||
|
|
||||||
|
return function(version)
|
||||||
|
-- not working, needing support
|
||||||
|
-- process.args = { "sourcemap", "bins/argon/tests/input.project.json", "--output bins/argon/tests/output/sourcemap.json" }
|
||||||
|
local success, err = pcall(require, "bins/argon/init.luau")
|
||||||
|
assert(success, `failed to execute argon: {err}`)
|
||||||
|
|
||||||
|
assert(fs.isFile("bins/argon/tests/output/sourcemap.luau"), `output not found`)
|
||||||
|
end
|
10
bins/asphalt/tests/asphalt.toml
Normal file
10
bins/asphalt/tests/asphalt.toml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
[inputs.assets]
|
||||||
|
path = "input/**"
|
||||||
|
output_path = "output"
|
||||||
|
|
||||||
|
[creator]
|
||||||
|
type = "user"
|
||||||
|
id = 0
|
||||||
|
|
||||||
|
[codegen]
|
||||||
|
output_name = "init.luau"
|
BIN
bins/asphalt/tests/input/water_normal_map.png
Normal file
BIN
bins/asphalt/tests/input/water_normal_map.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
13
bins/asphalt/tests/run.luau
Normal file
13
bins/asphalt/tests/run.luau
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
local toolchainlib = require("../lune_packages/core")
|
||||||
|
local process = require("@lune/process")
|
||||||
|
local fs = require("@lune/fs")
|
||||||
|
|
||||||
|
return function(version)
|
||||||
|
-- not working, needing support
|
||||||
|
-- process.cwd = "bins/asphalt" -- bcuz asphalt.toml must to be in the same directory
|
||||||
|
-- process.args = { "sync", "--target debug" }
|
||||||
|
local success, err = pcall(require, "bins/asphalt/init.luau")
|
||||||
|
assert(success, `failed to execute asphalt: {err}`)
|
||||||
|
|
||||||
|
assert(fs.isFile("bins/asphalt/tests/output/water_normal_map.png"), "uploaded asset not found")
|
||||||
|
end
|
9
bins/blink/tests/input.blink
Normal file
9
bins/blink/tests/input.blink
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
option ClientOutput = "test/output/client.luau"
|
||||||
|
option ServerOutput = "test/output/server.luau"
|
||||||
|
|
||||||
|
event MyFirstEvent {
|
||||||
|
from: Server,
|
||||||
|
type: Reliable,
|
||||||
|
call: SingleSync,
|
||||||
|
data: string
|
||||||
|
}
|
16
bins/blink/tests/run.luau
Normal file
16
bins/blink/tests/run.luau
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
local toolchainlib = require("../lune_packages/core")
|
||||||
|
local process = require("@lune/process")
|
||||||
|
local fs = require("@lune/fs")
|
||||||
|
|
||||||
|
return function(version)
|
||||||
|
-- not working, needing support
|
||||||
|
-- process.args = { "bins/blink/tests/input.blink" }
|
||||||
|
local success, err = pcall(require, "bins/blink/init.luau")
|
||||||
|
assert(success, `failed to execute blink: {err}`)
|
||||||
|
|
||||||
|
local client_signature = `\n-- File generated by Blink v{version}`
|
||||||
|
assert(fs.readFile("bins/blink/tests/output/client.luau"):match(client_signature), `invalid output`)
|
||||||
|
|
||||||
|
local server_signature = `\n-- File generated by Blink v{version}`
|
||||||
|
assert(fs.readFile("bins/blink/tests/output/server.luau"):match(server_signature), `invalid output`)
|
||||||
|
end
|
8
bins/darklua/tests/input.luau
Normal file
8
bins/darklua/tests/input.luau
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
opt server_output = "tests/output/server.luau"
|
||||||
|
opt client_output = "tests/output/client.luau"
|
||||||
|
|
||||||
|
funct Test = {
|
||||||
|
call: Async,
|
||||||
|
args: (Foo: u8, Bar: string),
|
||||||
|
rets: enum { Success, Fail }
|
||||||
|
}
|
16
bins/darklua/tests/run.luau
Normal file
16
bins/darklua/tests/run.luau
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
local toolchainlib = require("../lune_packages/core")
|
||||||
|
local process = require("@lune/process")
|
||||||
|
local fs = require("@lune/fs")
|
||||||
|
|
||||||
|
return function(version)
|
||||||
|
-- not working, needing support
|
||||||
|
-- process.args = { "bins/zap/tests/input.zap" }
|
||||||
|
local success, err = pcall(require, "bins/blink/init.luau")
|
||||||
|
assert(success, `failed to execute blink: {err}`)
|
||||||
|
|
||||||
|
local client_signature = `\n-- Client generated by Zap v{version} (https://github.com/red-blox/zap)`
|
||||||
|
assert(fs.readFile("tests/output/client.luau"):match(client_signature), `invalid output`)
|
||||||
|
|
||||||
|
local server_signature = `\n-- Server generated by Zap v{version} (https://github.com/red-blox/zap)`
|
||||||
|
assert(fs.readFile("tests/output/server.luau"):match(server_signature), `invalid output`)
|
||||||
|
end
|
1
bins/luau-lsp/tests/input.luau
Normal file
1
bins/luau-lsp/tests/input.luau
Normal file
|
@ -0,0 +1 @@
|
||||||
|
local a: string = 1
|
15
bins/luau-lsp/tests/run.luau
Normal file
15
bins/luau-lsp/tests/run.luau
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
local toolchainlib = require("../lune_packages/core")
|
||||||
|
local process = require("@lune/process")
|
||||||
|
local fs = require("@lune/fs")
|
||||||
|
|
||||||
|
return function(version)
|
||||||
|
-- not working, needing support
|
||||||
|
-- process.args = { "process bins/darklua/tests/input.luau bins/darklua/tests/output.luau" --format dense }
|
||||||
|
local success, result = pcall(require, "bins/darklua/init.luau")
|
||||||
|
assert(success, `failed to execute darklua: {result}`)
|
||||||
|
|
||||||
|
assert(
|
||||||
|
fs.readFile("bins/darklua/tests/output.luau") ~= fs.readFile("bins/darklua/tests/input.luau"),
|
||||||
|
`any expected error was found: {result}`
|
||||||
|
)
|
||||||
|
end
|
6
bins/rojo/tests/input.project.json
Normal file
6
bins/rojo/tests/input.project.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"name": "good-input",
|
||||||
|
"tree": {
|
||||||
|
"$path": "../"
|
||||||
|
}
|
||||||
|
}
|
12
bins/rojo/tests/run.luau
Normal file
12
bins/rojo/tests/run.luau
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
local toolchainlib = require("../lune_packages/core")
|
||||||
|
local process = require("@lune/process")
|
||||||
|
local fs = require("@lune/fs")
|
||||||
|
|
||||||
|
return function(version)
|
||||||
|
-- not working, needing support
|
||||||
|
-- process.args = { "sourcemap", "bins/rojo/tests/input.project.json", "--output bins/rojo/tests/output/sourcemap.json" }
|
||||||
|
local success, err = pcall(require, "bins/rojo/init.luau")
|
||||||
|
assert(success, `failed to execute rojo: {err}`)
|
||||||
|
|
||||||
|
assert(fs.isFile("bins/rojo/tests/output/sourcemap.luau"), `output not found`)
|
||||||
|
end
|
3
bins/selene/tests/bad_input.luau
Normal file
3
bins/selene/tests/bad_input.luau
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
if {} == {} then
|
||||||
|
error("impossible")
|
||||||
|
end
|
3
bins/selene/tests/good_input.luau
Normal file
3
bins/selene/tests/good_input.luau
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
if 1 == 1 then
|
||||||
|
print("always true")
|
||||||
|
end
|
28
bins/selene/tests/run.luau
Normal file
28
bins/selene/tests/run.luau
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
local toolchainlib = require("../lune_packages/core")
|
||||||
|
local process = require("@lune/process")
|
||||||
|
|
||||||
|
return function(version)
|
||||||
|
do
|
||||||
|
-- not working, needing support
|
||||||
|
-- process.args = { "bins/selene/tests/bad_input.luau" }
|
||||||
|
local success, result = pcall(require, "bins/selene/init.luau")
|
||||||
|
assert(success, `failed to execute selene: {result}`)
|
||||||
|
|
||||||
|
assert(
|
||||||
|
string.find(result, "%d warnings") or string.find(result, "%d errors"),
|
||||||
|
`any expected error was found: {result}`
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
-- not working, needing support
|
||||||
|
-- process.args = { "bins/selene/tests/good_input.luau" }
|
||||||
|
local success, result = pcall(require, "bins/selene/init.luau")
|
||||||
|
assert(success, `failed to execute selene: {result}`)
|
||||||
|
|
||||||
|
assert(
|
||||||
|
string.find(result, "0 warnings") or string.find(result, "0 errors"),
|
||||||
|
`a unexpected error was found: {result}`
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
1
bins/stylua/tests/bad_input.luau
Normal file
1
bins/stylua/tests/bad_input.luau
Normal file
|
@ -0,0 +1 @@
|
||||||
|
local a = 5
|
1
bins/stylua/tests/good_input.luau
Normal file
1
bins/stylua/tests/good_input.luau
Normal file
|
@ -0,0 +1 @@
|
||||||
|
local a = 5
|
22
bins/stylua/tests/run.luau
Normal file
22
bins/stylua/tests/run.luau
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
local toolchainlib = require("../lune_packages/core")
|
||||||
|
local process = require("@lune/process")
|
||||||
|
|
||||||
|
return function(version)
|
||||||
|
do
|
||||||
|
-- not working, needing support
|
||||||
|
-- process.args = { "--check bins/stylua/tests/bad_input.luau", "--output-format summary" }
|
||||||
|
local success, result = pcall(require, "bins/stylua/init.luau")
|
||||||
|
assert(success, `failed to execute stylua: {result}`)
|
||||||
|
|
||||||
|
assert(string.find(result, "Code style issues found"), `any expected error was found: {result}`)
|
||||||
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
-- not working, needing support
|
||||||
|
-- process.args = { "--check bins/stylua/tests/good_input.luau", "--output-format summary" }
|
||||||
|
local success, result = pcall(require, "bins/stylua/init.luau")
|
||||||
|
assert(success, `failed to execute stylua: {result}`)
|
||||||
|
|
||||||
|
assert(string.find(result, "All files are correctly formatted."), `a unexpected error was found: {result}`)
|
||||||
|
end
|
||||||
|
end
|
8
bins/zap/tests/input.zap
Normal file
8
bins/zap/tests/input.zap
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
opt server_output = "tests/output/server.luau"
|
||||||
|
opt client_output = "tests/output/client.luau"
|
||||||
|
|
||||||
|
funct Test = {
|
||||||
|
call: Async,
|
||||||
|
args: (Foo: u8, Bar: string),
|
||||||
|
rets: enum { Success, Fail }
|
||||||
|
}
|
16
bins/zap/tests/run.luau
Normal file
16
bins/zap/tests/run.luau
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
local toolchainlib = require("../lune_packages/core")
|
||||||
|
local process = require("@lune/process")
|
||||||
|
local fs = require("@lune/fs")
|
||||||
|
|
||||||
|
return function(version)
|
||||||
|
-- not working, needing support
|
||||||
|
-- process.args = { "bins/zap/tests/input.zap" }
|
||||||
|
local success, err = pcall(require, "bins/zap/init.luau")
|
||||||
|
assert(success, `failed to execute zap: {err}`)
|
||||||
|
|
||||||
|
local client_signature = `\n-- Client generated by Zap v{version} (https://github.com/red-blox/zap)`
|
||||||
|
assert(fs.readFile("bins/zap/tests/output/client.luau"):match(client_signature), `invalid output`)
|
||||||
|
|
||||||
|
local server_signature = `\n-- Server generated by Zap v{version} (https://github.com/red-blox/zap)`
|
||||||
|
assert(fs.readFile("bins/zap/tests/output/server.luau"):match(server_signature), `invalid output`)
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue