Skip to content

Commit 5c73f23

Browse files
ghostnapsvocksel
andauthored
Run Luau analysis in CI (#14)
Co-authored-by: Marin Minnerly <[email protected]>
1 parent 2fe6223 commit 5c73f23

File tree

7 files changed

+55
-42
lines changed

7 files changed

+55
-42
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,22 @@ jobs:
3838

3939
- name: Lint
4040
run: lune run lint
41+
42+
analyze:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- uses: CompeyDev/[email protected]
48+
49+
- name: Install tools
50+
run: rokit install --no-trust-check
51+
52+
- name: Install dependencies
53+
run: lune run install
54+
55+
- name: Setup Lune typedefs
56+
run: lune setup
57+
58+
- name: Analyze
59+
run: lune run analyze

.lune/analyze.luau

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
local run = require("@root/lib/run")
2+
3+
local foldersToAnalyze = {
4+
".lune",
5+
"src",
6+
"examples",
7+
}
8+
9+
run("luau-lsp", { "analyze", "--ignore=**/pkg/**", table.unpack(foldersToAnalyze) })

foreman.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[tools]
2+
luau-lsp = { source = "JohnnyMorganz/luau-lsp", version = "=1.45.0" }
23
lune = { source = "lune-org/lune", version = "=0.9.3" }
34
rojo = { source = "rojo-rbx/rojo", version = "=7.5.0" }
45
selene = { source = "kampfkarren/selene", version = "=0.28.0" }

src/cloud/publishPlaceAsync.luau

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ local function publishPlaceAsync(
3131

3232
if res.ok then
3333
local body = serde.decode("json", res.body)
34-
return body.versionNumber
34+
return body.versionNumber :: number
3535
end
36+
return -1
3637
end
3738

3839
return publishPlaceAsync

src/requests/publishImagesAsync.luau

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ local function publishImagesAsync(
4848
apiKey
4949
)
5050

51-
local assetId = operation.response.assetId
51+
local assetId = if operation.response then operation.response.assetId else nil
5252

5353
if assetId then
5454
table.insert(pendingImages, {
@@ -88,18 +88,20 @@ local function publishImagesAsync(
8888
apiKey
8989
)
9090

91-
local assetId = operation.response.assetId
91+
if operation.response then
92+
local assetId = operation.response.assetId
9293

93-
if assetId then
94-
table.insert(pendingImages, {
95-
path = thumbnailPath,
96-
filename = thumbnailFilename,
97-
assetId = assetId,
98-
})
94+
if assetId then
95+
table.insert(pendingImages, {
96+
path = thumbnailPath,
97+
filename = thumbnailFilename,
98+
assetId = assetId,
99+
})
99100

100-
logging.debug(`image uploaded successfully`)
101-
else
102-
logging.warn(`failed to upload image at {thumbnailPath}`)
101+
logging.debug(`image uploaded successfully`)
102+
else
103+
logging.warn(`failed to upload image at {thumbnailPath}`)
104+
end
103105
end
104106
end
105107
end

src/requests/setAssetIconAsync.luau

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ local function setAssetIconAsync(projectPath: string, assetName: string, assetCo
6464

6565
local operation = waitForAssetOperationAsync(body.operationId, apiKey)
6666

67-
if operation.error then
67+
if operation.metadata then
6868
local problems = {}
6969
for _, err in operation.metadata.errors do
7070
table.insert(problems, err.error.message)

src/types.luau

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -133,46 +133,27 @@ types.validateLockfile = t.strictInterface({
133133
export type ErrorStatusResponse = {
134134
code: string,
135135
message: string,
136+
details: { string }?,
136137
}
137138

138-
type OperationPendingResponse = {
139-
done: false,
139+
export type OperationResponse = {
140+
done: boolean,
140141
operationId: string,
141142
path: string,
142-
}
143143

144-
type ErrorResponse = {
145-
code: string,
146-
details: { string }?,
147-
message: string,
148-
}
144+
-- Success
145+
response: { [string]: any }?,
149146

150-
type OperationFailedResponse = {
151-
done: true,
152-
error: ErrorResponse,
147+
-- Failure
148+
error: ErrorStatusResponse?,
153149
metadata: {
154150
errors: {
155151
{
156-
error: ErrorResponse,
152+
error: ErrorStatusResponse,
157153
fieldMask: { [string]: any },
158154
}
159155
},
160-
},
161-
operationId: string,
162-
path: string,
163-
}
164-
165-
type OperationSucceededResponse = {
166-
done: true,
167-
operationId: string,
168-
path: string,
169-
response: { [string]: any },
170-
}
171-
172-
export type OperationResponse =
173-
OperationSucceededResponse
174-
| OperationFailedResponse
175-
| OperationPendingResponse
176-
| ErrorStatusResponse
156+
}?,
157+
} & ErrorStatusResponse
177158

178159
return types

0 commit comments

Comments
 (0)