Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
ROBLOX_OC_API_KEY = "API_KEY_HERE",
}
57 changes: 42 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Aftman
uses: ok-nick/setup-aftman@v0

- name: Install Just
uses: extractions/setup-just@v1
- name: Setup Rokit
uses: CompeyDev/setup-rokit@v0.1.2
with:
cache: true
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
shell: bash
run: just install-packages
run: sh bin/install-packages.sh

- name: Analyze
shell: bash
run: just analyze
run: sh bin/analyze.sh

lint:
name: Lint
Expand All @@ -38,12 +38,14 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Aftman
uses: ok-nick/setup-aftman@v0
- name: Setup Rokit
uses: CompeyDev/setup-rokit@v0.1.2
with:
cache: true
token: ${{ secrets.GITHUB_TOKEN }}

- name: Lint
run: |
selene ./packages
run: selene modules/

style:
name: Styling
Expand All @@ -52,9 +54,34 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Check code style
uses: JohnnyMorganz/stylua-action@v2
- name: Setup Rokit
uses: CompeyDev/setup-rokit@v0.1.2
with:
cache: true
token: ${{ secrets.GITHUB_TOKEN }}
version: v0.17.1
args: --check ./packages

- name: Check style
run: stylua --check modules/

test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Rokit
uses: CompeyDev/setup-rokit@v0.1.2
with:
cache: true
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
shell: bash
run: sh bin/install-packages.sh

- name: Run tests
shell: bash
run: lune run test --ci
env:
ROBLOX_OC_API_KEY: ${{ secrets.ROBLOX_OC_API_KEY }}
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
deps/
temp/
build/
Packages/
DevPackages/

dsn.lua
globalTypes.d.lua
.env.luau
sourcemap.json
.secrets

*.rbxm
*.rbxl
Expand Down
29 changes: 0 additions & 29 deletions .justfile

This file was deleted.

Binary file added .lune/.DS_Store
Binary file not shown.
8 changes: 8 additions & 0 deletions .lune/.luaurc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"languageMode": "strict",
"aliases": {
"lune": "~/.lune/.typedefs/0.9.4/",
"root": "../",
"test": "./test"
}
}
24 changes: 24 additions & 0 deletions .lune/test/bin/run-tests.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Packages = ReplicatedStorage.Packages
local DevPackages = ReplicatedStorage.DevPackages
local Jest = require(DevPackages.Jest)

local PACKAGE_ROOTS = {
Packages.SentryCore,
Packages.SentryRoblox,
Packages.SentryTypes,
Packages.SentryUtils,
}

local status, result = Jest.runCLI(ReplicatedStorage, {
verbose = _G.__VERBOSE__,
ci = _G.__CI__,
passWithNoTests = true,
}, PACKAGE_ROOTS):awaitStatus()

if status == "Rejected" then
error(result)
end

return nil
75 changes: 75 additions & 0 deletions .lune/test/init.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
local fs = require("@lune/fs")
local process = require("@lune/process")

local buildUploadPlaceAsync = require("@test/utility/buildUploadPlaceAsync")
local executeLuauTaskAsync = require("@test/utility/executeLuauTaskAsync")

local function loadEnvFile()
local envFile = require("@root/.env")
return envFile
end

local function getApiKey(): string
local keyInEnv = process.env.ROBLOX_OC_API_KEY
if keyInEnv then
return keyInEnv
end

local success, envFile = pcall(loadEnvFile)
if not success then
error(
"No environment variable set for ROBLOX_OC_API_KEY. Please set it in the environment or in the .env.luau file."
)
end

return envFile.ROBLOX_OC_API_KEY
end

local function loadTestConfig()
local testConfig = require("@root/test-config")
return testConfig
end

local function hasArg(requiredArg: string)
for _, arg in process.args do
if arg == requiredArg then
return true
end
end
return false
end

local function main()
local apiKey = getApiKey()
local testConfig = loadTestConfig()

local verbose = hasArg("--verbose")
local ci = hasArg("--ci")

local jestScript = fs.readFile(".lune/test/bin/run-tests.luau")
jestScript = jestScript:gsub("_G.__VERBOSE__", if verbose then "true" else "false")
jestScript = jestScript:gsub("_G.__CI__", if ci then "true" else "false")

local uploadResult = buildUploadPlaceAsync({
universeId = testConfig.universeId,
placeId = testConfig.placeId,
apiKey = apiKey,
filePath = testConfig.testPlaceFile,
rojoProjectFile = testConfig.rojoProjectFile,
})

if uploadResult then
executeLuauTaskAsync({
universeId = testConfig.universeId,
placeId = testConfig.placeId,
placeVersion = uploadResult.versionNumber,
apiKey = apiKey,
script = jestScript,
})
end

-- Explicitly exit because Lune sucks at async tasks
process.exit(0)
end

main()
88 changes: 88 additions & 0 deletions .lune/test/types.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
type Array<T> = { T }

export type LuauExecutionSessionTask_State =
"STATE_UNSPECIFIED"
| "QUEUED"
| "PROCESSING"
| "CANCELLED"
| "COMPLETE"
| "FAILED"

--- Present when the task execution fails. Contains details about the error that
--- caused the failure.
export type LuauExecutionSessionTask_Error = {
--- An error code indicating the category of the error.
code: "ERROR_CODE_UNSPECIFIED"
| "SCRIPT_ERROR"
| "DEADLINE_EXCEEDED"
| "OUTPUT_SIZE_LIMIT_EXCEEDED"
| "INTERNAL_ERROR",
--- An error message containing more details about the error.
message: string,
}

--- Present when the task execution succeeds. Contains the output of the
--- execution.
export type LuauExecutionSessionTask_Output = {
--- Return values from the script that was run. Return values that are not
--- JSON serializable (such as Data Model Instances) will be returned as
--- nulls.
results: Array<any>,
}

--[[
A `LuauExecutionSessionTask` ("task" for short) executes a given Luau script
in the context of a specific version of a place.

The script may access and update the data model of the place, including
invoking any module scripts. However, data model changes are local to the
task and cannot be persisted.

The script can also invoke engine APIs that read and/or modify data stored
in the cloud, such as those for DataStores. Exercise caution when using such
APIs.
]]
export type LuauExecutionSessionTask_Request = {
--- The script to be run as part of this task.
script: string,
}

export type LuauExecutionSessionTask = LuauExecutionSessionTask_Request & {
--- The resource path of the luau execution session task.
path: string,
--- Time when this task was created. This string is formatted as a
--- Timestamp.
createTime: string,
--- Time when this task's state last changed. This string is formatted as a
--- Timestamp.
updateTime: string,
--- The user that created the API key that was used to create this task.
user: string,
--- The task's state. See the State enum for information about each possible
--- value.
state: LuauExecutionSessionTask_State,

error: LuauExecutionSessionTask_Error?,
output: LuauExecutionSessionTask_Output?,
}

--[[
Represents a chunk of log messages generated by a `LuauExecutionSessionTask`.

The amount of logs that is retained is limited. See the documentation of the
`LuauExecutionSessionTask` resource for more details.

Logs have the same retention time as the parent task.
]]
export type LuauExecutionSessionTaskLog = {
luauExecutionSessionTaskLogs: Array<{
--- The resource path of the luau execution session task log.
path: string,
--- A list of log messages generated by the task execution. Each call to the
--- Luau `print()` function from the task's script's code results in a
--- single list item here, even if the message itself contains newlines.
messages: Array<string>,
}>,
}

return nil
Loading