Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test design tokens build #454

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/test_design_tokens_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Test design tokens build script

on:
pull_request:
paths:
- packages/design-tokens/**
workflow_dispatch:

# Cancel any currently running builds to save GitHub Actions hours.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
run-tests:
name: Run tests
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Read .nvmrc
run: echo "GITHUB_NVMRC_VERSION=$(cat .nvmrc)" >> $GITHUB_ENV
working-directory: ./packages/design-tokens

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.GITHUB_NVMRC_VERSION }}

- name: Install dependencies
run: npm install
working-directory: ./packages/design-tokens

- name: Run test suite with npm script
run: npm run test
working-directory: ./packages/design-tokens
23 changes: 23 additions & 0 deletions packages/design-tokens/build-output.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { exec } from "child_process";
import { test } from "node:test";
import assert from "node:assert";

test("build-output.js should complete without errors", async () => {
try {
await new Promise((resolve, reject) => {
// Execute the build script using Node.js
exec("node build-output.js", (error, stdout, stderr) => {
// If there was an error, the test should fail
if (error) {
console.error("Error executing build-output.js:", stderr);
return reject(new Error("build-output.js threw an error"));
}
console.log("build-output.js executed successfully:", stdout);
resolve();
});
});
assert.ok(true);
} catch (error) {
assert.fail(error.message);
}
});
Loading