Skip to content
Latchkey

Node.js - E2E, Unit Tests, Lint (for PR) workflow (InfuseAI/piperider)

The Node.js - E2E, Unit Tests, Lint (for PR) workflow from InfuseAI/piperider, explained and optimized by Latchkey.

F

CI health: F - at risk

Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, 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: InfuseAI/piperider.github/workflows/ci-statics.yamlLicense Apache-2.0View source

What it does

This is the Node.js - E2E, Unit Tests, Lint (for PR) workflow from the InfuseAI/piperider 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

workflow (.yml)

name: Node.js - E2E, Unit Tests, Lint (for PR)

on:
  pull_request:
    types: [opened, synchronize, reopened]
      # Trigger when PR is created and/or head of branch is updated.
    paths:
      - "static_report/**"
      - "piperider_cli/**"
      # Trigger when diffs detected in statics source code
    branches:
      - main
      # Only PR target is `main`

jobs:
  build:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./static_report

    steps:
    - uses: actions/checkout@v3

    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v3
      with:
        node-version: 16

    - uses: pnpm/action-setup@v2.2.2
      with:
        version: 7

    - name: Install dependencies
      working-directory: ./static_report
      run: pnpm install --frozen-lockfile

    - name: Set up Python 3.8
      uses: actions/setup-python@v2
      with:
        python-version: 3.8

    - name: Prepare Piperider Data & E2E Builds (2+1 runs; 1+1 comparison)
      working-directory: .
      run: |
        pip install -r requirements.txt

        which piperider
        piperider version

        bash static_report/src/sdlc/generate-e2e-data.sh first

        cd static_report
        pnpm run embed:html e2e
        pnpm run bundle:e2e
        cd ..

        bash static_report/src/sdlc/generate-e2e-data.sh second

        cd static_report
        pnpm run embed:html e2e
        pnpm run bundle:e2e:case
        cd ..

        zip -r reports.zip ./static_report/build

    - name: Cypress run (E2E)
    # Parallelization only for cypress dashboard https://www.cypress.io/pricing/
      uses: cypress-io/github-action@v2
      with:
        install: false
        record: false
        working-directory: ./static_report
        config-file: cypress.config.ts
        start: |
          pnpm run serve:e2e:norm:single
          pnpm run serve:e2e:norm:comparison
          pnpm run serve:e2e:case:single-edge
          pnpm run serve:e2e:case:comparison-asymmetric
        wait-on: 'http://localhost:3000, http://localhost:3001, http://localhost:4000, http://localhost:4001'

    - uses: actions/upload-artifact@v3
      with:
        working-directory: ./static_report
        name: report-artifacts
        path: reports.zip

    - name: Build Apps
      run: pnpm run build
    

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: Node.js - E2E, Unit Tests, Lint (for PR)
 
on:
  pull_request:
    types: [opened, synchronize, reopened]
      # Trigger when PR is created and/or head of branch is updated.
    paths:
      - "static_report/**"
      - "piperider_cli/**"
      # Trigger when diffs detected in statics source code
    branches:
      - main
      # Only PR target is `main`
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    timeout-minutes: 30
    runs-on: latchkey-small
    defaults:
      run:
        working-directory: ./static_report
 
    steps:
    - uses: actions/checkout@v3
 
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v3
      with:
        cache: 'npm'
        node-version: 16
 
    - uses: pnpm/action-setup@v2.2.2
      with:
        version: 7
 
    - name: Install dependencies
      working-directory: ./static_report
      run: pnpm install --frozen-lockfile
 
    - name: Set up Python 3.8
      uses: actions/setup-python@v2
      with:
        python-version: 3.8
 
    - name: Prepare Piperider Data & E2E Builds (2+1 runs; 1+1 comparison)
      working-directory: .
      run: |
        pip install -r requirements.txt
 
        which piperider
        piperider version
 
        bash static_report/src/sdlc/generate-e2e-data.sh first
 
        cd static_report
        pnpm run embed:html e2e
        pnpm run bundle:e2e
        cd ..
 
        bash static_report/src/sdlc/generate-e2e-data.sh second
 
        cd static_report
        pnpm run embed:html e2e
        pnpm run bundle:e2e:case
        cd ..
 
        zip -r reports.zip ./static_report/build
 
    - name: Cypress run (E2E)
    # Parallelization only for cypress dashboard https://www.cypress.io/pricing/
      uses: cypress-io/github-action@v2
      with:
        install: false
        record: false
        working-directory: ./static_report
        config-file: cypress.config.ts
        start: |
          pnpm run serve:e2e:norm:single
          pnpm run serve:e2e:norm:comparison
          pnpm run serve:e2e:case:single-edge
          pnpm run serve:e2e:case:comparison-asymmetric
        wait-on: 'http://localhost:3000, http://localhost:3001, http://localhost:4000, http://localhost:4001'
 
    - uses: actions/upload-artifact@v3
      with:
        working-directory: ./static_report
        name: report-artifacts
        path: reports.zip
 
    - name: Build Apps
      run: pnpm run build
    
 

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.

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:

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