Skip to content
Latchkey

Tests workflow (jupyter-widgets-contrib/ipygany)

The Tests workflow from jupyter-widgets-contrib/ipygany, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get run de-duplication, 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: jupyter-widgets-contrib/ipygany.github/workflows/main.ymlLicense BSD-3-ClauseView source

What it does

This is the Tests workflow from the jupyter-widgets-contrib/ipygany repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Tests

on:
  push:
    branches:
    - master
  pull_request:
    branches:
    - master

defaults:
  run:
    shell: bash -l {0}

jobs:
  tests:
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest]
        python-version: [3.9]

    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Setup conda
      uses: conda-incubator/setup-miniconda@v2
      with:
        activate-environment: ipygany-dev
        environment-file: dev_environment.yml
        python-version: ${{ matrix.python-version }}
        mamba-version: "*"
        auto-activate-base: false
        channels: conda-forge

    - name: Workaround pytest issue
      run: pip install pytest_tornasync

    - name: Test flake8
      run: flake8 ipygany --ignore=E501

    - name: Install ipygany
      run: pip install .

    - name: Check installation files
      run: |
        test -d $CONDA_PREFIX/share/jupyter/nbextensions/ipygany
        test -f $CONDA_PREFIX/share/jupyter/nbextensions/ipygany/extension.js
        test -f $CONDA_PREFIX/share/jupyter/nbextensions/ipygany/index.js
        test -d $CONDA_PREFIX/share/jupyter/labextensions/ipygany
        test -f $CONDA_PREFIX/share/jupyter/labextensions/ipygany/package.json

    - name: Check nbextension and labextension
      run: |
        jupyter nbextension list 2>&1 | grep -ie "ipygany/extension.*enabled" -
        jupyter labextension list 2>&1 | grep -ie "ipygany.*enabled.*ok" -

    - name: Run Python tests
      run: pytest tests

    - name: Build docs (Only on MacOS for build speed)
      if: matrix.os == 'macos-latest'
      run: |
        mamba install sphinx sphinx_rtd_theme pygments==2.6.1 jupyter-sphinx meshpy pyvista
        cd docs/source/
        sphinx-build . _build/html
        cd ../..

  build:
    runs-on: ubuntu-latest
    steps:

    - name: Checkout
      uses: actions/checkout@v2

    - name: Setup conda
      uses: conda-incubator/setup-miniconda@v2
      with:
        activate-environment: ipygany-dev
        environment-file: dev_environment.yml
        python-version: ${{ matrix.python-version }}
        mamba-version: "*"
        auto-activate-base: false
        channels: conda-forge

    - name: Build packages
      run: |
        python setup.py sdist bdist_wheel
        cd dist
        sha256sum * | tee SHA256SUMS

    - name: Upload builds
      uses: actions/upload-artifact@v2
      with:
        name: dist ${{ github.run_number }}
        path: ./dist

  install:
    runs-on: ${{ matrix.os }}-latest
    needs: [build]

    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu, macos, windows]
        python: ['3.6', '3.9']
        include:
          - python: '3.6'
            dist: 'ipygany*.tar.gz'
          - python: '3.9'
            dist: 'ipygany*.whl'

    steps:

      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup conda
        uses: conda-incubator/setup-miniconda@v2
        with:
          activate-environment: ipygany-dev
          environment-file: dev_environment.yml
          python-version: ${{ matrix.python-version }}
          mamba-version: "*"
          auto-activate-base: false
          channels: conda-forge

      - uses: actions/download-artifact@v2
        with:
          name: dist ${{ github.run_number }}
          path: ./dist

      - name: Install the package
        run: |
          cd dist
          pip install -vv ${{ matrix.dist }}

      - name: Test installation files
        run: |
          test -d $CONDA_PREFIX/share/jupyter/nbextensions/ipygany
          test -f $CONDA_PREFIX/share/jupyter/nbextensions/ipygany/extension.js
          test -f $CONDA_PREFIX/share/jupyter/nbextensions/ipygany/index.js
          test -d $CONDA_PREFIX/share/jupyter/labextensions/ipygany
          test -f $CONDA_PREFIX/share/jupyter/labextensions/ipygany/package.json
          test -d $CONDA_PREFIX/share/jupyter/labextensions/ipygany/static

      - name: Validate the nbextension
        run: jupyter nbextension list 2>&1 | grep "ipygany/extension"

      - name: Validate the labextension
        run: jupyter labextension list 2>&1 | grep ipygany

The same workflow, on Latchkey

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

