Skip to content
Latchkey

Test Pyodide build workflow (PyWavelets/pywt)

The Test Pyodide build workflow from PyWavelets/pywt, 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: PyWavelets/pywt.github/workflows/emscripten.ymlLicense MITView source

What it does

This is the Test Pyodide build workflow from the PyWavelets/pywt 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: Test Pyodide build

on:
  push:
    branches:
      # Runs on every merge to main to upload .dev0 wheels to anaconda.org
      - main
      - v1.**
  pull_request:
    branches:
      - main
      - v1.**
  # Make it possible to upload wheels manually if needed
  workflow_dispatch:
    inputs:
      push_wheels:
        description: >
          'Push wheels to Anaconda if "true". Default is "false". Warning: this will overwrite existing wheels.'
        required: false
        default: "false"
  # Upload wheels to anaconda.org on a schedule
  schedule:
    # Run at 0300 hours on days 3 and 17 of the month
    - cron: "0 3 3,17 * *"

env:
  FORCE_COLOR: 3

jobs:
  build_wasm_emscripten:
    name: Build PyWavelets for Pyodide
    runs-on: ubuntu-22.04
    # Comment out the following line to test changes on a fork
    if: github.repository == 'PyWavelets/pywt'
    steps:
      - name: Check out repository
        uses: actions/checkout@v6.0.2

      - name: Build and test PyWavelets
        uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
        env:
          CIBW_PLATFORM: pyodide
          CIBW_TEST_REQUIRES: pytest matplotlib
          CIBW_TEST_COMMAND: python -c "import pywt; pywt.test(extra_argv=['-m', 'not slow'])"

        # https://anaconda.org/scientific-python-nightly-wheels/pywavelets
        # WARNING: this job will overwrite existing wheels.
      - name: Push wheels to Anaconda PyPI index
        if: >-
          (github.repository == 'PyWavelets/pywt') &&
          (github.event_name == 'push' && github.ref == 'refs/heads/main') ||
          (github.event_name == 'workflow_dispatch' && github.event.inputs.push_wheels == 'true') ||
          (github.event_name == 'schedule')
        uses: scientific-python/upload-nightly-action@e76cfec8a4611fd02808a801b0ff5a7d7c1b2d99 # v0.6.4
        with:
          artifacts_path: wheelhouse/
          anaconda_nightly_upload_token: ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }}

The same workflow, on Latchkey

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

name: Test Pyodide build
 
on:
  push:
    branches:
      # Runs on every merge to main to upload .dev0 wheels to anaconda.org
      - main
      - v1.**
  pull_request:
    branches:
      - main
      - v1.**
  # Make it possible to upload wheels manually if needed
  workflow_dispatch:
    inputs:
      push_wheels:
        description: >
          'Push wheels to Anaconda if "true". Default is "false". Warning: this will overwrite existing wheels.'
        required: false
        default: "false"
  # Upload wheels to anaconda.org on a schedule
  schedule:
    # Run at 0300 hours on days 3 and 17 of the month
    - cron: "0 3 3,17 * *"
 
env:
  FORCE_COLOR: 3
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build_wasm_emscripten:
    timeout-minutes: 30
    name: Build PyWavelets for Pyodide
    runs-on: latchkey-small
    # Comment out the following line to test changes on a fork
    if: github.repository == 'PyWavelets/pywt'
    steps:
      - name: Check out repository
        uses: actions/checkout@v6.0.2
 
      - name: Build and test PyWavelets
        uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1
        env:
          CIBW_PLATFORM: pyodide
          CIBW_TEST_REQUIRES: pytest matplotlib
          CIBW_TEST_COMMAND: python -c "import pywt; pywt.test(extra_argv=['-m', 'not slow'])"
 
        # https://anaconda.org/scientific-python-nightly-wheels/pywavelets
        # WARNING: this job will overwrite existing wheels.
      - name: Push wheels to Anaconda PyPI index
        if: >-
          (github.repository == 'PyWavelets/pywt') &&
          (github.event_name == 'push' && github.ref == 'refs/heads/main') ||
          (github.event_name == 'workflow_dispatch' && github.event.inputs.push_wheels == 'true') ||
          (github.event_name == 'schedule')
        uses: scientific-python/upload-nightly-action@e76cfec8a4611fd02808a801b0ff5a7d7c1b2d99 # v0.6.4
        with:
          artifacts_path: wheelhouse/
          anaconda_nightly_upload_token: ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }}
 

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