Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Merge bf2246c into 103bd18
Browse files Browse the repository at this point in the history
  • Loading branch information
matthargett committed Sep 25, 2021
2 parents 103bd18 + bf2246c commit 66c8a00
Show file tree
Hide file tree
Showing 96 changed files with 481 additions and 437 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,41 @@ jobs:

- uses: leafo/gh-actions-luarocks@v4

- name: get foreman and run foreman install
uses: rojo-rbx/setup-foreman@v1
with:
version: "^1.0.1"
token: ${{ secrets.GITHUB_TOKEN }}

# useful for debugging differences between CI and local environment
- name: check versions
shell: bash
run: |
foreman list
- name: use rojo to build project
shell: bash
run: rojo build default.project.json --output model.rbxmx

- name: Linting and Style Checking
shell: bash
run: |
selene src benchmarks examples
stylua -c src benchmarks examples
- name: Install dependencies
run: |
luarocks install luafilesystem
luarocks install luacov
luarocks install luacov-reporter-lcov
luarocks install luacheck
- name: Test
run: |
lua -lluacov bin/spec.lua
luacheck src benchmarks examples
luacov -r lcov
- name: Report to Coveralls
uses: coverallsapp/github-action@v1.1.2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: luacov.report.out
path-to-lcov: luacov.report.out
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
/*.rbxlx
/*.rbxmx
/*.rbxm
/*.rbxl
/*.rbxl
# let selene re-generate roblox.toml so it updates automatically with selene
roblox.toml
43 changes: 0 additions & 43 deletions .luacheckrc

This file was deleted.

29 changes: 20 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,20 @@ To get started working on Roact, you'll need:
* Lua 5.1
* Lemur's dependencies:
* [LuaFileSystem](https://keplerproject.github.io/luafilesystem/) (`luarocks install luafilesystem`)
* [Luacheck](https://github.com/mpeterv/luacheck) (`luarocks install luacheck`)
* [LuaCov](https://keplerproject.github.io/luacov) (`luarocks install luacov`)

Foreman is an un-package manager that retrieves code directly from GitHub repositories. We'll use this to get a lua code analysis tool and other utilities. The Foreman packages are listed in `foreman.toml`.

You can install `foreman` from its [releases page](https://github.com/rojo-rbx/foreman/releases). If you have the Rust tool `cargo` installed, you can also do `cargo install foreman`. Either way, be sure the foreman binary location is in your `PATH` environment variable.

```
foreman github-auth <[your GitHub API token](https://github.com/settings/tokens)>
foreman install
export PATH=$PATH:~/.foreman/bin/ # you might want to add this to your .bash_profile (or similarly appropriate shell configuration) file as well
```

After running `foreman install`, you should be able to run `stylua src` and `selene src` commands -- just like this repository's continuous integration steps do! This helps ensure that our code and your contributions are consistently formatted and are free of trivial bugs.

Make sure you have all of the Git submodules for Roact downloaded, which include a couple extra dependencies used for testing.

Finally, you can run all of Roact's tests with:
Expand All @@ -44,10 +55,10 @@ luacov
Before starting a pull request, open an issue about the feature or bug. This helps us prevent duplicated and wasted effort. These issues are a great place to ask for help if you run into problems!

Before you submit a new pull request, check:
* Code Style: Match the [official Roblox Lua style guide](https://roblox.github.io/lua-style-guide) and the local code style
* Changelog: Add an entry to [CHANGELOG.md](CHANGELOG.md)
* Luacheck: Run [Luacheck](https://github.com/mpeterv/luacheck) on your code, no warnings allowed!
* Code Style: Run [StyLua](https://github.com/JohnnyMorganz/StyLua) to ensure your code changes follow the [official Roblox Lua style guide](https://roblox.github.io/lua-style-guide) and the local code style
* selene: Run [Selene](https://github.com/kampfkarren/selene) on your code, no warnings allowed!
* Tests: They all need to pass!
* Changelog: Add an entry to [CHANGELOG.md](CHANGELOG.md)

### Code Style
Roblox has an [official Lua style guide](https://roblox.github.io/lua-style-guide) which should be the general guidelines for all new code. When modifying code, follow the existing style!
Expand All @@ -58,7 +69,7 @@ In short:
* Double quotes
* One statement per line

Eventually we'll have a tool to check these things automatically.
Use `StyLua` (instructions below) to automatically format the code to follow the coding style

### Changelog
Adding an entry to [CHANGELOG.md](CHANGELOG.md) alongside your commit makes it easier for everyone to keep track of what's been changed.
Expand All @@ -67,10 +78,10 @@ Add a line under the "Current master" heading. When we make a new release, all o

Add a link to your pull request in the entry. We don't need to link to the related GitHub issue, since pull requests will also link to them.

### Luacheck
We use [Luacheck](https://github.com/mpeterv/luacheck) for static analysis of Lua on all of our projects.
### Selene and StyLua
We use [Selene](https://github.com/kampfkarren/selene) and [StyLua](https://github.com/JohnnyMorganz/StyLua) for static analysis of Lua on all of our projects.

From the command line, just run `luacheck src` to check the Roact source.
From the command line, just run `selene src` and `stylua -c src` to check the Roact source. You'll need to install `foreman` and run `foreman install` first, which will make both the `selene` and `stylua` tools available.

You should get it working on your system, and then get a plugin for the editor you use. There are plugins available for most popular editors!

Expand All @@ -97,4 +108,4 @@ When releasing a new version of Roact, do these things:
7. Write a release on GitHub:
- Use the same format as the previous release
- Copy the release notes from `CHANGELOG.md`
- Attach the `Roact.rbxm` built with Rojo
- Attach the `Roact.rbxm` built with Rojo
2 changes: 1 addition & 1 deletion benchmarks/hello.bench.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ return {
local handle = Roact.mount(hello)
Roact.unmount(handle)
end,
}
}
15 changes: 4 additions & 11 deletions benchmarks/init.server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ local function findBenchmarkModules(root, moduleList)
end
end

local function noop()
end
local function noop() end

local emptyTimes = {}
local function getEmptyTime(iterations)
Expand Down Expand Up @@ -42,11 +41,7 @@ table.sort(benchmarkModules, function(a, b)
return a.Name < b.Name
end)

local startMessage = (
"Starting %d benchmarks..."
):format(
#benchmarkModules
)
local startMessage = ("Starting %d benchmarks..."):format(#benchmarkModules)
print(startMessage)
print()

Expand All @@ -70,9 +65,7 @@ for _, module in ipairs(benchmarkModules) do

local totalTime = (endTime - startTime) - getEmptyTime(benchmark.iterations)

local message = (
"Benchmark %s:\n\t(%d iterations) took %f s (%f ns/iteration)"
):format(
local message = ("Benchmark %s:\n\t(%d iterations) took %f s (%f ns/iteration)"):format(
module.Name,
benchmark.iterations,
totalTime,
Expand All @@ -83,4 +76,4 @@ for _, module in ipairs(benchmarkModules) do
print()
end

print("Benchmarks complete!")
print("Benchmarks complete!")
11 changes: 7 additions & 4 deletions benchmarks/update.bench.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ return {
Roact.unmount(tree)
end,
step = function(i)
Roact.update(tree, Roact.createElement("StringValue", {
Value = tostring(i),
}))
Roact.update(
tree,
Roact.createElement("StringValue", {
Value = tostring(i),
})
)
end,
}
}
6 changes: 2 additions & 4 deletions bin/run-tests.server.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
-- luacheck: globals __LEMUR__

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local isRobloxCli, ProcessService = pcall(game.GetService, game, "ProcessService")

Expand All @@ -19,8 +17,8 @@ local results = TestEZ.TestBootstrap:run(

local statusCode = (results.failureCount == 0 and #results.errors == 0) and 0 or 1

if __LEMUR__ then
if _G.__LEMUR__ then
os.exit(statusCode)
elseif isRobloxCli then
ProcessService:ExitAsync(statusCode)
end
end
2 changes: 1 addition & 1 deletion examples/binding/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ return function()
end

return stop
end
end
20 changes: 13 additions & 7 deletions examples/clock/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,23 @@ return function()

local running = true
local currentTime = 0
local handle = Roact.mount(Roact.createElement(ClockApp, {
time = currentTime,
}), PlayerGui)
local handle = Roact.mount(
Roact.createElement(ClockApp, {
time = currentTime,
}),
PlayerGui
)

spawn(function()
while running do
currentTime = currentTime + 1

handle = Roact.reconcile(handle, Roact.createElement(ClockApp, {
time = currentTime,
}))
handle = Roact.reconcile(
handle,
Roact.createElement(ClockApp, {
time = currentTime,
})
)

wait(1)
end
Expand All @@ -40,4 +46,4 @@ return function()
end

return stop
end
end
2 changes: 1 addition & 1 deletion examples/event/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ return function()
-- Attach event listeners using `Roact.Event[eventName]`
-- Event listeners get `rbx` as their first parameter
-- followed by their normal event arguments.
[Roact.Event.Activated] = function(rbx)
[Roact.Event.Activated] = function(_rbx)
print("The button was clicked!")
end,
}),
Expand Down
2 changes: 1 addition & 1 deletion examples/hello-roact/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ return function()
end

return stop
end
end
2 changes: 1 addition & 1 deletion examples/init.client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ function Examples.makeExampleList()
end

Examples.exampleList = Examples.makeExampleList()
Examples.exampleList.Parent = PlayerGui
Examples.exampleList.Parent = PlayerGui
2 changes: 1 addition & 1 deletion examples/stress-test/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ return function()
end

return stop
end
end
4 changes: 4 additions & 0 deletions foreman.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tools]
rojo = { source = "rojo-rbx/rojo", version = "6.2.0" }
selene = { source = "Kampfkarren/selene", version = "0.14" }
stylua = { source = "JohnnyMorganz/StyLua", version = "0.11" }
1 change: 1 addition & 0 deletions selene.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
std = "roblox+testez"
12 changes: 5 additions & 7 deletions src/Binding.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function BindingInternalApi.map(upstreamBinding, predicate)
end)
end

function impl.update(newValue)
function impl.update(_newValue)
error("Bindings created by Binding:map(fn) cannot be updated directly", 2)
end

Expand All @@ -96,9 +96,7 @@ function BindingInternalApi.join(upstreamBindings)

for key, value in pairs(upstreamBindings) do
if Type.of(value) ~= Type.Binding then
local message = (
"Expected arg #1 to contain only bindings, but key %q had a non-binding value"
):format(
local message = ("Expected arg #1 to contain only bindings, but key %q had a non-binding value"):format(
tostring(key)
)
error(message, 2)
Expand All @@ -122,7 +120,7 @@ function BindingInternalApi.join(upstreamBindings)
local disconnects = {}

for key, upstream in pairs(upstreamBindings) do
disconnects[key] = BindingInternalApi.subscribe(upstream, function(newValue)
disconnects[key] = BindingInternalApi.subscribe(upstream, function(_newValue)
callback(getValue())
end)
end
Expand All @@ -140,7 +138,7 @@ function BindingInternalApi.join(upstreamBindings)
end
end

function impl.update(newValue)
function impl.update(_newValue)
error("Bindings created by joinBindings(...) cannot be updated directly", 2)
end

Expand All @@ -154,4 +152,4 @@ function BindingInternalApi.join(upstreamBindings)
}, BindingPublicMeta)
end

return BindingInternalApi
return BindingInternalApi
4 changes: 2 additions & 2 deletions src/Binding.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ return function()
local binding1, update1 = Binding.create(1)
local binding2, update2 = Binding.create(2)

local joined = Binding.join({binding1, binding2})
local joined = Binding.join({ binding1, binding2 })

local spy = createSpy()
local disconnect = Binding.subscribe(joined, spy.value)
Expand Down Expand Up @@ -266,4 +266,4 @@ return function()
end)
end)
end)
end
end
Loading

0 comments on commit 66c8a00

Please sign in to comment.