Skip to content

zerocracy/judges-action

Repository files navigation

Judges Zerocracy Action

DevOps By Rultor.com

make Hits-of-Code License

First, get a free authentication token from Zerocracy.com and add it as ZEROCRACY_TOKEN secret to your repository.

Then, create a new personal access token and add it as a ZEROCRACY_PAT secret to your repository. Don't forget to give it full "repository access". You may ignore this, if all your repositories are public.

Then, add this zerocracy.yml file to your GitHub repository at the .github/workflows/ directory (replace foo with the name of your team and 42 with anything between zero and 60):

name: zerocracy
'on':
  schedule:
    - cron: '42 * * * *'
concurrency:
  group: zerocracy
  cancel-in-progress: false
jobs:
  zerocracy:
    runs-on: ubuntu-24.04
    timeout-minutes: 25
    steps:
      - uses: actions/checkout@v4
      - uses: zerocracy/[email protected]
        with:
          token: ${{ secrets.ZEROCRACY_TOKEN }}
          github-token: ${{ secrets.ZEROCRACY_PAT }}
          repositories: yegor256/judges,yegor256/factbase,zerocracy/*
          factbase: foo.fb
      - uses: zerocracy/[email protected]
        with:
          github-token: ${{ secrets.ZEROCRACY_PAT }}
          factbase: foo.fb
      - uses: JamesIves/[email protected]
        with:
          folder: pages
          clean: false

In the file, there is only one place that you should configure: the repositories=... should have a comma-separated list of repositories where your team works (instead of ...). If you have more than one repository in your product, list them here. The CI job must only be added to one of them.

Once the file is added, GitHub will start running this job hourly, collecting information about most important activities of your programmers. The plugin will give them awards for good things they do (like fixing bugs) and will also punish them (by deducting points) for bad things (like stale pull requests).

The plugin will also generate a summary foo.html file, which will be automatically deployed to the gh-pages branch. You can configure your GitHub repository to render the branch as a static website via GitHub Pages. Thus, the summary page will be updated hourly and you will see who is the best performer in your team, similar to what we see in our team.

Configuration

The following options are expected by the plugin (see how we configure it):

  • token (mandatory) is an authentication token from Zerocracy.com
  • options (mandatory) is a list of k=v pairs, which are explained below
  • factbase (mandatory) is the path of the Factbase file (where everything is kept)
  • repositories (optional) is a comma-separated list of masks that determine the repositories to manage, where yegor256/* means all repos of the user, yegor256/judges means a specific repo, and -yegor256/judges means an exclusion of the repo from the list.
  • github-token (optional) is an authentication GitHub access token
  • verbose (optional) makes it print debugging info if set to true
  • timeout (optional) is how many minutes each judge can spend
  • lifetime (optional) is how many minutes the entire update can take
  • cycles (optional) is a number of update cycles to run
  • sqlite-cache (optional) is a path of SQLite database file with HTTP cache

The following k=v pairs inside the options may be important:

  • github_token=... is a default GitHub token, usually to be set to ${{ secrets.GITHUB_TOKEN }}
  • repositories=.. is a comma-separated list of masks that determine the repositories to manage, where yegor256/* means all repos of the user, yegor256/judges means a specific repo, and -yegor256/judges means an exclusion of the repo from the list.
  • sqlite_cache_maxsize=10M is the maximum size of HTTP cache file
  • sqlite_cache_maxsize=10K is the maximum size of a single HTTP entry to cache

The zerocracy/pages-action plugin is responsible for rendering the summary HTML page: its configuration is not explained here, check its own repository.

How to Contribute

In order to test this action, just run (provided, you have Ruby 3+, Bundler, and GNU make installed):

bundle update
make

This should build a new Docker image named judges-action and then run the entire cycle inside a new Docker container. Obviously, you need to have Docker installed. The Docker image will be deleted by the end of the build (either success or failure).

In order to run "live" tests of some judges, do this:

bundle exec rake -- --live

In order to run a single test, try this:

bundle exec ruby test/judges/test-dimensions-of-terrain.rb -n test_total_repositories

About

A GitHub Action that scans the entire repository and generates a Factbase for Zerocracy

Topics

Resources

License

Stars

Watchers

Forks

Contributors 8

Languages