CI workflow (couler-proj/couler)
The CI workflow from couler-proj/couler, explained and optimized by Latchkey.
CI health: F - at risk
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the CI workflow from the couler-proj/couler 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
name: CI
on:
push:
branches: [ master, dev-* ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-18.04
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
strategy:
matrix:
python-version: [3.6.7]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.15.0' # The Go version to download (if necessary) and use.
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt -r requirements-dev.txt
go get github.com/golang/protobuf/protoc-gen-go@v1.3.2
go get golang.org/x/lint/golint
go get github.com/argoproj/argo@v0.0.0-20210125193418-4cb5b7eb8075
- name: Install protoc
uses: arduino/setup-protoc@v1
with:
version: '3.14.0'
## TODO: This is temporarily commented out to unblock PRs.
# - name: Sanity checks
# run: |
# pre-commit run -a --show-diff-on-failure
- name: Python Unit tests
run: |
set -e
bash ./scripts/test_python.sh
- name: Build docs
run: |
mkdocs build
- name: Go Unit tests
run: |
set -e
bash ./scripts/test_go.sh
- uses: opsgang/ga-setup-minikube@v0.1.1
with:
minikube-version: 1.22.0
k8s-version: 1.18.3
- name: Integration tests
run: |
minikube config set vm-driver docker
minikube config set kubernetes-version 1.18.3
minikube start
kubectl create ns argo
kubectl create sa default -n argo
kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo-workflows/v2.12.6/manifests/quick-start-minimal.yaml
kubectl wait -n argo --for=condition=Ready pods --all --timeout=300s
kubectl apply -n argo -f manifests/mpi-operator.yaml
go build -buildmode=c-shared -o submit.so go/couler/commands/submit.go
scripts/integration_tests.sh
export E2E_TEST=true
go test -timeout 3m ./go/couler/submitter/... -v
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: CI on: push: branches: [ master, dev-* ] pull_request: branches: [ master ] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: timeout-minutes: 30 runs-on: ubuntu-18.04 env: ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' strategy: matrix: python-version: [3.6.7] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: cache: 'pip' python-version: ${{ matrix.python-version }} - name: Setup Go uses: actions/setup-go@v2 with: go-version: '1.15.0' # The Go version to download (if necessary) and use. - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install -r requirements.txt -r requirements-dev.txt go get github.com/golang/protobuf/protoc-gen-go@v1.3.2 go get golang.org/x/lint/golint go get github.com/argoproj/argo@v0.0.0-20210125193418-4cb5b7eb8075 - name: Install protoc uses: arduino/setup-protoc@v1 with: version: '3.14.0' ## TODO: This is temporarily commented out to unblock PRs. # - name: Sanity checks # run: | # pre-commit run -a --show-diff-on-failure - name: Python Unit tests run: | set -e bash ./scripts/test_python.sh - name: Build docs run: | mkdocs build - name: Go Unit tests run: | set -e bash ./scripts/test_go.sh - uses: opsgang/ga-setup-minikube@v0.1.1 with: minikube-version: 1.22.0 k8s-version: 1.18.3 - name: Integration tests run: | minikube config set vm-driver docker minikube config set kubernetes-version 1.18.3 minikube start kubectl create ns argo kubectl create sa default -n argo kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo-workflows/v2.12.6/manifests/quick-start-minimal.yaml kubectl wait -n argo --for=condition=Ready pods --all --timeout=300s kubectl apply -n argo -f manifests/mpi-operator.yaml go build -buildmode=c-shared -o submit.so go/couler/commands/submit.go scripts/integration_tests.sh export E2E_TEST=true go test -timeout 3m ./go/couler/submitter/... -v
What changed
- Cancel superseded runs when a branch or PR gets a newer push.
- Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
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:
- Dependency installs
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.