Skip to content
Latchkey

Build workflow (ma1co/Sony-PMCA-RE)

The Build workflow from ma1co/Sony-PMCA-RE, explained and optimized by Latchkey.

D

CI health: D - needs work

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: ma1co/Sony-PMCA-RE.github/workflows/build.ymlLicense MITView source

What it does

This is the Build workflow from the ma1co/Sony-PMCA-RE 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: Build
on: push
jobs:
  PyInstaller:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [windows-2019, macos-10.15]
    defaults:
      run:
        shell: bash
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-python@v2
      with:
        python-version: 3.6
    - name: Install libusb (windows)
      if: runner.os == 'Windows'
      shell: pwsh
      run: |
        Invoke-WebRequest http://jaist.dl.sourceforge.net/project/libusb-win32/libusb-win32-releases/1.2.6.0/libusb-win32-bin-1.2.6.0.zip -OutFile libusb-win32-bin-1.2.6.0.zip
        Expand-Archive libusb-win32-bin-1.2.6.0.zip .
        Move-Item libusb-win32-bin-1.2.6.0\bin\amd64\libusb0.dll .
        echo $env:GITHUB_WORKSPACE | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
    - name: Install libusb (macos)
      if: runner.os == 'macOS'
      run: |
        brew install libusb
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt
    - name: Build
      run: |
        python -OO -m PyInstaller pmca-console.spec
        python -OO -m PyInstaller pmca-gui.spec
    - name: Test
      run: |
        dist/pmca-console* -h
    - name: Upload
      uses: actions/upload-artifact@v2
      with:
        name: ${{ runner.os }} binaries
        path: dist/*
    - name: Release
      if: ${{ startsWith(github.ref, 'refs/tags/') && runner.os != 'Windows' }}
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      run: |
        tag="${GITHUB_REF##*/}"
        assets="$(find dist/* -exec echo -a {} \;)"
        hub release create $assets -m "$tag" "$tag" || hub release edit $assets -m "" "$tag"

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: Build
on: push
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  PyInstaller:
    timeout-minutes: 30
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [windows-2019, macos-10.15]
    defaults:
      run:
        shell: bash
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-python@v2
      with:
        cache: 'pip'
        python-version: 3.6
    - name: Install libusb (windows)
      if: runner.os == 'Windows'
      shell: pwsh
      run: |
        Invoke-WebRequest http://jaist.dl.sourceforge.net/project/libusb-win32/libusb-win32-releases/1.2.6.0/libusb-win32-bin-1.2.6.0.zip -OutFile libusb-win32-bin-1.2.6.0.zip
        Expand-Archive libusb-win32-bin-1.2.6.0.zip .
        Move-Item libusb-win32-bin-1.2.6.0\bin\amd64\libusb0.dll .
        echo $env:GITHUB_WORKSPACE | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
    - name: Install libusb (macos)
      if: runner.os == 'macOS'
      run: |
        brew install libusb
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt
    - name: Build
      run: |
        python -OO -m PyInstaller pmca-console.spec
        python -OO -m PyInstaller pmca-gui.spec
    - name: Test
      run: |
        dist/pmca-console* -h
    - name: Upload
      uses: actions/upload-artifact@v2
      with:
        name: ${{ runner.os }} binaries
        path: dist/*
    - name: Release
      if: ${{ startsWith(github.ref, 'refs/tags/') && runner.os != 'Windows' }}
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      run: |
        tag="${GITHUB_REF##*/}"
        assets="$(find dist/* -exec echo -a {} \;)"
        hub release create $assets -m "$tag" "$tag" || hub release edit $assets -m "" "$tag"
 

What changed

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 (2 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow