-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(*): create package and sharable eslint config (#1)
* feat(*): initial setup * ci: add package previews * docs: update readme * fix: lefthook commands * docs: update readme * feat: json config and docs * chore: update patterns * docs: update readme * feat: cypress config * fix: files * fix: files * fix: cypress config * fix: cypress config should include base * fix: allow unused vars in cypress
- Loading branch information
1 parent
446f48a
commit 38d7524
Showing
25 changed files
with
6,050 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_size = 2 | ||
indent_style = space | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# These owners will be the default owners for everything in | ||
# the repo. They will be requested for review whenever someone | ||
# opens a PR, unless a later match takes precedence. | ||
* @adamdehaven @jillztom @Kong/team-core-ui | ||
|
||
# Workflows & CI | ||
/.github/ @adamdehaven @jillztom @ValeryG | ||
/lefthook.yaml @adamdehaven @jillztom | ||
|
||
# ================================================ | ||
# Renovate Bot approvals | ||
# Allow Kongponents BOT to approve dependency updates | ||
# These rules MUST remain at the bottom as the last entry | ||
package.json @kongponents-bot @Kong/team-core-ui @adamdehaven @jillztom @ValeryG | ||
yarn.lock @kongponents-bot @Kong/team-core-ui @adamdehaven @jillztom @ValeryG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Setup PNPM with Dependencies | ||
description: Reusable composition of setup-node, cache, and pnpm install actions | ||
inputs: | ||
nodejs-version: | ||
description: 'Version of NodeJS to use (ex: 20.13.1)' | ||
default: '20.13.1' | ||
force-install: | ||
description: When 'true', pnpm install will be executed regardless of a cache hit | ||
required: false | ||
default: 'false' | ||
frozen-lockfile: | ||
description: When false, pnpm install will use the --no-frozen-lockfile flag | ||
required: false | ||
default: 'true' | ||
outputs: | ||
cache-hit: | ||
description: Whether or not there was a cache hit | ||
value: ${{ steps.dependency-cache.outputs.cache-hit }} | ||
runs: | ||
using: composite | ||
steps: | ||
|
||
- name: get Node version | ||
id: node-version | ||
shell: bash | ||
run: | | ||
voltaNodeVersion=$(cat package.json|jq -r ".volta.node") | ||
if [[ $voltaNodeVersion == null ]]; then | ||
voltaNodeVersion="${{ inputs.nodejs-version }}" | ||
fi | ||
voltaPnpmVersion=$(cat package.json|jq -r ".volta.pnpm") | ||
if [[ $voltaPnpmVersion == null ]]; then | ||
voltaPnpmVersion="9.1.4" | ||
fi | ||
echo "node-version=${voltaNodeVersion}">> $GITHUB_OUTPUT | ||
echo "pnpm-version=${voltaPnpmVersion}">> $GITHUB_OUTPUT | ||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ steps.node-version.outputs.node-version }} | ||
|
||
- name: Install PNPM | ||
shell: bash | ||
run: | | ||
npm i -g pnpm@${{ steps.node-version.outputs.pnpm-version }} | ||
pnpm --version | ||
- name: Dependency Cache | ||
id: dependency-cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: '**/node_modules' | ||
key: pnpm-${{ steps.node-version.outputs.pnpm-version }}-${{ steps.node-version.outputs.node-version }}-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
|
||
- name: Install Dependencies | ||
if: ${{ inputs.force-install == 'true' || steps.dependency-cache.outputs.cache-hit != 'true' }} | ||
shell: bash | ||
run: pnpm i${{ inputs.frozen-lockfile == 'false' && ' --no-frozen-lockfile' || '' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
name: Renovate Bot dependency updates auto-merge | ||
|
||
permissions: | ||
pull-requests: write | ||
contents: write | ||
|
||
on: pull_request_target | ||
|
||
jobs: | ||
renovate-autoapprove: | ||
if: ${{ github.actor == 'renovate[bot]' }} | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- name: Approve a PR | ||
run: gh pr review --approve "$PR_URL" | ||
env: | ||
PR_URL: ${{ github.event.pull_request.html_url }} | ||
# Use the bot account PAT to allow auto-approve and merge the PRs | ||
GITHUB_TOKEN: ${{ secrets.KONGPONENTS_BOT_PAT }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Cleanup PR preview packages | ||
on: | ||
workflow_dispatch: | ||
|
||
schedule: | ||
- cron: '0 2/6 * * 6,0' | ||
|
||
concurrency: | ||
group: ${{ github.ref }}-${{ github.workflow }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
cleanup: | ||
name: Cleanup PR Previews | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN_PUBLIC_PUBLISH }} | ||
GITHUB_TOKEN: ${{ secrets.KONGPONENTS_BOT_PAT }} | ||
|
||
steps: | ||
- name: Checkout Source Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Prepare cleanup | ||
id: prepare | ||
run: | | ||
echo "openPRs=$(gh pr list --state open --json number|jq -cM 'map(.number|tostring)')" >> $GITHUB_OUTPUT | ||
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc | ||
- name: Cleanup PR preview | ||
uses: Kong/public-shared-actions/pr-previews/cleanup@main | ||
with: | ||
package: "@kong/eslint-config-kong-ui" | ||
openPRs: ${{ steps.prepare.outputs.openPRs }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Lint Commit Messages | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
commitlint: | ||
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' }} | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: wagoid/commitlint-github-action@v6 | ||
with: | ||
configFile: commitlint.config.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: On closing PR | ||
on: | ||
pull_request_target: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
remove-pr-preview-comment: | ||
name: Remove PR preview comment from PR | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN_PUBLIC_PUBLISH }} | ||
steps: | ||
- name: Checkout Source Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Remove preview consumption comment | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: pr_preview_consumption | ||
delete: true | ||
GITHUB_TOKEN: ${{ secrets.KONGPONENTS_BOT_PAT }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
# Allow calling manually from GitHub | ||
workflow_dispatch: | ||
|
||
jobs: | ||
run-tests: | ||
name: Tests | ||
uses: ./.github/workflows/test.yaml | ||
|
||
publish: | ||
name: Publish | ||
needs: | ||
- run-tests | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.KONGPONENTS_BOT_PAT }} | ||
|
||
- name: Setup git | ||
run: | | ||
git config user.email "[email protected]" | ||
git config user.name "Kong UI Bot" | ||
- name: Create .npmrc | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN_PUBLIC_PUBLISH }} | ||
# Reference the env variable NPM_TOKEN here, not the secret | ||
run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc | ||
|
||
|
||
- name: Setup PNPM with Dependencies | ||
uses: ./.github/actions/setup-pnpm-with-dependencies/ | ||
|
||
- name: Semantic Release | ||
uses: cycjimmy/semantic-release-action@v3 | ||
env: | ||
# Since branch protections are on (pushing commits) you need to use a bot PAT | ||
GITHUB_TOKEN: ${{ secrets.KONGPONENTS_BOT_PAT }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN_PUBLIC_PUBLISH }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
- labeled | ||
branches: | ||
- main | ||
|
||
# Allow calling manually from GitHub | ||
workflow_dispatch: | ||
|
||
# Allow workflow to be called by another workflow | ||
workflow_call: | ||
|
||
jobs: | ||
test: | ||
name: Run Tests | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Remove preview consumption comment | ||
if: github.event_name == 'pull_request' | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: pr_preview_consumption | ||
delete: true | ||
GITHUB_TOKEN: ${{ secrets.KONGPONENTS_BOT_PAT }} | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup PNPM with Dependencies | ||
uses: ./.github/actions/setup-pnpm-with-dependencies/ | ||
with: | ||
force-install: true | ||
|
||
- name: Lint | ||
run: pnpm lint | ||
|
||
- name: Publish Package Preview | ||
id: package-preview | ||
# Do not run for `alpha` or `beta` branches | ||
if: github.event_name == 'pull_request' && (github.actor != 'renovate[bot]' || contains(github.event.pull_request.labels.*.name, 'create preview package')) && !contains(github.head_ref || github.ref_name, 'alpha') && !contains(github.head_ref || github.ref_name, 'beta') | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN_PUBLIC_PUBLISH }} | ||
run: | | ||
git config user.email "[email protected]" | ||
git config user.name "Kong UI Bot" | ||
preid="pr.${{ github.event.pull_request.number }}.$(git rev-parse --short ${{ github.event.pull_request.head.sha }})" | ||
tag="pr-${{ github.event.pull_request.number }}" | ||
echo "preid=${preid}" | ||
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc | ||
# Use yarn to bump the version for the prerelease | ||
pnpm version prerelease --preid ${preid} --no-git-tag-version --yes --amend | ||
package_version=$(jq -r ".version" package.json) | ||
package=@kong/eslint-config-kong-ui@"${package_version}" | ||
npm show "${package}" >/dev/null 2>&1 && npm_show_status=0 || npm_show_status=1 | ||
if [ $npm_show_status -eq 0 ]; then | ||
echo "Package ${package} is already published. Skipping publishing." | ||
exit 0 | ||
fi | ||
npm_instructions="" | ||
pkg=$(pnpm publish --no-git-checks --access public --report-summary --tag "${tag}" | grep "+ "| sed 's/+ //') | ||
if [[ -z "${pkg}" ]]; then | ||
echo "Error publishing package" | ||
exit -1 | ||
fi | ||
npm_instructions="@$(echo ${pkg}|cut -d'@' -f2)@${tag}" | ||
echo "npm_instructions<<EOF" >> $GITHUB_OUTPUT | ||
echo -e "$npm_instructions" >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
- name: Provide preview link info | ||
if: ${{ steps.package-preview.outputs.npm_instructions != '' }} | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: pr_preview_consumption | ||
message: | | ||
### Install the preview package from this PR | ||
```sh | ||
${{ steps.package-preview.outputs.npm_instructions }} | ||
``` | ||
GITHUB_TOKEN: ${{ secrets.KONGPONENTS_BOT_PAT }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
node_modules | ||
*.log | ||
.output | ||
.data | ||
# Env variables | ||
.env | ||
.env.local | ||
|
||
package-lock.json | ||
framework | ||
dist | ||
.DS_Store | ||
|
||
# Local History | ||
.history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
shamefully-hoist=true | ||
strict-peer-dependencies=false | ||
auto-install-peers=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
20.13.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit", | ||
"source.fixAll.stylelint": "explicit" | ||
}, | ||
"editor.formatOnPaste": true, | ||
"editor.trimAutoWhitespace": true, | ||
"editor.tabSize": 2, | ||
"editor.insertSpaces": true, | ||
"editor.detectIndentation": false, | ||
"eslint.format.enable": true, | ||
"eslint.validate": [ | ||
"typescript", | ||
"javascript", | ||
"javascriptreact", | ||
"vue", | ||
"json" | ||
] | ||
} |
Oops, something went wrong.