Skip to content

Commit

Permalink
Merge branch 'main' into colorblind-scales-to-overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasoppermann authored May 3, 2023
2 parents 559c2bb + f9f5473 commit 57cf952
Show file tree
Hide file tree
Showing 43 changed files with 623 additions and 685 deletions.
5 changes: 5 additions & 0 deletions .changeset/pretty-apes-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/primitives': patch
---

add option to remove descriptions from css output
5 changes: 5 additions & 0 deletions .changeset/tricky-maps-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/primitives": patch
---

Minor docs fixes
27 changes: 4 additions & 23 deletions .github/workflows/a11y-contrast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,12 @@ on:
- main

jobs:
# JOB to run change detection
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
tokens: ${{ steps.filter.outputs.tokens }}
# transformation: ${{ steps.filter.outputs.transformation }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
tokens:
- 'src/tokens/**'
- 'data/**'
- name: No changes to tokens detected
if: ${{ steps.filter.outputs.tokens == 'false' }}
run: echo "No changes to tokens detected, skipping further jobs checking tokens"
uses: ./.github/workflows/hasChanged.yml

build:
needs: changes
if: ${{ needs.changes.outputs.tokens == 'true' }}
if: needs.changes.outputs.oldTokens == 'true'
name: Check design token color contrast
runs-on: ubuntu-latest
steps:
Expand All @@ -42,9 +22,10 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Install dependencies
run: npm ci --no-audit --no-fund
run: npm ci --no-audit --no-fund --ignore-scripts

- name: Build tokens
run: npm run build # building v1 as they are currently used for contrast check
Expand Down
73 changes: 7 additions & 66 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,81 +19,22 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'

- name: Install dependencies
run: npm ci --legacy-peer-deps --no-audit --no-fund && cd docs && npm ci --legacy-peer-deps --no-audit --no-fund
run: npm ci --no-audit --no-fund --ignore-scripts

- name: Build v1 tokens
run: npm run build

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

lint:
if: ${{ github.repository == 'primer/primitives' }}
name: Code linting check
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install dependencies
run: npm ci --legacy-peer-deps --no-audit --no-fund && cd docs && npm ci --legacy-peer-deps --no-audit --no-fund

- name: Build v1 tokens
run: npm run build

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

- name: Lint
- name: Code linting check
run: npm run lint

formatting:
if: ${{ github.repository == 'primer/primitives' }}
name: Code formatting check
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install dependencies
run: npm ci --legacy-peer-deps --no-audit --no-fund && cd docs && npm ci --legacy-peer-deps --no-audit --no-fund

- name: Lint
- name: Code formatting check
run: npm run format:check

test:
if: ${{ github.repository == 'primer/primitives' }}
name: Unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install dependencies
run: npm ci --legacy-peer-deps --no-audit --no-fund && cd docs && npm ci --legacy-peer-deps --no-audit --no-fund

- name: Build v1 tokens
run: npm run build

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

- name: Run unit tests
run: npm test
run: npm test
23 changes: 3 additions & 20 deletions .github/workflows/consumer_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,7 @@ env:

