Skip to content
Latchkey

Validate workflow (VigoZhao/AI-Visual-Prompt-Cookbook)

The Validate workflow from VigoZhao/AI-Visual-Prompt-Cookbook, 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: VigoZhao/AI-Visual-Prompt-Cookbook.github/workflows/validate.ymlLicense MITView source

What it does

This is the Validate workflow from the VigoZhao/AI-Visual-Prompt-Cookbook 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: Validate

on:
  push:
    branches: [main]
  pull_request:

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Validate style.json files
        run: python3 scripts/validate-style-json.py

      - name: Check generated site data is in sync
        run: |
          python3 scripts/build-pages-mvp.py
          python3 scripts/generate-copy-prompts.py
          git diff --exit-code -- site/styles-data.js docs/ || {
            echo "::error::Generated files are out of sync. Run scripts/build-pages-mvp.py and scripts/generate-copy-prompts.py, then commit the result."
            exit 1
          }

      - name: Check every style has a gallery thumbnail
        run: |
          fail=0
          for d in styles/*/; do
            slug=$(basename "$d")
            if [ ! -f "assets/thumbs/$slug-16x9.jpg" ]; then
              echo "::error::missing assets/thumbs/$slug-16x9.jpg (run scripts/generate-thumbnails.py)"
              fail=1
            fi
          done
          exit $fail

      - name: Check style folders contain exactly the three public files
        run: |
          fail=0
          for d in styles/*/; do
            files=$(ls "$d" | grep -v '^\.DS_Store$' | sort | tr '\n' ' ')
            if [ "$files" != "preview-16x9.jpg preview-9x16.jpg style.json " ]; then
              echo "::error::$d has unexpected contents: $files"
              fail=1
            fi
          done
          exit $fail

The same workflow, on Latchkey

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

name: Validate
 
on:
  push:
    branches: [main]
  pull_request:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  validate:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v4
 
      - name: Validate style.json files
        run: python3 scripts/validate-style-json.py
 
      - name: Check generated site data is in sync
        run: |
          python3 scripts/build-pages-mvp.py
          python3 scripts/generate-copy-prompts.py
          git diff --exit-code -- site/styles-data.js docs/ || {
            echo "::error::Generated files are out of sync. Run scripts/build-pages-mvp.py and scripts/generate-copy-prompts.py, then commit the result."
            exit 1
          }
 
      - name: Check every style has a gallery thumbnail
        run: |
          fail=0
          for d in styles/*/; do
            slug=$(basename "$d")
            if [ ! -f "assets/thumbs/$slug-16x9.jpg" ]; then
              echo "::error::missing assets/thumbs/$slug-16x9.jpg (run scripts/generate-thumbnails.py)"
              fail=1
            fi
          done
          exit $fail
 
      - name: Check style folders contain exactly the three public files
        run: |
          fail=0
          for d in styles/*/; do
            files=$(ls "$d" | grep -v '^\.DS_Store$' | sort | tr '\n' ' ')
            if [ "$files" != "preview-16x9.jpg preview-9x16.jpg style.json " ]; then
              echo "::error::$d has unexpected contents: $files"
              fail=1
            fi
          done
          exit $fail
 

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