check_contributing_guidelines_acceptance workflow (stdlib-js/stdlib)
The check_contributing_guidelines_acceptance workflow from stdlib-js/stdlib, explained and optimized by Latchkey.
CI health: A - excellent
Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the check_contributing_guidelines_acceptance workflow from the stdlib-js/stdlib 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
#/
# @license Apache-2.0
#
# Copyright (c) 2024 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#/
# Workflow name:
name: check_contributing_guidelines_acceptance
# Workflow triggers:
on:
# Allow the workflow to be triggered by other workflows
workflow_call:
# Define the input parameters for the workflow:
inputs:
pull_request_number:
description: 'Pull request number'
required: true
type: number
user:
required: true
type: string
# Define the secrets accessible by the workflow:
secrets:
STDLIB_BOT_GITHUB_TOKEN:
description: 'stdlib-bot GitHub token to create pull request comments'
required: true
# Trigger on pull request events:
pull_request_target:
types:
- opened
- reopened
- edited
# Global permissions:
permissions:
# Allow read-only access to the repository contents:
contents: read
# Workflow jobs:
jobs:
# Define a job for checking the contributing guidelines acceptance...
check_acknowledgment:
# Define a display name:
name: 'Check Contributing Guidelines Acceptance'
# Define the type of virtual host machine:
runs-on: ubuntu-latest
# Skip this job for PRs opened by automated bot accounts:
if: github.event.pull_request.user.login != 'stdlib-bot' && github.event.pull_request.user.login != 'dependabot[bot]'
# Define the sequence of job steps...
steps:
# Checkout the repository:
- name: 'Checkout repository'
# Pin action to full length commit SHA
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
# Ensure we have access to the scripts directory:
sparse-checkout: |
.github/workflows/scripts
sparse-checkout-cone-mode: false
timeout-minutes: 10
# Check contributing guidelines acceptance:
- name: 'Check contributing guidelines acceptance'
env:
GITHUB_TOKEN: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }}
PR_NUMBER: ${{ github.event.pull_request.number || inputs.pull_request_number }}
run: |
. "$GITHUB_WORKSPACE/.github/workflows/scripts/check_contributing_guidelines_acceptance/run" $PR_NUMBER
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
#/ # @license Apache-2.0 # # Copyright (c) 2024 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #/ # Workflow name: name: check_contributing_guidelines_acceptance # Workflow triggers: on: # Allow the workflow to be triggered by other workflows workflow_call: # Define the input parameters for the workflow: inputs: pull_request_number: description: 'Pull request number' required: true type: number user: required: true type: string # Define the secrets accessible by the workflow: secrets: STDLIB_BOT_GITHUB_TOKEN: description: 'stdlib-bot GitHub token to create pull request comments' required: true # Trigger on pull request events: pull_request_target: types: - opened - reopened - edited # Global permissions: permissions: # Allow read-only access to the repository contents: contents: read # Workflow jobs: jobs: # Define a job for checking the contributing guidelines acceptance... check_acknowledgment: timeout-minutes: 30 # Define a display name: name: 'Check Contributing Guidelines Acceptance' # Define the type of virtual host machine: runs-on: latchkey-small # Skip this job for PRs opened by automated bot accounts: if: github.event.pull_request.user.login != 'stdlib-bot' && github.event.pull_request.user.login != 'dependabot[bot]' # Define the sequence of job steps... steps: # Checkout the repository: - name: 'Checkout repository' # Pin action to full length commit SHA uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: # Ensure we have access to the scripts directory: sparse-checkout: | .github/workflows/scripts sparse-checkout-cone-mode: false timeout-minutes: 10 # Check contributing guidelines acceptance: - name: 'Check contributing guidelines acceptance' env: GITHUB_TOKEN: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }} PR_NUMBER: ${{ github.event.pull_request.number || inputs.pull_request_number }} run: | . "$GITHUB_WORKSPACE/.github/workflows/scripts/check_contributing_guidelines_acceptance/run" $PR_NUMBER
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. - 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.