Skip to content
Latchkey

Fragments check workflow (hikari-py/hikari)

The Fragments check workflow from hikari-py/hikari, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: hikari-py/hikari.github/workflows/fragments-check.ymlLicense MITView source

What it does

This is the Fragments check workflow from the hikari-py/hikari repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Fragments check

on:
  pull_request:
    types: [labeled, unlabeled, opened, reopened, synchronize]
    branches:
      - master

jobs:
  check-fragment-added:
    if: github.event.pull_request.user.type != 'Bot' && !contains(github.event.pull_request.labels.*.name, 'skip-fragment-check')
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          # `towncrier check` runs `git diff --name-only origin/main...`, which
          # needs a non-shallow clone.
          fetch-depth: 0

      - name: Setup uv
        uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
        with:
          python-version: 3.14
          activate-environment: true

      - name: Check if changelog fragment was added
        run: |
          uv sync --frozen --only-group towncrier

          if ! towncrier check --compare-with origin/${{ github.base_ref }}; then
            exit 1
          fi

      - name: Check if linked to the correct pull request
        run: |
          diff=$(git diff origin/${{ github.base_ref }} HEAD --name-only)

          changelog_fragments=$(echo "$diff" | grep "^changes/")
          valid_changelog_fragments=$(echo "$diff" | grep "^changes/${{ github.event.number }}\.")

          if [ "$changelog_fragments" != "$valid_changelog_fragments" ]; then
            exit 1
          fi

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Fragments check
 
on:
  pull_request:
    types: [labeled, unlabeled, opened, reopened, synchronize]
    branches:
      - master
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  check-fragment-added:
    timeout-minutes: 30
    if: github.event.pull_request.user.type != 'Bot' && !contains(github.event.pull_request.labels.*.name, 'skip-fragment-check')
    runs-on: latchkey-small
 
    steps:
      - name: Checkout repository
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          # `towncrier check` runs `git diff --name-only origin/main...`, which
          # needs a non-shallow clone.
          fetch-depth: 0
 
      - name: Setup uv
        uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
        with:
          python-version: 3.14
          activate-environment: true
 
      - name: Check if changelog fragment was added
        run: |
          uv sync --frozen --only-group towncrier
 
          if ! towncrier check --compare-with origin/${{ github.base_ref }}; then
            exit 1
          fi
 
      - name: Check if linked to the correct pull request
        run: |
          diff=$(git diff origin/${{ github.base_ref }} HEAD --name-only)
 
          changelog_fragments=$(echo "$diff" | grep "^changes/")
          valid_changelog_fragments=$(echo "$diff" | grep "^changes/${{ github.event.number }}\.")
 
          if [ "$changelog_fragments" != "$valid_changelog_fragments" ]; then
            exit 1
          fi
 

What changed

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow