Skip to content

Commit

Permalink
rename script (#1047)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann authored Sep 9, 2024
1 parent faead48 commit b173e40
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 33 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/a11y-contrast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
changes:
uses: ./.github/workflows/hasChanged.yml


build:
needs: changes
if: needs.changes.outputs.tokens == 'true' || github.event_name == 'workflow_dispatch'
Expand All @@ -32,8 +31,8 @@ jobs:
- name: Install dependencies
run: npm ci --no-audit --no-fund --ignore-scripts

- name: Build v8 tokens
run: npm run build:v8
- name: Build tokens
run: npm run build:tokens

- name: Run required checks
run: |
Expand All @@ -47,7 +46,7 @@ jobs:
script: |
const results = require('./color-contrast-check.json');
const faildChecks = results.reduce((acc, {failingContrast}) => acc + failingContrast, 0);
// prepare comment body
const resultsMarkdown = '## Design Token Contrast Check\n\n' +
results.map(({theme, failingContrast, markdownTable}) =>
Expand All @@ -71,24 +70,24 @@ jobs:
else {
core.info('\u001b[32;1m✅ All contrast checks passed!')
}
- name: Report check results as comment
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const resultsMarkdown = `${{ steps.check-results.outputs.markdown }}`
// get comments
const {data: comments} = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
});
// get token issue
const tokenCheckComment = comments.filter(comment => comment.body.includes('## Design Token Contrast Check'));
// if token issue exists, update it
if(tokenCheckComment.length > 0) {
await github.rest.issues.updateComment({
Expand Down Expand Up @@ -118,7 +117,7 @@ jobs:
// output results to summary
core.summary.addRaw(resultsMarkdown, true)
core.summary.write({overwrite: true})
Fail_action_on_contrast_failing:
needs: build
name: Fail action on contrast failing
Expand Down Expand Up @@ -146,7 +145,7 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo
});
// get token issue
const tokenCheckComment = comments.filter(comment => comment.body.includes('## Design Token Contrast Check'));
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
- name: Install dependencies
run: npm ci --no-audit --no-fund --ignore-scripts

- name: Build v8 tokens
run: npm run build:v8
- name: Build tokens
run: npm run build:tokens

- name: Build fallbacks
run: npm run build:fallbacks
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/diff-v8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ jobs:
run: npm ci --no-audit --no-fund --include=dev --ignore-scripts

- name: Build tokens (pr)
run: npm run build:v8
run: npm run build:tokens

- name: Install dependencies (base)
run: pushd base; npm i --no-audit --no-fund --ignore-scripts; popd

- name: Build tokens (base)
run: pushd base; npm run build:v8; popd
run: pushd base; npm run build:tokens; popd

- name: Install dependecies for diffing
run: npm install shelljs
Expand All @@ -55,7 +55,7 @@ jobs:
const globber = await glob.create(cssFolder + '/**/**/*.css')
const files = await globber.glob()
const fs = require('fs')
// create file to store diffs
const diffFilePath = 'diff_output.json'
shell.touch(diffFilePath)
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
.filter(item => {
return item.diff !== ''
})
// store diffs in file
fs.writeFileSync(diffFilePath, JSON.stringify(diffs, null, ' '))
Expand All @@ -101,7 +101,7 @@ jobs:
script: |
const fs = require('fs')
const diffFilePath = "${{ steps.diff-files.outputs.diffFilePath }}"
// check if file exists
if(!fs.existsSync(diffFilePath)) {
return
Expand All @@ -110,9 +110,9 @@ jobs:
const diffs = JSON.parse(fs.readFileSync(diffFilePath, 'utf8'))
core.summary.clear()
core.summary.addHeading('V8 Design Token Diff', '1')
if (diffs.length === 0) {
core.summary.addRaw('No design tokens changed', true)
} else {
Expand All @@ -139,7 +139,7 @@ jobs:
script: |
const fs = require('fs')
const diffFilePath = "${{ steps.diff-files.outputs.diffFilePath }}"
// check if file exists
if(!fs.existsSync(diffFilePath)) {
return
Expand Down Expand Up @@ -213,7 +213,7 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo
});
// get comment if exists
const existingComment = comments.filter(comment => comment.body.includes('## Design Token Diff'));
Expand All @@ -228,4 +228,4 @@ jobs:
// remove summary
core.summary.clear()
core.summary.write({overwrite: true})
core.summary.write({overwrite: true})
6 changes: 3 additions & 3 deletions .github/workflows/release_canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
- name: Install dependencies
run: npm ci --no-audit --no-fund --include=dev

- name: Build v8 tokens
run: npm run build:v8
- name: Build tokens
run: npm run build:tokens

- name: Create .npmrc
run: |
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
core.setOutput('packageVersion', package.version);
// Output the package name for next step
core.setOutput('packageName', package.name);
- name: Output canary version to summary
env:
VERSION: ${{ steps.commitStatus.outputs.packageVersion }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release_candidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
- name: Install dependencies
run: npm ci --no-audit --no-fund --include=dev

- name: Build tokens v8
run: npm run build:v8
- name: Build tokens
run: npm run build:tokens

- name: Create .npmrc
run: |
Expand Down Expand Up @@ -71,4 +71,4 @@ jobs:
PACKAGE_NAME: ${{ steps.commitStatus.outputs.packageName }}
run: |
echo "### Latest release candidate" >> $GITHUB_STEP_SUMMARY
echo "[v$VERSION](https://unpkg.com/$PACKAGE_NAME@$VERSION/)" >> $GITHUB_STEP_SUMMARY
echo "[v$VERSION](https://unpkg.com/$PACKAGE_NAME@$VERSION/)" >> $GITHUB_STEP_SUMMARY
4 changes: 2 additions & 2 deletions .github/workflows/update_visual_snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
run: npm ci --no-audit --no-fund --ignore-scripts
- name: Install browsers
run: npx playwright install --with-deps
- name: Build v8 tokens
run: npm run build:v8
- name: Build tokens
run: npm run build:tokens
- name: Build storybook
working-directory: docs/storybook
run: |
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
},
"homepage": "https://github.com/primer/primitives#readme",
"scripts": {
"build": "npm run build:v8 && npm run build:fallbacks && npm run build:figma && npm run build:config",
"build:next": "echo '\\033[31m 🛑 Use npm run build instead of npm run build:next\\033[0m'",
"build:v8": "tsx ./scripts/buildTokens.ts",
"build": "npm run build:tokens && npm run build:fallbacks && npm run build:figma && npm run build:config",
"build:tokens": "tsx ./scripts/buildTokens.ts",
"build:fallbacks": "tsx ./scripts/buildFallbacks.ts",
"build:figma": "tsx scripts/buildFigma.ts",
"build:config": "tsc -p buildConfig.tsconfig.jsonc",
Expand Down

0 comments on commit b173e40

Please sign in to comment.