Skip to content
Latchkey

GO tests workflow (ChineseSubFinder/ChineseSubFinder)

The GO tests workflow from ChineseSubFinder/ChineseSubFinder, 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: ChineseSubFinder/ChineseSubFinder.github/workflows/build-test.ymlLicense MITView source

What it does

This is the GO tests workflow from the ChineseSubFinder/ChineseSubFinder 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)
on:
  push:
    branches: [master]
  pull_request:
    # The branches below must be a subset of the branches above
    branches: [master]

# for cache
# checkout https://github.com/magnetikonline/action-golang-cache
# https://www.lorenzobettini.it/2020/12/caching-dependencies-in-github-actions/
# https://github.com/mongodb/mongocli/actions/runs/1637632940/workflow

name: GO tests

jobs:
  tests:
    strategy:
      matrix:
        go-version: [1.17]
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Install Go
        uses: actions/setup-go@v2
        with:
          go-version: ${{ matrix.golang }}
      - name: Cache Dependencies
        uses: actions/cache@v2
        with:
          path: ~/go/pkg/mod # not sure if this part needs editing
          key: ${{ runner.os }}-go-${{ matrix.golang }}-${{ hashFiles('**/go.sum') }}
          restore-keys: |
            ${{ runner.os }}-go-${{ matrix.golang }}-
      - name: Test
        # only test gss for now
        # go test ./... for all
        # after the testdata problems resolved
        # TODO: add makefile for testing
        run: go test ./internal/pkg/gss/

The same workflow, on Latchkey

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

on:
  push:
    branches: [master]
  pull_request:
    # The branches below must be a subset of the branches above
    branches: [master]
 
# for cache
# checkout https://github.com/magnetikonline/action-golang-cache
# https://www.lorenzobettini.it/2020/12/caching-dependencies-in-github-actions/
# https://github.com/mongodb/mongocli/actions/runs/1637632940/workflow
 
name: GO tests
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  tests:
    timeout-minutes: 30
    strategy:
      matrix:
        go-version: [1.17]
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Install Go
        uses: actions/setup-go@v2
        with:
          go-version: ${{ matrix.golang }}
      - name: Cache Dependencies
        uses: actions/cache@v2
        with:
          path: ~/go/pkg/mod # not sure if this part needs editing
          key: ${{ runner.os }}-go-${{ matrix.golang }}-${{ hashFiles('**/go.sum') }}
          restore-keys: |
            ${{ runner.os }}-go-${{ matrix.golang }}-
      - name: Test
        # only test gss for now
        # go test ./... for all
        # after the testdata problems resolved
        # TODO: add makefile for testing
        run: go test ./internal/pkg/gss/
 

What changed

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