Build workflow (svaarala/duktape)
The Build workflow from svaarala/duktape, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get caching, run de-duplication, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Build workflow from the svaarala/duktape 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: Build
on: [push, pull_request]
jobs:
build_duk_ubuntu:
name: Duk Ubuntu 22.04
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install packages
run: |
sudo apt -qqy update
sudo apt -qqy install build-essential make python3 python3-yaml bc git
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Build
run: |
make build/duk build/dukd build/duk-g++ build/duk-clang build/duk-fuzzilli
- name: Test
run: |
build/duk -e "print(Duktape.env); print('Hello world!');"
build/duk dist-files/mandel.js
build/duk-g++ dist-files/mandel.js
build_duk_macos:
name: Duk macOS 12
runs-on: macos-12
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install packages
run: |
python -m pip install PyYAML
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Build
run: |
make build/duk
- name: Test
run: |
build/duk -e "print(Duktape.env); print('Hello world!');"
build/duk dist-files/mandel.js
# build_duk_macos_arm64:
# name: Duk macOS 13 ARM64
# runs-on: macos-13-arm64
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Install packages
# run: |
# python -m pip install PyYAML
# - name: Install Node.js
# uses: actions/setup-node@v3
# with:
# node-version: 16
# - name: Build
# run: |
# make build/duk
# - name: Test
# run: |
# build/duk -e "print(Duktape.env); print('Hello world!');"
# build/duk dist-files/mandel.js
build_duk_windows:
name: Duk VS2022
runs-on: windows-2022
strategy:
matrix:
architecture: [ 'x86', 'amd64' ]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build
shell: cmd
run: |
REM call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{matrix.architecture}}
REM cl /?
REM python2 -m pip install PyYAML
REM python2 tools\configure.py --line-directives --output-directory prep-nondll --source-directory src-input --config-metadata config
cd src-tools && make && cd ..
node.exe src-tools\index.js configure --output-directory prep-nondll --source-directory src-input
cl /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-nondll /Iexamples\cmdline /Iextras\print-alert prep-nondll\duktape.c examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk.exe
dir duk.exe
- name: Test
shell: cmd
run: |
duk.exe -e "print(Duktape.env); print('Hello world!');"
duk.exe dist-files\mandel.js
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: Build on: [push, pull_request] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build_duk_ubuntu: name: Duk Ubuntu 22.04 runs-on: latchkey-small steps: - name: Checkout code uses: actions/checkout@v2 - name: Install packages run: | sudo apt -qqy update sudo apt -qqy install build-essential make python3 python3-yaml bc git - name: Install Node.js uses: actions/setup-node@v3 with: cache: 'npm' node-version: 16 - name: Build run: | make build/duk build/dukd build/duk-g++ build/duk-clang build/duk-fuzzilli - name: Test run: | build/duk -e "print(Duktape.env); print('Hello world!');" build/duk dist-files/mandel.js build/duk-g++ dist-files/mandel.js build_duk_macos: name: Duk macOS 12 runs-on: macos-12 steps: - name: Checkout code uses: actions/checkout@v2 - name: Install packages run: | python -m pip install PyYAML - name: Install Node.js uses: actions/setup-node@v3 with: cache: 'npm' node-version: 16 - name: Build run: | make build/duk - name: Test run: | build/duk -e "print(Duktape.env); print('Hello world!');" build/duk dist-files/mandel.js # build_duk_macos_arm64: # name: Duk macOS 13 ARM64 # runs-on: macos-13-arm64 # steps: # - name: Checkout code # uses: actions/checkout@v2 # - name: Install packages # run: | # python -m pip install PyYAML # - name: Install Node.js # uses: actions/setup-node@v3 with: cache: 'npm' # with: # node-version: 16 # - name: Build # run: | # make build/duk # - name: Test # run: | # build/duk -e "print(Duktape.env); print('Hello world!');" # build/duk dist-files/mandel.js build_duk_windows: name: Duk VS2022 runs-on: windows-2022 strategy: matrix: architecture: [ 'x86', 'amd64' ] steps: - name: Checkout code uses: actions/checkout@v2 - name: Build shell: cmd run: | REM call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{matrix.architecture}} REM cl /? REM python2 -m pip install PyYAML REM python2 tools\configure.py --line-directives --output-directory prep-nondll --source-directory src-input --config-metadata config cd src-tools && make && cd .. node.exe src-tools\index.js configure --output-directory prep-nondll --source-directory src-input cl /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-nondll /Iexamples\cmdline /Iextras\print-alert prep-nondll\duktape.c examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk.exe dir duk.exe - name: Test shell: cmd run: | duk.exe -e "print(Duktape.env); print('Hello world!');" duk.exe dist-files\mandel.js
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.
- Cache dependency installs on the setup step so they are served from cache.
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 3 jobs (4 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.