Introduction
This article describes how to set up a clean and efficient CI pipeline using GitHub Actions. You will learn how to:
- Install Rokit
- Cache Rokit dependencies
- Run Lute scripts automatically
- Validate formatting and static-analysis
Prerequisities
Before configuring CI, your project should already include:
- A Rokit project file (rokit.toml)
- A Luau script to format and lint
- A Github repository with CI enabled
A typical minimal structure:
Github Actions Workflow Overview
We will create a workflow that:
- Checks out your repository
- Installs the appropriate dependencies
- Sets up Rokit
- Caches Rokit's dependency store
- Runs formatting, linting
Installing the dependencies
Add the required tools to the tool section of your rokit.toml file.
Once configured, install the dependencies by running:
This ensures all tools are installed in a reproducible manner.
Creating the CI Workflow
Create the following file in your repository:
Paste the workflow configuration into this file:
Workflow breakdown
Checkout repository
Uses actions/checkout to fetch your code so it is available to the runner.
Cache Rokit
Rokit downloads tools into its own store. Caching this directory dramatically reduces CI time after the first run.
The cache key is tied to rokit.toml, so updates invalidate the cache correctly.
Install Rokit
Rokit is installed via the official bootstrap script and added to PATH for subsequent steps.
Install dependencies
rokit install resolves and installs all declared tools (Lute, Luau, etc.) in a reproducible manner.
Formatting and Linting
Luau scripts are executed through Lute to ensure consistent tool versions both locally and in CI.
- format is a Luau script that invokes the StyLua formatter
- lint runs Selene to detect linting and static analysis issues
Setting up the scripts
Configuration files
Begin by creating the StyLua configuration file, stylua.toml, and populating it with:
Next, create selene.toml, which defines the configuration for Selene:
Luau Scripts
We will now proceed to the creation of our Luau scripts, lint and format.
Let's start by creating our format script. Paste the following content inside scripts/format.luau:
This script uses Lute’s process API to invoke the StyLua command, passing the previously created configuration file as an argument.
Now, let's create our lint script. Paste the content inside scripts/lint.luau
This script follows the same structure as the format script but invokes Selene instead.
Conclusion
This setup provides a solid foundation for a Luau project, with automated formatting, linting, and reproducible tooling enforced through CI.
From here, the pipeline can be extended with additional steps such as testing, bundling (using Darklua), or deployment, without sacrificing consistency or reliability.
