Skip to content

Getting started

This page sets up the first and safest way to use Ichnos: not repeating on main what the pull request just passed. It takes a few lines in one workflow, stores nothing and needs no write access.

When it applies

A pull request is tested on its merge commit. When the pull request was up to date with main, the push that follows its merge has exactly the same files, and the jobs repeat a run that just passed. Ichnos asks GitHub three questions about the pushed commit:

  1. Is it the merge of a pull request?
  2. Does that pull request's last commit have the same git tree?
  3. Did the jobs you name succeed there, in a successful run of the same workflow?

If so, the output seen is true. A job that was skipped on the pull request does not count, and any doubt or API error leaves seen at false: everything runs.

The workflow

jobs:
  changes:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      actions: read        # the jobs of the pull request's run
      pull-requests: read  # which pull request this commit merged
    outputs:
      seen: ${{ steps.ichnos.outputs.seen == 'true' }}
    steps:
      - uses: actions/checkout@v7
        if: github.event_name == 'push'
      - id: ichnos
        if: github.event_name == 'push'
        uses: mmornati/ichnos@v0
        with:
          passed-in-pull-request: |
            test

  test:
    needs: changes
    if: needs.changes.outputs.seen != 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - run: make test

Name the jobs as GitHub shows them in the pull request's checks. A name also stands for its matrix: test covers test (3.12) and test (3.13), and all of them must have succeeded.

Which version

@v0 follows the latest 0.x release. Use @v0.1.0, or a commit you have read, to stay on exactly one version. Ichnos is at version 0: options may still change between 0.x releases.

Three things to decide

Do you have a single required check? If a job such as ci-ok gathers the results, it must accept the skipped jobs when seen is true, and only then.

Does something on main need the job to really run? A coverage upload that later pull requests are compared with, an image that a publish step rebuilds from a cache. Leave those jobs out of the list.

Does a job depend on something outside the repository? A vulnerability database, the network, today's date. Leave those out too, and keep a scheduled run that skips nothing.

What you should see

After merging an up-to-date pull request, the run on main shows the named jobs as skipped, and the log of the changes job says which pull request it relied on:

ichnos: not repeated: pull request #94 passed them on the same files (https://github.com/…/runs/…)

When it does not apply, the log says why:

ichnos: to run: the files differ from those of pull request #77 (it was not up to date)
ichnos: to run: on pull request #76 these did not run and pass: Unit tests

Going further

On a machine of your own:

pip install git+https://github.com/mmornati/ichnos@v0.1.0
ichnos doctor
ichnos run --id tests -- python -m unittest discover tests