Skip to content

Commit

Permalink
feat: refactor entire shared libraries
Browse files Browse the repository at this point in the history
Signed-off-by: Wouter Termont <[email protected]>
  • Loading branch information
woutermont committed Sep 28, 2021
1 parent a0146cf commit 6e147fc
Show file tree
Hide file tree
Showing 662 changed files with 36,452 additions and 17,088 deletions.
14 changes: 0 additions & 14 deletions .editorconfig

This file was deleted.

106 changes: 106 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: CI

on:
push:
branches:
- master
- develop
- release
- release/*
- feature/*
- feat/*
- fix/*
- test/*
- chore/*
- build/*

tags:
- '*'

env:
NPM_TOKEN: ${{secrets.GA_TOKEN}}

jobs:
test:
name: Run tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Extract tag
id: extract-tag
run: echo "::set-output name=tag::${GITHUB_REF/refs\/tags\//}"

- name: Check tag
run: echo ${{ steps.extract-tag.outputs.tag }}

- name: Extract branch
id: extract-branch
run: echo "::set-output name=branch::${GITHUB_REF/refs\/heads\//}"

- name: Check branch
run: echo ${{ steps.extract-branch.outputs.branch }}

- uses: actions/setup-node@v1
with:
node-version: 14

- run: npm run bootstrap

- run: npm run build:all

- run: npm run lint:all

- run: npm run test:all

release:
name: Create release
needs: test
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body_path: CHANGELOG.md
draft: false
prerelease: false

publish-npm:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: release
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v1
with:
node-version: 14
registry-url: https://npm.pkg.github.com/

- run: npm run bootstrap

- run: npm run build:all

- run: npm publish packages/dgt-components
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- run: npm publish packages/dgt-theme
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- run: npm publish packages/dgt-utils
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

177 changes: 116 additions & 61 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,61 +1,116 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out

# dependencies
/node_modules
/projects/dgt-shared-utils/node_modules
/projects/dgt-shared-web/node_modules
/projects/dgt-shared-data/node_modules
/projects/dgt-shared-venture/node_modules
/projects/dgt-shared-connectors/node_modules
/projects/dgt-shared-test/node_modules

# profiling files
chrome-profiler-events.json
speed-measure-plugin.json

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db

package-lock.json
yarn.lock
projects/dgt-shared-web/yarn.lock
projects/dgt-shared-test/yarn.lock
projects/dgt-shared-utils/yarn.lock
projects/dgt-shared-data/yarn.lock
projects/dgt-shared-connectors/yarn.lock
projects/dgt-shared-venture/yarn.lock
.npmrc
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Error files
componentsjs-error-state.json

# Static assets
assets

# jest coverage files
coverage-summary.json

# pod data
rundata
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
96 changes: 96 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/sh

. "$(dirname $0)/_/husky.sh"

## List changed files
STATUS=$(git status --porcelain)
STAGED=$(echo "$STATUS" | grep -E '^(M|A|D|R|C) ' | sed -E 's/^(M|A|D|R|C) ([^ ]+).*$/\2/g')
#MODIFIED=$(echo "$STATUS" | grep -E '^ (M|A|D|R|C)' | sed -E 's/^ (M|A|D|R|C) ([^ ]+).*$/\2/g')
#UNTRACKED=$(echo "$STATUS" | grep -E '^??' | sed -E 's/^?? //g')
#CHANGED=$(echo "$STAGED" && echo "$MODIFIED" && echo "$UNTRACKED")

## Check for ongoing merge
MERGE=$(git rev-parse -q --verify MERGE_HEAD || echo "")
M_MSG=$([[ -f .git/MERGE_MSG ]] && cat .git/MERGE_MSG || echo '')

## Check for empty commits
if [[ -z "$STAGED" && -z "$MERGE" ]] ; then

echo "[COMMIT-MSG Hook] No staged changes && no ongoing merge => aborting commit"
exit 1

fi

## Lint commit message
echo "[COMMIT-MSG Hook] Linting commit message" && ./node_modules/.bin/commitlint --edit $1

## Check for WIP mention
if (grep -qe "WIP" $1); then

## If WIP, skip tests
echo "[COMMIT-MSG Hook] Found WIP mention => Skipping tests"

else

## If no WIP, run tests
echo "[COMMIT-MSG Hook] No WIP mention found"

if [[ -n "$MERGE" ]] ; then
echo "[COMMIT-MSG Hook] Saved ongoing merge status"
fi

if [[ -n "$STAGED" ]] ; then
echo "[COMMIT-MSG Hook] Stashing working tree"
STASH="pre-commit hook test on $(date '+%F %T')" && git stash push -qukm "$STASH"
fi

echo "[COMMIT-MSG Hook] Running tests"

## Build list of previous WIP changes
LIST=""
NEW=$(git rev-parse HEAD)
while [[ -n "$NEW" ]] ; do
LIST=$(echo "$LIST" ; echo "$NEW")
NEW=$(echo "$NEW" | sed -e 's/^\(.*\)$/\1\^@/g' | xargs git rev-list --no-walk -E --grep="WIP")
done

RELEVANT="$(echo "$LIST" | xargs -L1 git diff-tree --no-commit-id --name-only -r | sort -u ; echo "$STAGED")"

## Install root dependencies if package.json changed
echo "$RELEVANT" | grep -q "^package.json$" && npm i

## Bootstrap packages with changed package.json
PACKAGES=$(echo "$RELEVANT" | grep "package.json$" | grep -v "^package.json$" | xargs cat | grep name
echo "$PACKAGES" | sed 's/.*"name": "\(.*\)".*/--scope "\1"/g') | xargs ./node_modules/.bin/lerna bootstrap --since HEAD

## Run tests related to staged files
echo "$RELEVANT" | xargs ./node_modules/.bin/jest --bail --coverage --silent --passWithNoTests --findRelatedTests

if [[ $? -ne 0 ]] ; then
echo "[COMMIT-MSG Hook] You tried to commit changes without a WIP mention,"
echo "[COMMIT-MSG Hook] but tests related to staged files or yet untested WIP commits are failing."
echo "[COMMIT-MSG Hook] Resolve the remaining issues or commit current changes as WIP."
fi

echo "[COMMIT-MSG Hook] Resetting the stage"

## Reset tracked files & clean untracked files
git reset --hard
git clean -df

if [[ -n "$STAGED" ]] ; then
echo "[COMMIT-MSG Hook] Restoring working tree"
git stash list | grep -q "$STASH" && git stash pop -q --index
fi

if [[ -n "$MERGE" ]] ; then
echo "[COMMIT-MSG Hook] Restoring ongoing merge status"
git update-ref MERGE_HEAD "$MERGE"
if [[ -n "$M_MSG" ]] ; then
echo "$M_MSG" > .git/MERGE_MSG
fi
fi

exit $TESTS

fi
Loading

0 comments on commit 6e147fc

Please sign in to comment.