Skip to content
Latchkey

Test Chrome workflow (sweetalert2/sweetalert2)

The Test Chrome workflow from sweetalert2/sweetalert2, explained and optimized by Latchkey.

D

CI health: D - needs work

Point runs-on at Latchkey and get caching, run de-duplication, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: sweetalert2/sweetalert2.github/workflows/chrome.ymlLicense MITView source

What it does

This is the Test Chrome workflow from the sweetalert2/sweetalert2 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)
name: Test Chrome

on:
  push:

jobs:
  Chrome:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    permissions:
      contents: write # to be able to publish a GitHub release
      issues: write # to be able to comment on released issues
      pull-requests: write # to be able to comment on released pull requests
      id-token: write # to enable use of OIDC for trusted publishing and npm provenance

    steps:
      - uses: actions/checkout@v5
      - uses: oven-sh/setup-bun@v2

      # because npm 10.8.2 (default) doesn't work with trusted publishing, 11.6.2 works
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 'lts/*'

      - run: bun install

      - run: bun run build

      - run: bun lint

      - run: bun check-types

      - name: Run tests in Chrome
        run: bun run test --browser chrome

      - name: Test in CommonJS
        if: github.ref_name == 'main'
        run: node test/require-in-commonjs.cjs

      - name: Test with Webpack
        if: github.ref_name == 'main'
        run: |
          bun add --dev webpack@^5.0.0 webpack-cli@^5.0.0
          bun webpack-build
          bun add --dev webpack@^4.0.0 webpack-cli@^4.0.0
          export NODE_OPTIONS=--openssl-legacy-provider
          bun webpack-build

      - name: Check TypeScript
        if: github.ref_name == 'main'
        run: |
          ln -s ../../ test/ts/node_modules
          tsc --lib dom,es6 --skipLibCheck --noEmit --strict test/ts/simple-usage.ts
          tsc --lib dom,es6 --skipLibCheck --noEmit --strict test/ts/inputValidator.ts
          tsc --lib dom,es6 --skipLibCheck --noEmit --strict test/ts/dist-sweetalert2.ts sweetalert2.d.ts
          tsc --lib dom,es6 --skipLibCheck --noEmit --strict test/ts/src-sweetalert2.ts sweetalert2.d.ts

      - name: Run automated release process with semantic-release
        if: github.ref_name == 'main'
        uses: cycjimmy/semantic-release-action@v6
        with:
          extra_plugins: |
            @semantic-release/changelog
            @semantic-release/git
            @semantic-release/exec
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

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: Test Chrome
 
on:
  push:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  Chrome:
    runs-on: latchkey-small
    timeout-minutes: 10
    permissions:
      contents: write # to be able to publish a GitHub release
      issues: write # to be able to comment on released issues
      pull-requests: write # to be able to comment on released pull requests
      id-token: write # to enable use of OIDC for trusted publishing and npm provenance
 
    steps:
      - uses: actions/checkout@v5
      - uses: oven-sh/setup-bun@v2
 
      # because npm 10.8.2 (default) doesn't work with trusted publishing, 11.6.2 works
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          cache: 'npm'
          node-version: 'lts/*'
 
      - run: bun install
 
      - run: bun run build
 
      - run: bun lint
 
      - run: bun check-types
 
      - name: Run tests in Chrome
        run: bun run test --browser chrome
 
      - name: Test in CommonJS
        if: github.ref_name == 'main'
        run: node test/require-in-commonjs.cjs
 
      - name: Test with Webpack
        if: github.ref_name == 'main'
        run: |
          bun add --dev webpack@^5.0.0 webpack-cli@^5.0.0
          bun webpack-build
          bun add --dev webpack@^4.0.0 webpack-cli@^4.0.0
          export NODE_OPTIONS=--openssl-legacy-provider
          bun webpack-build
 
      - name: Check TypeScript
        if: github.ref_name == 'main'
        run: |
          ln -s ../../ test/ts/node_modules
          tsc --lib dom,es6 --skipLibCheck --noEmit --strict test/ts/simple-usage.ts
          tsc --lib dom,es6 --skipLibCheck --noEmit --strict test/ts/inputValidator.ts
          tsc --lib dom,es6 --skipLibCheck --noEmit --strict test/ts/dist-sweetalert2.ts sweetalert2.d.ts
          tsc --lib dom,es6 --skipLibCheck --noEmit --strict test/ts/src-sweetalert2.ts sweetalert2.d.ts
 
      - name: Run automated release process with semantic-release
        if: github.ref_name == 'main'
        uses: cycjimmy/semantic-release-action@v6
        with:
          extra_plugins: |
            @semantic-release/changelog
            @semantic-release/git
            @semantic-release/exec
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 

What changed

2 third-party actions are referenced by a movable tag. Pin them 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.

Actions used in this workflow