Skip to content
Latchkey

opencli-plugin-test workflow (himself65/finance-skills)

The opencli-plugin-test workflow from himself65/finance-skills, explained and optimized by Latchkey.

D

CI health: D - needs work

Point runs-on at Latchkey and get caching, 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: himself65/finance-skills.github/workflows/opencli-plugin-test.ymlLicense MITView source

What it does

This is the opencli-plugin-test workflow from the himself65/finance-skills 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: opencli-plugin-test
on:
  push:
    branches: [main]
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '22'
      - name: Run unit tests for every plugin under opencli-plugins/
        run: |
          set -euo pipefail
          shopt -s nullglob

          plugins=(opencli-plugins/*/)
          if [ ${#plugins[@]} -eq 0 ]; then
            echo "No opencli plugins found"
            exit 0
          fi

          any_tested=0
          for dir in "${plugins[@]}"; do
            name="${dir#opencli-plugins/}"
            name="${name%/}"

            if [ ! -f "${dir}package.json" ]; then
              echo "::notice::Skipping ${name} - no package.json"
              continue
            fi
            if ! compgen -G "${dir}tests/*.test.js" >/dev/null; then
              echo "::notice::Skipping ${name} - no tests/*.test.js"
              continue
            fi

            echo "::group::Testing ${name}"
            (cd "$dir" && npm test)
            echo "::endgroup::"
            any_tested=1
          done

          if [ $any_tested -eq 0 ]; then
            echo "::warning::No plugin had a runnable test suite"
          fi

The same workflow, on Latchkey

Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.

name: opencli-plugin-test
on:
  push:
    branches: [main]
  pull_request:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          cache: 'npm'
          node-version: '22'
      - name: Run unit tests for every plugin under opencli-plugins/
        run: |
          set -euo pipefail
          shopt -s nullglob
 
          plugins=(opencli-plugins/*/)
          if [ ${#plugins[@]} -eq 0 ]; then
            echo "No opencli plugins found"
            exit 0
          fi
 
          any_tested=0
          for dir in "${plugins[@]}"; do
            name="${dir#opencli-plugins/}"
            name="${name%/}"
 
            if [ ! -f "${dir}package.json" ]; then
              echo "::notice::Skipping ${name} - no package.json"
              continue
            fi
            if ! compgen -G "${dir}tests/*.test.js" >/dev/null; then
              echo "::notice::Skipping ${name} - no tests/*.test.js"
              continue
            fi
 
            echo "::group::Testing ${name}"
            (cd "$dir" && npm test)
            echo "::endgroup::"
            any_tested=1
          done
 
          if [ $any_tested -eq 0 ]; then
            echo "::warning::No plugin had a runnable test suite"
          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