Skip to content
Latchkey

Unit Tests workflow (awslabs/amazon-s3-find-and-forget)

The Unit Tests workflow from awslabs/amazon-s3-find-and-forget, explained and optimized by Latchkey.

F

CI health: F - at risk

Point runs-on at Latchkey and get caching, 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: awslabs/amazon-s3-find-and-forget.github/workflows/unit-tests.yamlLicense Apache-2.0View source

What it does

This is the Unit Tests workflow from the awslabs/amazon-s3-find-and-forget 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: Unit Tests
on:
  push:
    branches:
      - master
  pull_request:
    types:
      - opened
      - edited
      - synchronize
permissions:
  contents: read

jobs:
  unit_tests:
    name: Unit tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      # Cache
      - uses: actions/cache@v4
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-
      - uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-
      # Setup
      - name: Install snappy dep
        run: sudo apt-get install libsnappy-dev
      - name: Set up Python 3.12
        uses: actions/setup-python@v1
        with:
          python-version: 3.12
      - name: Set up Nodejs 20
        uses: actions/setup-node@v1
        with:
          node-version: 20
      - name: Set up ruby 3.3
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: '3.3'
      - name: Install virtualenv
        run: pip install virtualenv
      - name: Install dependencies
        run: make setup
      # Run Tests
      - name: CloudFormation unit tests
        run: make test-cfn
      - name: Backend unit tests
        run: make test-ci
        env:
          AWS_DEFAULT_REGION: eu-west-1
      - name: Frontend unit tests
        run: make test-frontend
      - name: Upload unit test coverage reports to Codecov
        uses: codecov/codecov-action@v4
        with:
          fail_ci_if_error: false
          token: ${{ secrets.CODECOV_TOKEN }}
          verbose: true

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: Unit Tests
on:
  push:
    branches:
      - master
  pull_request:
    types:
      - opened
      - edited
      - synchronize
permissions:
  contents: read
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  unit_tests:
    timeout-minutes: 30
    name: Unit tests
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v2
      # Cache
      - uses: actions/cache@v4
        with:
          path: ~/.npm
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-
      - uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-
      # Setup
      - name: Install snappy dep
        run: sudo apt-get install libsnappy-dev
      - name: Set up Python 3.12
        uses: actions/setup-python@v1
        with:
          python-version: 3.12
      - name: Set up Nodejs 20
        uses: actions/setup-node@v1
        with:
          cache: 'npm'
          node-version: 20
      - name: Set up ruby 3.3
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: '3.3'
      - name: Install virtualenv
        run: pip install virtualenv
      - name: Install dependencies
        run: make setup
      # Run Tests
      - name: CloudFormation unit tests
        run: make test-cfn
      - name: Backend unit tests
        run: make test-ci
        env:
          AWS_DEFAULT_REGION: eu-west-1
      - name: Frontend unit tests
        run: make test-frontend
      - name: Upload unit test coverage reports to Codecov
        uses: codecov/codecov-action@v4
        with:
          fail_ci_if_error: false
          token: ${{ secrets.CODECOV_TOKEN }}
          verbose: true
 

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

Actions used in this workflow