Skip to content

Template repository for configuring Fensak using TypeScript and Jest with a .fensak repository.

License

Notifications You must be signed in to change notification settings

fensak-io/dotfensak-ts-jest-template

Repository files navigation

TypeScript and Jest template for .fensak repositories

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.

What's included

This template includes the following:

Sample rule

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.

Sample config

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.

Tests

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:

  1. Install Node if you do not have it already.
  2. Install pnpm if you do not have it already.
  3. Install dependencies by running pnpm install.
  4. 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.

CI/CD with GitHub Actions

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 and eslint.
  • 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.

Instructions

  1. Create a new repo against this template on GitHub. Refer to the official documentation for more details on using template repositories.

  2. 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:

    1. LICENSE
    2. SECURITY.md
    3. .github/workflows/bootstrap.yml
  3. Add and define your own rules in the rules folder.

  4. Update this README to suit your needs.

Questions or Feedback

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.

About

Template repository for configuring Fensak using TypeScript and Jest with a .fensak repository.

Resources

License

Security policy

Stars

Watchers

Forks