Skip to content
Latchkey

Spec Update workflow (dropbox/dropbox-sdk-python)

The Spec Update workflow from dropbox/dropbox-sdk-python, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get caching, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: dropbox/dropbox-sdk-python.github/workflows/spec_update.ymlLicense MITView source

What it does

This is the Spec Update workflow from the dropbox/dropbox-sdk-python 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: Spec Update
on:
  workflow_dispatch:
  repository_dispatch:
    types: [spec_update]

jobs:
  Update:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - name: Setup Python environment
        uses: actions/setup-python@v6
        with:
          python-version: '3.11'
      - name: Get current time
        uses: 1466587594/get-current-time@v2
        id: current-time
        with:
          format: YYYY_MM_DD
          utcOffset: "-08:00"
      - name: Update Modules
        run: |
          git submodule init
          git submodule update --remote --recursive
      - name: Generate Branch Name
        id: git-branch
        run: |
          echo "::set-output name=branch::spec_update_${{ steps.current-time.outputs.formattedTime }}"
      - name: Generate Num Diffs
        id: git-diff-num
        run: |
          diffs=$(git diff --submodule spec | grep ">" | wc -l)
          echo "Number of Spec diffs: $diffs"
          echo "::set-output name=num-diff::$diffs"
      - name: Generate Diff
        id: git-diff
        run: |
          cd spec
          gitdiff=$(git log -n ${{ steps.git-diff-num.outputs.num-diff }} --pretty="format:%n %H %n%n %b")
          commit="Automated Spec Update $gitdiff"
          commit="${commit//'%'/'%25'}"
          commit="${commit//$'\n'/'%0A'}"
          commit="${commit//$'\r'/'%0D'}"
          echo "Commit Message: $commit"
          echo "::set-output name=commit::$commit"
          cd ..
      - name: Generate New Routes
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          python generate_base_client.py
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v7
        if: steps.git-diff-num.outputs.num-diff != 0
        with:
          token: ${{ secrets.SPEC_UPDATE_TOKEN }}
          commit-message: |
            ${{ steps.git-diff.outputs.commit}}
          branch: ${{ steps.git-branch.outputs.branch }}
          delete-branch: true
          title: 'Automated Spec Update'
          body: |
            ${{ steps.git-diff.outputs.commit}}
          base: 'main'
          team-reviewers: |
            owners
            maintainers
          draft: false

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: Spec Update
on:
  workflow_dispatch:
  repository_dispatch:
    types: [spec_update]
 
jobs:
  Update:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v5
      - name: Setup Python environment
        uses: actions/setup-python@v6
        with:
          cache: 'pip'
          python-version: '3.11'
      - name: Get current time
        uses: 1466587594/get-current-time@v2
        id: current-time
        with:
          format: YYYY_MM_DD
          utcOffset: "-08:00"
      - name: Update Modules
        run: |
          git submodule init
          git submodule update --remote --recursive
      - name: Generate Branch Name
        id: git-branch
        run: |
          echo "::set-output name=branch::spec_update_${{ steps.current-time.outputs.formattedTime }}"
      - name: Generate Num Diffs
        id: git-diff-num
        run: |
          diffs=$(git diff --submodule spec | grep ">" | wc -l)
          echo "Number of Spec diffs: $diffs"
          echo "::set-output name=num-diff::$diffs"
      - name: Generate Diff
        id: git-diff
        run: |
          cd spec
          gitdiff=$(git log -n ${{ steps.git-diff-num.outputs.num-diff }} --pretty="format:%n %H %n%n %b")
          commit="Automated Spec Update $gitdiff"
          commit="${commit//'%'/'%25'}"
          commit="${commit//$'\n'/'%0A'}"
          commit="${commit//$'\r'/'%0D'}"
          echo "Commit Message: $commit"
          echo "::set-output name=commit::$commit"
          cd ..
      - name: Generate New Routes
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          python generate_base_client.py
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v7
        if: steps.git-diff-num.outputs.num-diff != 0
        with:
          token: ${{ secrets.SPEC_UPDATE_TOKEN }}
          commit-message: |
            ${{ steps.git-diff.outputs.commit}}
          branch: ${{ steps.git-branch.outputs.branch }}
          delete-branch: true
          title: 'Automated Spec Update'
          body: |
            ${{ steps.git-diff.outputs.commit}}
          base: 'main'
          team-reviewers: |
            owners
            maintainers
          draft: false
 

What changed

2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

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