lint_terraform workflow (open-duelyst/duelyst)
The lint_terraform workflow from open-duelyst/duelyst, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the lint_terraform workflow from the open-duelyst/duelyst repository, a real project running GitHub Actions. It is shown here with attribution under its CC0-1.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: lint_terraform
on:
push:
branches:
- main
pull_request:
paths:
- terraform/**.tf
jobs:
linting:
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v3
- name: install terraform
run: |
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform=1.3.0
- name: install tflint
run: curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
- name: lint terraform code
run: scripts/tflint.sh
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: lint_terraform on: push: branches: - main pull_request: paths: - terraform/**.tf concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: linting: timeout-minutes: 30 runs-on: latchkey-small steps: - name: check out code uses: actions/checkout@v3 - name: install terraform run: | wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list sudo apt update && sudo apt install terraform=1.3.0 - name: install tflint run: curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash - name: lint terraform code run: scripts/tflint.sh
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
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
- Network fetches
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.