Skip to content
Latchkey

Run Tests workflow (Titan-Systems/titan)

The Run Tests workflow from Titan-Systems/titan, 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: Titan-Systems/titan.github/workflows/run-tests.ymlLicense Apache-2.0View source

What it does

This is the Run Tests workflow from the Titan-Systems/titan 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: Run Tests

on:
  push:
    branches: [ main ]
    paths-ignore:
    - version.md
  pull_request:
    branches: [ main ]
  workflow_dispatch:
  workflow_call:
    secrets:
      TEST_SNOWFLAKE_ACCOUNT:
        required: true
      TEST_SNOWFLAKE_USER:
        required: true
      TEST_SNOWFLAKE_PASSWORD:
        required: true
      VAR_STORAGE_BASE_URL:
        required: true
      VAR_STORAGE_ROLE_ARN:
        required: true
      VAR_STORAGE_AWS_EXTERNAL_ID:
        required: true
      CODECOV_TOKEN:
        required: true

jobs:
  build:
    runs-on: blacksmith-4vcpu-ubuntu-2204
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.9", "3.10", "3.11"]
    steps:
    - uses: actions/checkout@v4
    - name: Set up Python ${{ matrix.python-version }}
      uses: useblacksmith/setup-python@v6
      with:
        python-version: ${{ matrix.python-version }}
    - name: Create a virtual environment
      run: |
        python -m venv .venv
    - name: Install dependencies
      run: |
        source ./.venv/bin/activate
        python -m pip install --upgrade pip
        make install-dev
    - name: Run checks (linter, code style, static type checks, tests)
      run: |
        source ./.venv/bin/activate
        ruff check titan/
        make typecheck
        python -m pytest --cov=./ --cov-report=xml
    - name: Upload coverage reports to Codecov
      uses: codecov/codecov-action@v4
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  integration:
    runs-on: blacksmith-4vcpu-ubuntu-2204
    strategy:
      fail-fast: false
      matrix:
        include:
          - environment: snowflake-gcp-standard
            edition: standard
          - environment: snowflake-aws-standard
            edition: standard
          - environment: snowflake-aws-enterprise
            edition: enterprise
          - environment: snowflake-aws-business-critical
            edition: enterprise
          - environment: snowflake-azure-standard
            edition: standard
    environment: ${{ matrix.environment }}
    steps:
    - uses: actions/checkout@v4
    - name: Set up Python 3.9
      uses: useblacksmith/setup-python@v6
      with:
        python-version: 3.9
    - name: Create a virtual environment
      run: |
        python -m venv .venv
    - name: Install dependencies
      run: |
        source ./.venv/bin/activate
        python -m pip install --upgrade pip
        make install-dev
    - name: Run integration tests
      run: |
        source ./.venv/bin/activate
        python -m pytest --snowflake -m "standard or ${{ matrix.edition }}" --cov=./ --cov-report=xml
      env:
        TEST_SNOWFLAKE_ACCOUNT: ${{ secrets.TEST_SNOWFLAKE_ACCOUNT }}
        TEST_SNOWFLAKE_USER: ${{ secrets.TEST_SNOWFLAKE_USER }}
        TEST_SNOWFLAKE_PASSWORD: ${{ secrets.TEST_SNOWFLAKE_PASSWORD }}
        VAR_STORAGE_BASE_URL: ${{ secrets.VAR_STORAGE_BASE_URL }}
        VAR_STORAGE_ROLE_ARN: ${{ secrets.VAR_STORAGE_ROLE_ARN }}
        VAR_STORAGE_AWS_EXTERNAL_ID: ${{ secrets.VAR_STORAGE_AWS_EXTERNAL_ID }}
        TEST_SNOWFLAKE_ROLE: ACCOUNTADMIN
    - name: Upload coverage reports to Codecov
      uses: codecov/codecov-action@v4
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

The same workflow, on Latchkey

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

name: Run Tests
 
on:
  push:
    branches: [ main ]
    paths-ignore:
    - version.md
  pull_request:
    branches: [ main ]
  workflow_dispatch:
  workflow_call:
    secrets:
      TEST_SNOWFLAKE_ACCOUNT:
        required: true
      TEST_SNOWFLAKE_USER:
        required: true
      TEST_SNOWFLAKE_PASSWORD:
        required: true
      VAR_STORAGE_BASE_URL:
        required: true
      VAR_STORAGE_ROLE_ARN:
        required: true
      VAR_STORAGE_AWS_EXTERNAL_ID:
        required: true
      CODECOV_TOKEN:
        required: true
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    timeout-minutes: 30
    runs-on: blacksmith-4vcpu-ubuntu-2204
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.9", "3.10", "3.11"]
    steps:
    - uses: actions/checkout@v4
    - name: Set up Python ${{ matrix.python-version }}
      uses: useblacksmith/setup-python@v6
      with:
        python-version: ${{ matrix.python-version }}
    - name: Create a virtual environment
      run: |
        python -m venv .venv
    - name: Install dependencies
      run: |
        source ./.venv/bin/activate
        python -m pip install --upgrade pip
        make install-dev
    - name: Run checks (linter, code style, static type checks, tests)
      run: |
        source ./.venv/bin/activate
        ruff check titan/
        make typecheck
        python -m pytest --cov=./ --cov-report=xml
    - name: Upload coverage reports to Codecov
      uses: codecov/codecov-action@v4
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
  integration:
    timeout-minutes: 30
    runs-on: blacksmith-4vcpu-ubuntu-2204
    strategy:
      fail-fast: false
      matrix:
        include:
          - environment: snowflake-gcp-standard
            edition: standard
          - environment: snowflake-aws-standard
            edition: standard
          - environment: snowflake-aws-enterprise
            edition: enterprise
          - environment: snowflake-aws-business-critical
            edition: enterprise
          - environment: snowflake-azure-standard
            edition: standard
    environment: ${{ matrix.environment }}
    steps:
    - uses: actions/checkout@v4
    - name: Set up Python 3.9
      uses: useblacksmith/setup-python@v6
      with:
        python-version: 3.9
    - name: Create a virtual environment
      run: |
        python -m venv .venv
    - name: Install dependencies
      run: |
        source ./.venv/bin/activate
        python -m pip install --upgrade pip
        make install-dev
    - name: Run integration tests
      run: |
        source ./.venv/bin/activate
        python -m pytest --snowflake -m "standard or ${{ matrix.edition }}" --cov=./ --cov-report=xml
      env:
        TEST_SNOWFLAKE_ACCOUNT: ${{ secrets.TEST_SNOWFLAKE_ACCOUNT }}
        TEST_SNOWFLAKE_USER: ${{ secrets.TEST_SNOWFLAKE_USER }}
        TEST_SNOWFLAKE_PASSWORD: ${{ secrets.TEST_SNOWFLAKE_PASSWORD }}
        VAR_STORAGE_BASE_URL: ${{ secrets.VAR_STORAGE_BASE_URL }}
        VAR_STORAGE_ROLE_ARN: ${{ secrets.VAR_STORAGE_ROLE_ARN }}
        VAR_STORAGE_AWS_EXTERNAL_ID: ${{ secrets.VAR_STORAGE_AWS_EXTERNAL_ID }}
        TEST_SNOWFLAKE_ROLE: ACCOUNTADMIN
    - name: Upload coverage reports to Codecov
      uses: codecov/codecov-action@v4
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_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 2 jobs (4 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