Skip to content

Commit

Permalink
chore: add calcite-ui-icons to monorepo (#9835)
Browse files Browse the repository at this point in the history
**Related Issue:** #9255

## Summary

Good news, everyone! `@esri/calcite-ui-icons` is joining the Calcite
Design System monorepo. This change will ensure Calcite components
always uses the latest and greatest version of the icons. Additionally,
the icons will benefit from the monorepo's continuous integration,
including automatic changelog generation and deployment. This will give
the designers more time to do what they do best!

Some much needed cleanup was accomplished during this transition. The
following items will no longer be [published to
npm](https://unpkg.com/browse/@esri/calcite-ui-icons@3.29.0/):

```
.github/*
CONTRIBUTE.md
bin/build.js
bin/cli.js
bin/convert-mobile.js
bin/optimize.js
bin/path-data.js
bin/server.js
bin/templates/*
bower.json
docs/app.js
docs/index.html
docs/resources/*
launch-calcite.command
launch-meridian.command
```

Additionally, the autogenerated, build files will not longer be
committed into version control. This includes:

```
docs/icons.json
index.d.ts
index.js
js/*
sprite-16.svg
sprite-24.svg
sprite-32.svg
```

These files can be generated via `npm run build`. The build files will
be attached to GitHub releases for users who do not consume the icons
via NPM.

Note that I removed `bower.json` since [they
recommended](https://bower.io/blog/2017/how-to-migrate-away-from-bower/)
using other software back in 2017, and there hasn't been any activity in
the [repo](https://github.com/bower/bower) for a few years now. However,
I'm open to deprecating bower support and removing it in the next major
release if people prefer that route.

Release-As: 3.30.0
  • Loading branch information
benelan authored and github-actions[bot] committed Jul 30, 2024
1 parent cc81399 commit 05264ea
Show file tree
Hide file tree
Showing 3,512 changed files with 19,670 additions and 559 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 3 additions & 1 deletion .github/scripts/assignForVerification.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @ts-check
const { handoff, issueWorkflow } = require("./support/resources");
const {
labels: { handoff, issueWorkflow },
} = require("./support/resources");
const { removeLabel } = require("./support/utils");

/** @param {import('github-script').AsyncFunctionArguments} AsyncFunctionArguments */
Expand Down
89 changes: 89 additions & 0 deletions .github/scripts/iconTeamDiffCheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
const {
teams: { admins, iconDesigners },
labels: { snapshots },
} = require("./support/resources");

/** @param {import('github-script').AsyncFunctionArguments} AsyncFunctionArguments */
module.exports = async ({ github, context, core }) => {
const { repo, owner } = context.repo;

const payload = /** @type {import('@octokit/webhooks-types').PullRequestEvent} */ (context.payload);
const {
pull_request: {
number: pull_number,
user: { login: author },
},
} = payload;

core.debug("Checking author/reviewers because there are diffs outside of package/calcite-ui-icons");
core.debug(`Author: ${author}`);

const iconTeamMembers = (
await github.rest.teams.listMembersInOrg({
org: owner,
team_slug: iconDesigners,
})
).data.map((member) => member.login);

core.debug(`Members of "${iconDesigners}" GitHub Team: ${JSON.stringify(iconTeamMembers)}`);

const adminTeamMembers = (
await github.rest.teams.listMembersInOrg({
org: owner,
team_slug: admins,
})
).data.map((member) => member.login);

core.debug(`Members of "${admins}" GitHub Team: ${JSON.stringify(adminTeamMembers)}`);

// passes when an admin approves the PR
if (github.event?.review?.state == "APPROVED" && adminTeamMembers.includes(github.event?.review?.user?.login)) {
core.debug(`Approved by admin: ${github.event?.review?.user?.login}`);
core.debug("Passing because an admin has approved this pull request");
process.exit(0);
}

// passes if the author isn't on the icon designers team or if the author is on the admin team
// admin(s) may be on the icon designers team for maintenance purposes
if (adminTeamMembers.includes(author) || !iconTeamMembers.includes(author)) {
core.debug("Passing because the author is an admin and/or isn't an icon designer");
process.exit(0);
}

const { data: reviews } = await github.rest.pulls.listReviews({ owner, repo, pull_number });

// passes if there was a previous approval from an admin
reviews.forEach((review) => {
if (review.state == "APPROVED" && adminTeamMembers.includes(review.user.login)) {
core.debug(`Approved by admin: ${review.user.login}`);
core.debug("Passing because an admin has approved this pull request");
process.exit(0);
}
});

const { data: requestedReviewers } = await github.rest.pulls.listRequestedReviewers({
owner,
repo,
pull_number,
});

if (!requestedReviewers.teams.map((reviewer) => reviewer.slug).includes(admins)) {
core.debug(`Requesting review from the "${admins}" GitHub team`);
await github.rest.pulls.requestReviewers({
owner,
repo,
pull_number,
team_reviewers: [admins],
});
}

await github.rest.issues.addLabels({
owner,
repo,
issue_number: pull_number,
labels: [snapshots.skip],
});
core.setFailed(
`An admin needs to review these changes because a file outside of package/calcite-ui-icons was changed.`,
);
};
4 changes: 3 additions & 1 deletion .github/scripts/labelPullRequestWithCommitType.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @ts-check
const { issueType } = require("./support/resources");
const {
labels: { issueType },
} = require("./support/resources");

/** @param {import('github-script').AsyncFunctionArguments} AsyncFunctionArguments */
module.exports = async ({ github, context }) => {
Expand Down
4 changes: 3 additions & 1 deletion .github/scripts/notifyWhenReadyForDev.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
// The secret is formatted like so: person1, person2, person3
//
// Note the script automatically adds the "@" character in to notify the project manager(s)
const { issueWorkflow, planning } = require("./support/resources");
const {
labels: { issueWorkflow, planning },
} = require("./support/resources");
const { removeLabel } = require("./support/utils");

/** @param {import('github-script').AsyncFunctionArguments} AsyncFunctionArguments */
Expand Down
4 changes: 3 additions & 1 deletion .github/scripts/notifyWhenSpikeComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
// The secret is formatted like so: person1, person2, person3
//
// Note the script automatically adds the "@" character in to notify the project manager(s)
const { issueWorkflow, planning } = require("./support/resources");
const {
labels: { issueWorkflow, planning },
} = require("./support/resources");
const { removeLabel } = require("./support/utils");

/** @param {import('github-script').AsyncFunctionArguments} AsyncFunctionArguments */
Expand Down
80 changes: 45 additions & 35 deletions .github/scripts/support/resources.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,50 @@
const resources = {
bug: {
regression: "regression",
labels: {
bug: {
regression: "regression",
},
handoff: {
readyForDev: "ready for dev",
figmaChanges: "figma changes",
},
issueType: {
bug: "bug",
chore: "chore",
docs: "docs",
enhancement: "enhancement",
perf: "perf",
refactor: "refactor",
test: "testing",
tooling: "tooling",
},
issueWorkflow: {
new: "0 - new",
assigned: "1 - assigned",
inDevelopment: "2 - in development",
installed: "3 - installed",
verified: "4 - verified",
},
planning: {
needsMilestone: "needs milestone",
spike: "spike",
spikeComplete: "spike complete",
},
priority: {
low: "p - low",
high: "p - high",
critical: "p - critical",
},
risk: {
low: "low risk",
},
snapshots: {
skip: "skip visual snapshots",
run: "pr ready for visual snapshots",
},
},
handoff: {
readyForDev: "ready for dev",
figmaChanges: "figma changes",
},
issueType: {
bug: "bug",
chore: "chore",
docs: "docs",
enhancement: "enhancement",
perf: "perf",
refactor: "refactor",
test: "testing",
tooling: "tooling",
},
issueWorkflow: {
new: "0 - new",
assigned: "1 - assigned",
inDevelopment: "2 - in development",
installed: "3 - installed",
verified: "4 - verified",
},
planning: {
needsMilestone: "needs milestone",
spike: "spike",
spikeComplete: "spike complete",
},
priority: {
low: "p - low",
high: "p - high",
critical: "p - critical",
},
risk: {
low: "low risk",
teams: {
admins: "calcite-design-system-admins",
iconDesigners: "calcite-icon-designers",
},
};

Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/icons-diff-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Icon Team Diff Check
on:
pull_request:
branches: [main, rc, dev]
pull_request_review:
types: [submitted]
jobs:
check-diff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Check changed files
id: check-diff
run: |
non_icon_changes="$(
git diff --name-only HEAD "$(
git merge-base HEAD origin/${{ github.base_ref }}
)" -- . ':!**/calcite-ui-icons/**'
)"
printf "changed non-icon files:\n%s" "$non_icon_changes"
# skip if the only changes are in package/calcite-ui-icons
if [ -z "$non_icon_changes" ]; then
echo "SKIP=true" >> "$GITHUB_OUTPUT"
else
echo "SKIP=false" >> "$GITHUB_OUTPUT"
fi
- if: steps.check-diff.outputs.SKIP == 'false'
name: Check pull request author and reviewers
uses: actions/github-script@v7
with:
github-token: ${{ secrets.ADMIN_TOKEN }}
script: |
const action = require('${{ github.workspace }}/.github/scripts/iconTeamDiffCheck.js')
await action({github, context, core})
33 changes: 21 additions & 12 deletions .github/workflows/pr-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,38 @@ on:
branches: [main, rc, dev]
jobs:
e2e:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: skip for markdown only prs
id: markdown-check
- name: Check diff for testable changes
id: diff-check
run: |
current_branch="$(git rev-parse --abbrev-ref HEAD)"
# diff of branch excluding md
testable_changes=$(git diff --name-only "$current_branch" $(git merge-base "$current_branch" origin/${{ github.base_ref }}) -- . ':(exclude)*.md*')
testable_changes="$(
git diff --name-only HEAD "$(
git merge-base HEAD origin/${{ github.base_ref }}
)" -- . ':!*.md*' ':!**/calcite-ui-icons/**'
)"
echo "changed files: $testable_changes"
# skip if there are only md changes
if [ -z "$testable_changes" ]; then
echo "skip e2e"
echo "SKIP=true" >> $GITHUB_OUTPUT
echo "SKIP=true" >> "$GITHUB_OUTPUT"
else
echo "run e2e"
echo "SKIP=false" >> $GITHUB_OUTPUT
echo "SKIP=false" >> "$GITHUB_OUTPUT"
fi
- if: steps.markdown-check.outputs.SKIP == 'false'
- if: steps.diff-check.outputs.SKIP == 'false'
uses: actions/setup-node@v4
with:
node-version-file: package.json
- if: steps.markdown-check.outputs.SKIP == 'false'
- if: steps.diff-check.outputs.SKIP == 'false'
name: Run tests for testable changes
run: npm install && npm run build && npm run test
- if: steps.diff-check.outputs.SKIP == 'true'
name: Skip visual snapshots for non-testable changes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
gh pr edit "$PR_NUMBER" --add-label "skip visual snapshots"
1 change: 1 addition & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"packages/calcite-components": "2.10.1",
"packages/calcite-components-react": "2.10.1",
"packages/calcite-design-tokens": "2.2.0",
"packages/calcite-ui-icons": "3.29.0",
"packages/eslint-plugin-calcite-components": "1.2.0",
"packages/calcite-components-angular/projects/component-library": "2.10.1"
}
1 change: 1 addition & 0 deletions .renovaterc.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"ts-jest",
"typescript"
],
"ignorePaths": ["packages/calcite-ui-icons/**"],
"packageRules": [
{
"matchPackagePatterns": ["*"],
Expand Down
Loading

0 comments on commit 05264ea

Please sign in to comment.