Skip to content

Commit

Permalink
feat(*): initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdehaven committed Jun 5, 2024
1 parent 446f48a commit 3a52a69
Show file tree
Hide file tree
Showing 18 changed files with 5,664 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
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
15 changes: 15 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
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
60 changes: 60 additions & 0 deletions .github/actions/setup-pnpm-with-dependencies/action.yaml
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' || '' }}
21 changes: 21 additions & 0 deletions .github/workflows/auto-approve.yaml
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 }}
18 changes: 18 additions & 0 deletions .github/workflows/commitlint.yaml
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
49 changes: 49 additions & 0 deletions .github/workflows/publish.yaml
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 }}
36 changes: 36 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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: 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
15 changes: 15 additions & 0 deletions .gitignore
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
3 changes: 3 additions & 0 deletions .npmrc
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
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.13.1
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# eslint-config-kong-ui
10 changes: 10 additions & 0 deletions commitlint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default {
extends: ['@commitlint/config-conventional'],
rules: {
'header-max-length': [2, 'always', 100],
'body-max-line-length': [1, 'always', 150],
'type-case': [2, 'always', 'lower-case'],
'scope-case': [2, 'always', 'lower-case'],
},
ignores: [(message) => /^chore\(release\): .+$/m.test(message)],
}
Loading

0 comments on commit 3a52a69

Please sign in to comment.