name: Tests
 
on:
  push:
    branches:
    - master
  pull_request:
    branches:
    - master
 
defaults:
  run:
    shell: bash -l {0}
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  tests:
    timeout-minutes: 30
    runs-on: ${{ matrix.os }}
 
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest]
        python-version: [3.9]
 
    steps:
    - name: Checkout
      uses: actions/checkout@v2
 
    - name: Setup conda
      uses: conda-incubator/setup-miniconda@v2
      with:
        activate-environment: ipygany-dev
        environment-file: dev_environment.yml
        python-version: ${{ matrix.python-version }}
        mamba-version: "*"
        auto-activate-base: false
        channels: conda-forge
 
    - name: Workaround pytest issue
      run: pip install pytest_tornasync
 
    - name: Test flake8
      run: flake8 ipygany --ignore=E501
 
    - name: Install ipygany
      run: pip install .
 
    - name: Check installation files
      run: |
        test -d $CONDA_PREFIX/share/jupyter/nbextensions/ipygany
        test -f $CONDA_PREFIX/share/jupyter/nbextensions/ipygany/extension.js
        test -f $CONDA_PREFIX/share/jupyter/nbextensions/ipygany/index.js
        test -d $CONDA_PREFIX/share/jupyter/labextensions/ipygany
        test -f $CONDA_PREFIX/share/jupyter/labextensions/ipygany/package.json
 
    - name: Check nbextension and labextension
      run: |
        jupyter nbextension list 2>&1 | grep -ie "ipygany/extension.*enabled" -
        jupyter labextension list 2>&1 | grep -ie "ipygany.*enabled.*ok" -
 
    - name: Run Python tests
      run: pytest tests
 
    - name: Build docs (Only on MacOS for build speed)
      if: matrix.os == 'macos-latest'
      run: |
        mamba install sphinx sphinx_rtd_theme pygments==2.6.1 jupyter-sphinx meshpy pyvista
        cd docs/source/
        sphinx-build . _build/html
        cd ../..
 
  build:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
 
    - name: Checkout
      uses: actions/checkout@v2
 
    - name: Setup conda
      uses: conda-incubator/setup-miniconda@v2
      with:
        activate-environment: ipygany-dev
        environment-file: dev_environment.yml
        python-version: ${{ matrix.python-version }}
        mamba-version: "*"
        auto-activate-base: false
        channels: conda-forge
 
    - name: Build packages
      run: |
        python setup.py sdist bdist_wheel
        cd dist
        sha256sum * | tee SHA256SUMS
 
    - name: Upload builds
      uses: actions/upload-artifact@v2
      with:
        name: dist ${{ github.run_number }}
        path: ./dist
 
  install:
    timeout-minutes: 30
    runs-on: ${{ matrix.os }}-latest
    needs: [build]
 
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu, macos, windows]
        python: ['3.6', '3.9']
        include:
          - python: '3.6'
            dist: 'ipygany*.tar.gz'
          - python: '3.9'
            dist: 'ipygany*.whl'
 
    steps:
 
      - name: Checkout
        uses: actions/checkout@v2
 
      - name: Setup conda
        uses: conda-incubator/setup-miniconda@v2
        with:
          activate-environment: ipygany-dev
          environment-file: dev_environment.yml
          python-version: ${{ matrix.python-version }}
          mamba-version: "*"
          auto-activate-base: false
          channels: conda-forge
 
      - uses: actions/download-artifact@v2
        with:
          name: dist ${{ github.run_number }}
          path: ./dist
 
      - name: Install the package
        run: |
          cd dist
          pip install -vv ${{ matrix.dist }}
 
      - name: Test installation files
        run: |
          test -d $CONDA_PREFIX/share/jupyter/nbextensions/ipygany
          test -f $CONDA_PREFIX/share/jupyter/nbextensions/ipygany/extension.js
          test -f $CONDA_PREFIX/share/jupyter/nbextensions/ipygany/index.js
          test -d $CONDA_PREFIX/share/jupyter/labextensions/ipygany
          test -f $CONDA_PREFIX/share/jupyter/labextensions/ipygany/package.json
          test -d $CONDA_PREFIX/share/jupyter/labextensions/ipygany/static
 
      - name: Validate the nbextension
        run: jupyter nbextension list 2>&1 | grep "ipygany/extension"
 
      - name: Validate the labextension
        run: jupyter labextension list 2>&1 | grep ipygany
 

What changed

1 third-party action is referenced by a movable tag. Pin it 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 3 jobs (9 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