Use this template to create a TypeScript and Jest based
.fensak
repository in your Organization with a recommended project configuration for writing and testing rules. Feel
free to clone this repo and make any modifications necessary to get up and running with Fensak.
Check out our Getting started guide.
This template includes the following:
A sample rule file (using TypeScript) is provided in the rules folder. The sample rule is a basic "Hello
world" example that allows any PRs that only contains updates to the README.md
file in the root of the repository. It
should give you a basic starting point for navigating the patch object provided to rules functions by Fensak.
For more example rules, checkout fensak-io/fensak-rules-examples.
Also check out our Writing rules scripts guide.
A sample fensak.yml config file is provided for your convenience. The config file maps a single fictional
repository in your Organization (my-repo
) against the sample rule, rules/sample.ts.
Check out our Config file reference for an overview of the Fensak config file.
This template includes a project scaffold for running tests for the rules using Jest. The tests contain example usage of the Fensak module for testing various pull requests against the rules. See rules/sample.test.ts for more details.
To run the test, follow these steps:
- Install Node if you do not have it already.
- Install pnpm if you do not have it already.
- Install dependencies by running
pnpm install
. - Run
pnpm test
.
NOTE
The tests make API calls to GitHub. If you start hitting rate limits, try setting a personal access token on the environment variable
GITHUB_API_TOKEN
.
This template also includes a sample CI/CD workflow based on GitHub Actions in the .github/workflows folder. The GitHub Actions workflow will:
- Check if the code is linted and formatted properly using
prettier
andeslint
. - Run the tests using
pnpm test
and output a junit report. - Process the junit report and upload to GitHub Actions so that it can be viewed.
-
Create a new repo against this template on GitHub. Refer to the official documentation for more details on using template repositories.
-
Wait for the
bootstrap
GitHub Actions job to run. Remove the following files if you have GitHub Actions disabled on new repos in your Org:LICENSE
SECURITY.md
.github/workflows/bootstrap.yml
-
Add and define your own rules in the rules folder.
-
Update this README to suit your needs.
If you have any questions, concerns, or feedback pertaining to this repository or Fensak in general, please start a discussion on the Fensak GitHub Discussions forum.