Skip to content
Latchkey

test workflow (datamol-io/graphium)

The test workflow from datamol-io/graphium, explained and optimized by Latchkey.

B

CI health: B - good

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: datamol-io/graphium.github/workflows/test.ymlLicense Apache-2.0View source

What it does

This is the test workflow from the datamol-io/graphium repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.

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

The workflow

workflow (.yml)
name: test

on:
  push:
    branches: ["main"]
    tags: ["*"]
  pull_request:
    branches:
      - "*"
      - "!gh-pages"
  schedule:
    - cron: "0 4 * * *"

jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.8", "3.9", "3.10"]
        pytorch-version: ["2.0"]

    runs-on: "ubuntu-latest"
    timeout-minutes: 30

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

    name: |
        regular_env -
        python=${{ matrix.python-version }} -
        pytorch=${{ matrix.pytorch-version }}

    steps:
      - name: Checkout the code
        uses: actions/checkout@v3

      - name: Setup mamba
        uses: mamba-org/setup-micromamba@v1
        with:
          environment-file: env.yml
          environment-name: graphium
          cache-environment: true
          cache-downloads: true
          create-args: >-
            python=${{ matrix.python-version }}
            pytorch=${{ matrix.pytorch-version }}

      - name: Install library
        run: python -m pip install --no-deps -e . # `-e` required for correct `coverage` run.

      - name: Run tests
        run: pytest -m 'not ipu'

      - name: Test CLI
        run: graphium --help

      - name: Test building the doc
        run: mkdocs build

      - name: Codecov Upload
        uses: codecov/codecov-action@v3
        with:
          files: ./coverage.xml
          flags: unittests
          name: codecov-umbrella
          fail_ci_if_error: false
          verbose: false
          env_vars: ${{ matrix.python-version }},${{ matrix.pytorch-version }}

The same workflow, on Latchkey

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

name: test
 
on:
  push:
    branches: ["main"]
    tags: ["*"]
  pull_request:
    branches:
      - "*"
      - "!gh-pages"
  schedule:
    - cron: "0 4 * * *"
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.8", "3.9", "3.10"]
        pytorch-version: ["2.0"]
 
    runs-on: "ubuntu-latest"
    timeout-minutes: 30
 
    defaults:
      run:
        shell: bash -l {0}
 
    name: |
        regular_env -
        python=${{ matrix.python-version }} -
        pytorch=${{ matrix.pytorch-version }}
 
    steps:
      - name: Checkout the code
        uses: actions/checkout@v3
 
      - name: Setup mamba
        uses: mamba-org/setup-micromamba@v1
        with:
          environment-file: env.yml
          environment-name: graphium
          cache-environment: true
          cache-downloads: true
          create-args: >-
            python=${{ matrix.python-version }}
            pytorch=${{ matrix.pytorch-version }}
 
      - name: Install library
        run: python -m pip install --no-deps -e . # `-e` required for correct `coverage` run.
 
      - name: Run tests
        run: pytest -m 'not ipu'
 
      - name: Test CLI
        run: graphium --help
 
      - name: Test building the doc
        run: mkdocs build
 
      - name: Codecov Upload
        uses: codecov/codecov-action@v3
        with:
          files: ./coverage.xml
          flags: unittests
          name: codecov-umbrella
          fail_ci_if_error: false
          verbose: false
          env_vars: ${{ matrix.python-version }},${{ matrix.pytorch-version }}
 

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 (3 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