lint workflow (microsoft/maro)
The lint workflow from microsoft/maro, explained and optimized by Latchkey.
C
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 workflow from the microsoft/maro 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)
---
###########################
###########################
## Linter GitHub Actions ##
###########################
###########################
name: lint
#
# Documentation:
# https://help.github.com/en/articles/workflow-syntax-for-github-actions
#
#############################
# Start the job on all push #
#############################
on: [ push, pull_request, workflow_dispatch ]
###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Lint Code Base
# Set the agent to run on
runs-on: ubuntu-latest
##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 0
################################
# Run Linter against code base #
################################
- name: Lint Code Base
uses: github/super-linter@latest
env:
VALIDATE_ALL_CODEBASE: false
VALIDATE_PYTHON_PYLINT: false # disable pylint, as we have not configured it
VALIDATE_PYTHON_MYPY: false # same as above
VALIDATE_JSCPD: false # Can not exclude specific file: https://github.com/kucherenko/jscpd/issues/215
PYTHON_FLAKE8_CONFIG_FILE: tox.ini
PYTHON_BLACK_CONFIG_FILE: pyproject.toml
PYTHON_ISORT_CONFIG_FILE: pyproject.toml
EDITORCONFIG_FILE_NAME: ../../.editorconfig
FILTER_REGEX_INCLUDE: maro/.*
FILTER_REGEX_EXCLUDE: tests/.*
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.LINT_TOKEN }}
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
--- ########################### ########################### ## Linter GitHub Actions ## ########################### ########################### name: lint # # Documentation: # https://help.github.com/en/articles/workflow-syntax-for-github-actions # ############################# # Start the job on all push # ############################# on: [ push, pull_request, workflow_dispatch ] ############### # Set the Job # ############### concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: timeout-minutes: 30 # Name the Job name: Lint Code Base # Set the agent to run on runs-on: latchkey-small ################## # Load all steps # ################## steps: ########################## # Checkout the code base # ########################## - name: Checkout Code uses: actions/checkout@v2 with: fetch-depth: 0 ################################ # Run Linter against code base # ################################ - name: Lint Code Base uses: github/super-linter@latest env: VALIDATE_ALL_CODEBASE: false VALIDATE_PYTHON_PYLINT: false # disable pylint, as we have not configured it VALIDATE_PYTHON_MYPY: false # same as above VALIDATE_JSCPD: false # Can not exclude specific file: https://github.com/kucherenko/jscpd/issues/215 PYTHON_FLAKE8_CONFIG_FILE: tox.ini PYTHON_BLACK_CONFIG_FILE: pyproject.toml PYTHON_ISORT_CONFIG_FILE: pyproject.toml EDITORCONFIG_FILE_NAME: ../../.editorconfig FILTER_REGEX_INCLUDE: maro/.* FILTER_REGEX_EXCLUDE: tests/.* DEFAULT_BRANCH: master GITHUB_TOKEN: ${{ secrets.LINT_TOKEN }}
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.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.