Skip to content

#4767

#4767 #52

Workflow file for this run

# This workflow will do the following when a pull request is made against the main branch:
# 1. Clone base repository (apexcharts/apexcharts.js), install npm packages, build samples, and then generate e2e snapshots
# 2. Clone head repository (the repository with the code in the pull request), install npm packages, build samples, get snapshots generated from the base repository, run tests, and then generate an apexcharts build
# Test coverage results, base repository snapshots, head repository snapshots and diffs, sample HTML, and the apexcharts build are all uploaded to the workflow artifacts
# The diffs, build, and coverage results get uploaded even if the test fails for manual inspection and to make debugging easier
name: Node.js CI
on:
pull_request:
branches: [ main ]
jobs:
build:
name: Test & Build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- name: Create base repository artifacts folder
run: mkdir -p ${{ runner.temp }}/artifacts/base-repository
- name: Create head repository artifacts folder
run: mkdir -p ${{ runner.temp }}/artifacts/head-repository
- name: Checkout base repository
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.base.repo.full_name }}
ref: ${{ github.event.pull_request.base.ref }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install base repository's packages
run: npm ci
- name: Generate base repository's samples
run: npm run build:samples
- name: Copy Base Repository Samples To Artifacts Folder
run: cp -r samples/vanilla-js ${{ runner.temp }}/artifacts/base-repository/samples
- name: Generate base repository's e2e snapshots
run: npm run e2e:update
- name: Copy Base Repository e2e Snapshots To Artifacts Folder
run: cp -r tests/e2e/snapshots ${{ runner.temp }}/artifacts/base-repository/snapshots
- name: Checkout head repository
uses: actions/checkout@v4
- name: Install head repository's packages
run: npm ci
- name: Generate head repository's samples
run: npm run build:samples
- name: Copy Head Repository Samples To Artifacts Folder
run: cp -r samples/vanilla-js ${{ runner.temp }}/artifacts/head-repository/samples
- name: Delete snapshots folder
run: rm -r tests/e2e/snapshots
- name: Copy snapshots from base repository
run: cp -r ${{ runner.temp }}/artifacts/base-repository/snapshots tests/e2e
- name: Run tests
run: npm run test:ci
- name: Copy Head Repository Diffs To Artifacts Folder
if: '!cancelled()'
run: cp -r tests/e2e/diffs ${{ runner.temp }}/artifacts/head-repository/diffs
- name: Build apexcharts
if: '!cancelled()'
run: npm run build --if-present
- name: Copy Head Repository Build To Artifacts Folder
if: '!cancelled()'
run: cp -r dist ${{ runner.temp }}/artifacts/head-repository/build
- name: Copy Head Repository Test Coverage To Artifacts Folder
if: '!cancelled()'
run: cp -r coverage ${{ runner.temp }}/artifacts/head-repository/coverage
- name: Upload Artifacts
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: node${{ matrix.node-version }}${{ runner.os }}results
path: ${{ runner.temp }}/artifacts
test-reproducibility:
name: Test Reproducibility
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install packages
run: npm ci
- name: Build samples
run: npm run build:samples
- name: Generate snapshots
run: npm run e2e:update
- name: Run tests
run: npm run test:ci