detect runtime error workflow (nhn/tui.image-editor)
The detect runtime error workflow from nhn/tui.image-editor, explained and optimized by Latchkey.
CI health: B - good
Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the detect runtime error workflow from the nhn/tui.image-editor 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
name: detect runtime error
on:
schedule:
- cron: '0 22 * * *'
jobs:
detectError:
runs-on: ubuntu-latest
env:
WORKING_DIRECTORY: ./apps/image-editor
steps:
- name: checkout repository
uses: actions/checkout@v2
- name: create config variable
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
node createConfigVariable.js
- name: set global error variable
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
errorVariable=`cat ./errorVariable.txt`
echo "ERROR_VARIABLE=$errorVariable" >> $GITHUB_ENV
- name: set url
working-directory: ${{ env.WORKING_DIRECTORY }}
shell: bash
run: |
url=`cat ./url.txt`
echo "URLS=$url" >> $GITHUB_ENV
- name: detect runtime error
uses: nhn/toast-ui.detect-runtime-error-actions@v1.0.1
with:
global-error-log-variable: ${{ env.ERROR_VARIABLE }}
urls: ${{ env.URLS }}
env:
BROWSERSTACK_USERNAME: ${{secrets.BROWSERSTACK_USERNAME}}
BROWSERSTACK_ACCESS_KEY: ${{secrets.BROWSERSTACK_ACCESS_KEY}}
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: detect runtime error on: schedule: - cron: '0 22 * * *' jobs: detectError: timeout-minutes: 30 runs-on: latchkey-small env: WORKING_DIRECTORY: ./apps/image-editor steps: - name: checkout repository uses: actions/checkout@v2 - name: create config variable working-directory: ${{ env.WORKING_DIRECTORY }} run: | node createConfigVariable.js - name: set global error variable working-directory: ${{ env.WORKING_DIRECTORY }} run: | errorVariable=`cat ./errorVariable.txt` echo "ERROR_VARIABLE=$errorVariable" >> $GITHUB_ENV - name: set url working-directory: ${{ env.WORKING_DIRECTORY }} shell: bash run: | url=`cat ./url.txt` echo "URLS=$url" >> $GITHUB_ENV - name: detect runtime error uses: nhn/toast-ui.detect-runtime-error-actions@v1.0.1 with: global-error-log-variable: ${{ env.ERROR_VARIABLE }} urls: ${{ env.URLS }} env: BROWSERSTACK_USERNAME: ${{secrets.BROWSERSTACK_USERNAME}} BROWSERSTACK_ACCESS_KEY: ${{secrets.BROWSERSTACK_ACCESS_KEY}}
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.
1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.