diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc195a1..847ae1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,14 +43,65 @@ jobs: needs: Lint-and-test steps: - uses: actions/checkout@master + with: + fetch-depth: 0 - uses: actions/setup-node@v4 with: node-version: 20 cache: 'npm' - name: install run: npm ci + + - name: Checkout main branch + run: | + git fetch origin main + git checkout main + + - name: Install and build CSS files from main branch + run: | + npm ci + npm run test:build + mkdir -p /tmp/main-output + cp -r tests/dist/* /tmp/main-output/ || true + + - name: Checkout back to current branch + run: git checkout - + - name: Test build output run: npm run test:build + - name: Upload current branch output + uses: actions/upload-artifact@v4 + with: + name: build-output + path: tests/dist + retention-days: 2 + + - name: Compare build CSS output files + run: | + echo "Comparing CSS files between current build branch and main..." + diff -r /tmp/main-output tests/dist || true + echo "Diff complete. If no output above, files are identical." + - name: Test package output - run: npm run test:package \ No newline at end of file + run: npm run test:package + + - name: Compare package CSS output files + run: | + echo "Comparing CSS files between current package branch and main..." + diff -r /tmp/main-output tests/dist || true + echo "Diff complete. If no output above, files are identical." + + - name: Upload current branch output + uses: actions/upload-artifact@v4 + with: + name: package-output + path: tests/dist + retention-days: 2 + + - name: Upload main branch output + uses: actions/upload-artifact@v4 + with: + name: main-branch-output + path: /tmp/main-output + retention-days: 2 \ No newline at end of file diff --git a/tests/build-from-package.mjs b/tests/build-from-package.mjs index 83a05b6..9c2fe33 100644 --- a/tests/build-from-package.mjs +++ b/tests/build-from-package.mjs @@ -3,11 +3,13 @@ import {getIsType} from 'style-dictionary-utils/filter/getIsType.js'; const StyleDictionary = new SD(); +const outdir = './tests/dist/package/'; + const extendSd = await StyleDictionary.extend({ source: ["./tests/tokens/**/*.json5"], platforms: { css: { - buildPath: "./tests/dist/css/", + buildPath: `${outdir}/css/`, transformGroup: "css", files: [ { @@ -22,7 +24,7 @@ const extendSd = await StyleDictionary.extend({ }, cssPrefixed: { prefix: "PREFIX", - buildPath: "./tests/dist/css/", + buildPath: `${outdir}/css/`, transformGroup: "css", files: [ { @@ -36,8 +38,12 @@ const extendSd = await StyleDictionary.extend({ }, cssAdvanced: { prefix: "PREFIX", - buildPath: "./tests/dist/css/", - transformGroup: "css", + buildPath: `${outdir}/css/`, + transforms: [ + "name/kebab", + "color/rgbAlpha", + "border/css" + ], files: [ { format: "css/advanced", diff --git a/tests/build.mjs b/tests/build.mjs index 9020ca8..22e8a76 100644 --- a/tests/build.mjs +++ b/tests/build.mjs @@ -2,6 +2,8 @@ import { StyleDictionary as SD } from "../dist/index.js"; const StyleDictionary = new SD(); +const outdir = './tests/dist/local/'; + const addPlatforms = (outdir) => { return { css: { @@ -91,12 +93,12 @@ const addPlatforms = (outdir) => { } let extendSd = await StyleDictionary.extend({ - source: ["./tests/tokens/w3c/*.json5"], - platforms: addPlatforms('./tests/dist/w3c'), + source: ["./tests/tokens/css/*.json5"], + platforms: addPlatforms(outdir), }) extendSd = await StyleDictionary.extend({ source: ["./tests/tokens/non-w3c/*.json5"], - platforms: addPlatforms('./tests/dist/non-w3c'), + platforms: addPlatforms(outdir), }) extendSd.cleanAllPlatforms();