Skip to content
Latchkey

Build Docs workflow (CASIA-IVA-Lab/DANet)

The Build Docs workflow from CASIA-IVA-Lab/DANet, explained and optimized by Latchkey.

C

CI health: C - fair

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: CASIA-IVA-Lab/DANet.github/workflows/sphix_build_pr.ymlLicense MITView source

What it does

This is the Build Docs workflow from the CASIA-IVA-Lab/DANet 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)
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Build Docs

on: 
  pull_request:
    branches: [ master ]

jobs:
  docs:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v2
      - uses: seanmiddleditch/gha-setup-ninja@master

      - name: Set PR Number
        uses: actions/github-script@0.3.0
        with:
          github-token: ${{github.token}}
          script: |
            const core = require('@actions/core')
            const prNumber = context.payload.number;
            core.exportVariable('PULL_NUMBER', prNumber);
            core.exportVariable("PATH", "/home/ubuntu/anaconda3/bin:/usr/local/bin:/usr/bin/:/bin:$PATH")
        
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install numpy -I
          pip install pytest torch
          
      - name: Install package
        run: |
          pip install -e .
          
      - name: Install Sphix Dependencies
        run: |
          cd docs/
          pip install -r requirements.txt
          
      - name: Build Sphinx docs
        run: |
          cd docs/
          make html
          touch build/html/.nojekyll
          aws s3 sync build/html/ s3://hangzh/encoding/docs/${{ env.PULL_NUMBER }}/ --acl public-read --follow-symlinks --delete
          
      - name: Comment
        if: success()
        uses: thollander/actions-comment-pull-request@master
        with:
          message: "The docs are uploaded and can be previewed at http://hangzh.s3.amazonaws.com/encoding/docs/${{ env.PULL_NUMBER }}/index.html"
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The same workflow, on Latchkey

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

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
 
name: Build Docs
 
on: 
  pull_request:
    branches: [ master ]
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  docs:
    timeout-minutes: 30
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v2
      - uses: seanmiddleditch/gha-setup-ninja@master
 
      - name: Set PR Number
        uses: actions/github-script@0.3.0
        with:
          github-token: ${{github.token}}
          script: |
            const core = require('@actions/core')
            const prNumber = context.payload.number;
            core.exportVariable('PULL_NUMBER', prNumber);
            core.exportVariable("PATH", "/home/ubuntu/anaconda3/bin:/usr/local/bin:/usr/bin/:/bin:$PATH")
        
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install numpy -I
          pip install pytest torch
          
      - name: Install package
        run: |
          pip install -e .
          
      - name: Install Sphix Dependencies
        run: |
          cd docs/
          pip install -r requirements.txt
          
      - name: Build Sphinx docs
        run: |
          cd docs/
          make html
          touch build/html/.nojekyll
          aws s3 sync build/html/ s3://hangzh/encoding/docs/${{ env.PULL_NUMBER }}/ --acl public-read --follow-symlinks --delete
          
      - name: Comment
        if: success()
        uses: thollander/actions-comment-pull-request@master
        with:
          message: "The docs are uploaded and can be previewed at http://hangzh.s3.amazonaws.com/encoding/docs/${{ env.PULL_NUMBER }}/index.html"
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 

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