jobs:
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
outputAffected: ${{ steps.filter.outputs.outputAffected }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v2
id: filter
with:
list-files: shell
filters: |
outputAffected:
- '!(*.md|**/**/*.md|**/**/*.test.ts|**/**/*.test.js|docs/**|storybook/**)'
- name: Detecting changes that effect output
run: echo ${{ steps.filter.outputs.outputAffected == 'true' && 'Committed changes may affect output' || 'Committed changes do not affect output' }}
uses: ./.github/workflows/hasChanged.yml

test:
needs: changes
Expand All @@ -48,7 +31,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: 16

- name: Caching dependencies
uses: actions/cache@v3
Expand All @@ -59,7 +42,7 @@ jobs:
${{ runner.os }}-node-
- name: Install local dependencies
run: npm install --legacy-peer-deps
run: npm install --legacy-peer-deps --ignore-scripts

- name: Install consumer dependencies (reference)
run: pushd ${{env.TEST_FOLDER}}; npm install --legacy-peer-deps; popd
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ jobs:
install: npm ci --legacy-peer-deps --no-audit --no-fund && cd docs && npm ci --legacy-peer-deps --no-audit --no-fund && cd ..
build: npm run build:tokens && npm run build && npm run build:next && cd docs && npm run build
output_dir: docs/public

3 changes: 2 additions & 1 deletion .github/workflows/deploy_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ jobs:
uses: primer/.github/.github/workflows/deploy_preview.yml@main
with:
node_version: 18
install: npm ci --no-audit --no-fund
install: npm ci --no-audit --no-fund --ignore-scripts && npm run install:storybook && npm run install:docs
build: npm run build:tokens && npm run build && npm run build:next && cd docs && npm run build:preview
output_dir: docs/public


post_storybook:
needs: deploy
name: Link storybook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ on:
pull_request:

jobs:
changes:
uses: ./.github/workflows/hasChanged.yml

test:
if: ${{ github.repository == 'primer/primitives' }}
if: ${{ github.repository == 'primer/primitives' && needs.changes.outputs.outputAffected == 'true' }}
name: Primitives v2
runs-on: ubuntu-latest
steps:
Expand All @@ -21,7 +24,8 @@ jobs:
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '16'
node-version: 16
cache: 'npm'

- name: Cache dependencies
uses: actions/cache@v3
Expand All @@ -32,10 +36,10 @@ jobs:
${{ runner.os }}-node-
- name: Install dependencies
run: npm install --legacy-peer-deps
run: npm install --legacy-peer-deps --ignore-scripts

- name: Install dependencies (reference)
run: pushd temp-main; npm install --legacy-peer-deps; popd
run: pushd temp-main; npm install --legacy-peer-deps --ignore-scripts; popd

- name: Build
run: npm run build:tokens
Expand Down
128 changes: 128 additions & 0 deletions .github/workflows/diff-v8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Posts a comment listing all the variables that changed in a PR
name: Show diff for v8 design token changes
on:
pull_request:
branches-ignore:
- 'changeset-release/**'
jobs:
changes:
uses: ./.github/workflows/hasChanged.yml

diff:
needs: changes
if: ${{ needs.changes.outputs.tokens == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Checkout base branch
uses: actions/checkout@v3
with:
ref: ${{ github.base_ref }}
path: base

- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'

- name: Install dependencies
run: npm ci --no-audit --no-fund --include=dev --ignore-scripts

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

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

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

- name: Install dependecies for diffing
run: npm install shelljs

- name: Diff v8 tokens
uses: actions/github-script@v6
with:
script: |
const cssFolder = 'tokens-next-private/css'
const shell = require('shelljs')
const globber = await glob.create(cssFolder + '/**/**/*.css')
const files = await globber.glob()
// create diffs
const diffs = files.map(file => {
// run diff
const diff = shell.exec(`diff -u ${file.replace(cssFolder, 'base/' + cssFolder)} ${file}`)
// get filename
const regexRunnerPath = new RegExp('^[a-z\/]+\/tokens-next-private', 'g')
const filename = file.replaceAll(regexRunnerPath,'')
console.log('Checking diff for ' + filename + '...')
if (diff.stderr) {
console.error(diff.stderr)
core.setFailed(diff.stderr)
}
if (diff.stdout === '') {
console.log('No diff for ' + filename + '\n')
} else {
console.log(diff.stdout + '\n')
}
return {
file: filename,
diff: diff.stdout || ''
}
})
// filter files with no diffs
.filter(item => {
return item.diff !== ''
})
// prepare comment body
let body = '## Design Token Diff\n\n'
if (diffs.length === 0) {
body += 'No design tokens changed'
} else {
body += diffs.map(({file, diff}) =>
'<details>' +
`<summary><h3>${file}</h3></summary>\n` +
" \n"+
" ```diff"+
` ${diff}` +
" ```"+
'\n</details>'
).join('\n')
}
// get comments
const {data: comments} = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
});
// get comment if exists
const existingComment = comments.filter(comment => comment.body.includes('## Design Token Diff'));
// if token issue exists, update it
if(existingComment.length > 0) {
await github.rest.issues.updateComment({
comment_id: existingComment[0].id,
owner: context.repo.owner,
repo: context.repo.repo,
body
})
}
// if comment does not exist, create it
else {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body
})
}
Loading

0 comments on commit 57cf952

Please sign in to comment.