Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next Major Version of library #426

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"presets":[["@babel/preset-env",{"bugfixes":true,"debug":false}],["@babel/preset-react"]]}
5 changes: 3 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ full/**
lib/**
node_modules
reports
*.test.js
**/*.d.ts
documentation/**
.coverage
.coverage
esm
cjs
59 changes: 0 additions & 59 deletions .eslintrc

This file was deleted.

45 changes: 45 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module.exports = {
extends: ['airbnb', 'plugin:react-hooks/recommended', 'prettier'],
parserOptions: {
ecmaVersion: 2022,
},
globals: {
window: true,
document: true,
},
env: {
es2022: true,
browser: true,
node: true,
jest: true,
},
plugins: ['prettier', 'import'],
rules: {
'react/prop-types': 0,
'react/jsx-filename-extension': 0,
'react/jsx-props-no-spreading': 0,
'jsx-a11y/click-events-have-key-events': 0,
'jsx-a11y/anchor-is-valid': 0,
'jsx-a11y/label-has-associated-control': 0,
'react/forbid-prop-types': 0,
'react/function-component-definition': [
2,
{
namedComponents: 'arrow-function',
unnamedComponents: 'arrow-function',
},
],
'react/require-default-props': 0,
'prettier/prettier': 2,
'no-console': 0,
'no-param-reassign': 0,
'import/no-extraneous-dependencies': 0,
'global-require': 0,
'import/prefer-default-export': 0,
'max-len': 0,
'no-underscore-dangle': 0,
'class-methods-use-this': 0,
'arrow-body-style': [2, 'always'],
'import/no-dynamic-require': 0,
},
};
37 changes: 37 additions & 0 deletions .github/actions/npm-install/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 'Install dependencies'
description: 'Install dependencies and cache'
author: 'GDM BX UI Tools'
inputs:
install-options:
description: 'Install options'
required: false
default: '--ignore-scripts --no-audit'
working-directory:
description: 'Working directory'
required: false
default: '.'
runs:
using: 'composite'
steps:
- name: 'node_modules cache'
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: |
~/.npm
**/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
if: steps.cache-npm.outputs.cache-hit != 'true'
shell: bash
working-directory: ${{ inputs.working-directory }}
env:
NODE_ENV: development
run: npm ci ${{ inputs.install-options }}
49 changes: 49 additions & 0 deletions .github/actions/parse-info/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: 'Parse Git Information'
description: 'Parse git information for tags, version, commit message'
outputs:
tag:
description: 'latest for master, pr-X for pr instances otherwise undefined'
value: ${{ steps.parse.outputs.tag }}
version:
description: 'Current Version'
value: ${{ steps.parse.outputs.version }}
branch:
description: 'Current Branch'
value: ${{ steps.parse.outputs.branch }}
message:
description: 'Current commit message'
value: ${{ steps.parse.outputs.message }}
updateType:
description: 'Parse commit message to get the release type [pre|major,minot,path,release]'
value: ${{ steps.parse.outputs.updateType }}

runs:
using: 'composite'
steps:
- name: 'Parse GIT Information'
shell: bash
id: parse
run: |
declare -A TAGS_MAP
TAGS_MAP=(["master"]="latest")
VERSION=$(git describe --tags --always)
BRANCH=$(git rev-parse --abbrev-ref HEAD | sed -r "s/\//\-/g")
TAG=${TAGS_MAP[$BRANCH]}
if [ -d $TAG ]; then
TAG=pr-${{ github.event.number }}
fi
commit_message=$(git log --format=%B -n 1 ${{ github.sha }})
echo "MESSAGE<<EOF" >> $GITHUB_ENV
echo "${commit_message}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
echo "message=$(echo \"${commit_message}\")" >> $GITHUB_OUTPUT
regex='\[((pre)?(minor|patch|major|release))\]'
if [[ $commit_message =~ $regex ]]; then
echo "updateType=$(echo ${BASH_REMATCH[1]})" >> $GITHUB_OUTPUT
fi
echo "----- output ------"
cat $GITHUB_OUTPUT
echo "-------------------"
47 changes: 47 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Continuous Integration
on:
pull_request:
branches:
- master
- next

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
name: Linter
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/npm-install
- name: Run eslint
run: npm run eslint
test:
runs-on: ubuntu-latest
name: Tests
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/npm-install
- name: Run Test
run: npm run test:cov
- name: Code Coverage Report
uses: irongut/[email protected]
with:
filename: .coverage/cobertura-coverage.xml
badge: true
format: markdown
hide_branch_rate: false
hide_complexity: true
output: both
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
99 changes: 99 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Release
on:
push:
branches:
- master

permissions:
contents: write
packages: write
id-token: write

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup base
id: parse
uses: ./.github/actions/parse-info
- name: Version to bump
id: bump
env:
MESSAGE: ${{ steps.parse.outputs.message }}
run: |
regex='\[((pre)?(minor|patch|major|release))\]'
if [[ $MESSAGE =~ $regex ]]; then
echo "updateType=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
fi
outputs:
updateType: ${{ steps.bump.outputs.updateType }}
test:
runs-on: ubuntu-latest
name: Lint & Tests
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/npm-install
- name: Run Test
run: npm run test
release:
runs-on: ubuntu-latest
name: Publish
needs: [setup, test]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Install dependencies
uses: ./.github/actions/npm-install
- name: 'Generate new version'
id: updatedVersion
if: ${{ needs.setup.outputs.updateType }}
env:
TYPE: ${{ needs.setup.outputs.updateType }}
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
npm version $(echo ${TYPE}) -m "v%s - [skip ci]"
echo "version=$(echo $(git describe))" >> $GITHUB_OUTPUT
git diff HEAD~ HEAD
- name: Build
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
NODE_ENV=production npm run build
- name: Push changes
uses: ad-./.github-push-action@master
if: ${{ needs.setup.outputs.updateType }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
tags: true
atomic: true
- name: Generate Release
uses: octokit/[email protected]
if: ${{ needs.setup.outputs.updateType }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/:repository/releases
repository: ${{ github.repository }}
tag_name: ${{ steps.updatedVersion.outputs.version }}
generate_release_notes: true
- name: Deploy packages
if: ${{ needs.setup.outputs.updateType }}
run: |
npm publish
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jspm_packages/

# Typescript v1 declaration files
typings/
dist

# Optional npm cache directory
.npm
Expand Down Expand Up @@ -72,4 +73,6 @@ out*
/cjs
.coverage
.vscode
.cache
.cache
*storybook.log
storybook-static
20 changes: 2 additions & 18 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,2 @@
.coverage
.storybook
docs
node_modules
.babelrc
.eslint*
.git*
README.md
webpack.config.js
yarn*
.npmignore
reports
**/__mocks__
.coveralls.yml
.travis.yml
.yarnclean
jest.json
**/__test__
*
!dist
Loading
Loading