-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from BusyCityGuy/feature/local-ci
Feature/local ci
- Loading branch information
Showing
15 changed files
with
383 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ | |
globaltypes.d.lua | ||
Packages | ||
DevPackages | ||
sourcemap.json | ||
*sourcemap.json | ||
settings.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
--!strict | ||
|
||
--[[ | ||
Analyzes all the same paths that get analyzed in the CI pipeline. | ||
Since the parent folder is named `lune`, the `lune` cli will automatically look in this directory for scripts to run. | ||
Usage (from project directory): | ||
lune run analyze | ||
--]] | ||
|
||
local process = require("@lune/process") | ||
local stdio = require("@lune/stdio") | ||
local task = require("@lune/task") | ||
|
||
local ANALYZE_PATHS: { { path: string, project: string?, sourceMap: string? } } = { | ||
{ | ||
path = "src/StateMachine", | ||
project = "default.project.json", | ||
sourceMap = "stateMachineSourcemap.json", | ||
}, | ||
{ | ||
path = "src/TestService", | ||
project = "test.project.json", | ||
sourceMap = "testSourcemap.json", | ||
}, | ||
{ | ||
path = "lune", | ||
project = nil, | ||
sourceMap = nil, | ||
}, | ||
} | ||
|
||
local NUM_EXPECTED_TASKS = #ANALYZE_PATHS | ||
|
||
local numErrors = 0 | ||
local numTasksCompleted = 0 | ||
local mainThread = coroutine.running() | ||
|
||
local function buildSourceMap(projectFilePath: string, sourceMapFilePath: string) | ||
local proc = process.spawn("./scripts/sourcemap.sh", { projectFilePath, sourceMapFilePath }) | ||
print(proc.stdout) | ||
assert(proc.ok, proc.stderr) | ||
end | ||
|
||
local function analyzePath(path: string, sourceMap: string?) | ||
local proc | ||
if sourceMap then | ||
proc = process.spawn("./scripts/analyze.sh", { sourceMap, path }) | ||
else | ||
proc = process.spawn("./scripts/analyze.sh", { path }) | ||
end | ||
|
||
print(proc.stdout) | ||
assert(proc.ok, proc.stderr) | ||
end | ||
|
||
local function analyzeAllPaths() | ||
print(`Analyzing {NUM_EXPECTED_TASKS} paths:`) | ||
for _, path in ipairs(ANALYZE_PATHS) do | ||
task.spawn(function() | ||
local success, errorMessage: string? = pcall(function() | ||
if path.project and path.sourceMap then | ||
buildSourceMap(path.project, path.sourceMap) | ||
end | ||
analyzePath(path.path, path.sourceMap) | ||
end) | ||
|
||
if not success then | ||
stdio.ewrite(errorMessage :: string) | ||
numErrors += 1 | ||
end | ||
|
||
numTasksCompleted += 1 | ||
if numTasksCompleted == NUM_EXPECTED_TASKS then | ||
coroutine.resume(mainThread) | ||
end | ||
end) | ||
end | ||
|
||
if numTasksCompleted < NUM_EXPECTED_TASKS then | ||
coroutine.yield() | ||
end | ||
|
||
if numErrors > 0 then | ||
stdio.ewrite(`{numErrors} of {NUM_EXPECTED_TASKS} paths FAILED analysis\n`) | ||
process.exit(1) | ||
end | ||
|
||
stdio.write(`All ({NUM_EXPECTED_TASKS}) paths analyzed successfully\n`) | ||
end | ||
|
||
analyzeAllPaths() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--!strict | ||
|
||
--[[ | ||
Runs all the same checks that CI steps run, including analysis, format check, linting, and testing. | ||
Since the parent folder is named `lune`, the `lune` cli will automatically look in this directory for scripts to run. | ||
Usage (from project directory): | ||
lune run ci | ||
--]] | ||
|
||
local process = require("@lune/process") | ||
local stdio = require("@lune/stdio") | ||
local task = require("@lune/task") | ||
|
||
local LUNE_COMMANDS = { | ||
"lint", | ||
"formatCheck", | ||
"analyze", | ||
"test", | ||
} | ||
|
||
local NUM_EXPECTED_TASKS = #LUNE_COMMANDS | ||
|
||
local numErrors = 0 | ||
local numTasksCompleted = 0 | ||
local mainThread = coroutine.running() | ||
|
||
local function runLuneCommand(command: string) | ||
local home = process.env.HOME | ||
local proc = process.spawn(`{home}/.aftman/bin/lune`, { "run", command }) | ||
print(proc.stdout) | ||
if not proc.ok then | ||
stdio.ewrite(proc.stderr) | ||
numErrors += 1 | ||
end | ||
|
||
numTasksCompleted += 1 | ||
if numTasksCompleted == NUM_EXPECTED_TASKS then | ||
coroutine.resume(mainThread) | ||
end | ||
end | ||
|
||
local function runAllLuneCommands() | ||
print(`Fixing format for {NUM_EXPECTED_TASKS} paths:`) | ||
for _, path in ipairs(LUNE_COMMANDS) do | ||
task.spawn(runLuneCommand, path) | ||
end | ||
|
||
if numTasksCompleted < NUM_EXPECTED_TASKS then | ||
coroutine.yield() | ||
end | ||
|
||
if numErrors > 0 then | ||
stdio.ewrite(`{numErrors} of {NUM_EXPECTED_TASKS} commands FAILED\n`) | ||
process.exit(1) | ||
end | ||
|
||
stdio.write(`All ({NUM_EXPECTED_TASKS}) commands succeeded\n`) | ||
end | ||
|
||
runAllLuneCommands() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--!strict | ||
|
||
--[[ | ||
Checks the format for all the same paths that get checked in the CI pipeline. | ||
This is just a check that prints problems to the output. | ||
To fix the format, run `lune run formatFix` instead. | ||
Since the parent folder is named `lune`, the `lune` cli will automatically look in this directory for scripts to run. | ||
Usage (from project directory): | ||
lune run formatCheck | ||
--]] | ||
|
||
local process = require("@lune/process") | ||
local stdio = require("@lune/stdio") | ||
local task = require("@lune/task") | ||
|
||
local FORMAT_PATHS = { | ||
"src/StateMachine", | ||
"src/TestService", | ||
"lune", | ||
} | ||
|
||
local NUM_EXPECTED_TASKS = #FORMAT_PATHS | ||
|
||
local numErrors = 0 | ||
local numTasksCompleted = 0 | ||
local mainThread = coroutine.running() | ||
|
||
local function checkFormatForPath(path: string) | ||
local proc = process.spawn("./scripts/formatCheck.sh", { path }) | ||
print(proc.stdout) | ||
if not proc.ok then | ||
stdio.ewrite(proc.stderr) | ||
numErrors += 1 | ||
end | ||
|
||
numTasksCompleted += 1 | ||
if numTasksCompleted == NUM_EXPECTED_TASKS then | ||
coroutine.resume(mainThread) | ||
end | ||
end | ||
|
||
local function formatCheckAllPaths() | ||
print(`Checking format for {NUM_EXPECTED_TASKS} paths:`) | ||
for _, path in ipairs(FORMAT_PATHS) do | ||
task.spawn(checkFormatForPath, path) | ||
end | ||
|
||
if numTasksCompleted < NUM_EXPECTED_TASKS then | ||
coroutine.yield() | ||
end | ||
|
||
if numErrors > 0 then | ||
stdio.ewrite(`{numErrors} of {NUM_EXPECTED_TASKS} paths FAILED formatting checks\n`) | ||
process.exit(1) | ||
end | ||
|
||
stdio.write(`All ({NUM_EXPECTED_TASKS}) paths passed format checks successfully\n`) | ||
end | ||
|
||
formatCheckAllPaths() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--!strict | ||
|
||
--[[ | ||
Fixes the format for all the same paths that get fixed in the CI pipeline. | ||
This changes the files in place. | ||
To just check the format, run `lune run formatCheck` instead. | ||
Since the parent folder is named `lune`, the `lune` cli will automatically look in this directory for scripts to run. | ||
Usage (from project directory): | ||
lune run formatFix | ||
--]] | ||
|
||
local process = require("@lune/process") | ||
local stdio = require("@lune/stdio") | ||
local task = require("@lune/task") | ||
|
||
local FORMAT_PATHS = { | ||
"src/StateMachine", | ||
"src/TestService", | ||
"lune", | ||
} | ||
|
||
local NUM_EXPECTED_TASKS = #FORMAT_PATHS | ||
|
||
local numErrors = 0 | ||
local numTasksCompleted = 0 | ||
local mainThread = coroutine.running() | ||
|
||
local function fixFormatForPath(path: string) | ||
local home = process.env.HOME | ||
local proc = process.spawn(`{home}/.aftman/bin/stylua`, { path }) | ||
print(proc.stdout) | ||
if not proc.ok then | ||
stdio.ewrite(proc.stderr) | ||
numErrors += 1 | ||
end | ||
|
||
numTasksCompleted += 1 | ||
if numTasksCompleted == NUM_EXPECTED_TASKS then | ||
coroutine.resume(mainThread) | ||
end | ||
end | ||
|
||
local function formatFixAllPaths() | ||
print(`Fixing format for {NUM_EXPECTED_TASKS} paths:`) | ||
for _, path in ipairs(FORMAT_PATHS) do | ||
task.spawn(fixFormatForPath, path) | ||
end | ||
|
||
if numTasksCompleted < NUM_EXPECTED_TASKS then | ||
coroutine.yield() | ||
end | ||
|
||
if numErrors > 0 then | ||
stdio.ewrite(`{numErrors} of {NUM_EXPECTED_TASKS} paths FAILED to get format fixed\n`) | ||
process.exit(1) | ||
end | ||
|
||
stdio.write(`All ({NUM_EXPECTED_TASKS}) paths have fixed formats\n`) | ||
end | ||
|
||
formatFixAllPaths() |
Oops, something went wrong.