-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ci: refactor circleci config - Add `gitleaks` job for detecting unwanted secrets in code - Run `test` job in both 14 and 16 Node versions - Use [Cache](https://circleci.com/docs/2.0/caching/) for storing `node_modules` cross runs - Use [Workspace](https://circleci.com/docs/2.0/workspaces/) for storing files cross jobs - Add Workflow for PR branches * build: add githooks * build: add "commitlint" to enforce Conventional Commits message format [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) - A specification for adding human and machine readable meaning to commit messages * chore: rename _env * chore: link eslintignore and prettierignore to gitignore * build: update semantic-release to git push package version after bump * style: sync prettier's "endOfLine" with editorconfig * feat: update package to ESM BREAKING CHANGE: @asd14/blocks is now ESM only and requires node `^14.13.1 || >=16.0.0` * feat: update package to ESM BREAKING CHANGE: @asd14/blocks is now ESM only and requires node `^14.13.1 || >=16.0.0` * chore: format * chore: fix CHANGELOG.md typo Co-authored-by: David Gil <[email protected]> * fix: remove prepare step from package.json to avoid messing up with the consuming repo's environment Co-authored-by: David Gil <[email protected]>
- Loading branch information
Showing
64 changed files
with
20,546 additions
and
23,888 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 |
---|---|---|
@@ -1,112 +1,148 @@ | ||
# Javascript Node CircleCI 2.0 configuration file | ||
# CircleCI 2.0 configuration file | ||
# | ||
# Check https://circleci.com/docs/2.0/language-javascript/ for more details | ||
# | ||
version: 2 | ||
|
||
# | ||
# YAML variable templates | ||
# | ||
job_defaults: &job_defaults | ||
working_directory: ~/blocks | ||
docker: | ||
- image: circleci/node:12 | ||
|
||
job_filter: &job_filter | ||
filters: | ||
branches: | ||
only: | ||
- master | ||
version: 2.1 | ||
|
||
# Executors - https://circleci.com/docs/2.0/executor-intro/ | ||
# | ||
# Run all jobs in sequence | ||
# The underlying technology or environment in which to run a job | ||
|
||
executors: | ||
gitleaks: | ||
docker: | ||
- image: zricethezav/gitleaks:latest | ||
node14: | ||
docker: | ||
- image: cimg/node:14.13.1 | ||
node16: | ||
docker: | ||
- image: cimg/node:16.14.2 | ||
|
||
# Jobs - https://circleci.com/docs/2.0/configuration-reference/#jobs | ||
# | ||
workflows: | ||
version: 2 | ||
deploy_npm: | ||
jobs: | ||
- setup: | ||
<<: *job_filter | ||
- test: | ||
<<: *job_filter | ||
requires: | ||
- setup | ||
- coverage: | ||
<<: *job_filter | ||
requires: | ||
- test | ||
- publish: | ||
<<: *job_filter | ||
requires: | ||
- coverage | ||
# Atomic parts of the pipeline that will be composed and configured in one or | ||
# more Workflows | ||
|
||
# | ||
# Define atomic jobs | ||
# | ||
jobs: | ||
setup: | ||
<<: *job_defaults | ||
|
||
detect-secrets: | ||
executor: gitleaks | ||
working_directory: &JOB_WORKING_DIR "~/blocks" | ||
steps: | ||
- checkout | ||
|
||
- run: | ||
name: "blocks: Install npm packages" | ||
command: "npm run setup:ci" | ||
name: "[gitleaks] Detect secrets in repository history" | ||
command: | | ||
gitleaks detect --redact --verbose | ||
- persist_to_workspace: | ||
root: &WORKSPACE_ROOT "~/" | ||
paths: | ||
- blocks | ||
|
||
setup: | ||
executor: node16 | ||
working_directory: *JOB_WORKING_DIR | ||
steps: | ||
- attach_workspace: | ||
at: *WORKSPACE_ROOT | ||
- restore_cache: | ||
name: '[circleci] Restore cached "node_modules" folder' | ||
key: | ||
&CACHE_KEY_NODE_MODULES 'blocks-v1-{{ arch }}-{{ checksum | ||
"package-lock.json" }}' | ||
- run: | ||
name: "[npm]: Install packages" | ||
command: | | ||
node -v && npm -v | ||
npm run setup | ||
- save_cache: | ||
paths: | ||
- node_modules | ||
- src | ||
- tests | ||
- .git | ||
- .eslintrc | ||
- .gitignore | ||
- .nycrc | ||
- .prettierrc | ||
- README.md | ||
- CHANGELOG.md | ||
- package-lock.json | ||
- package.json | ||
key: blocks-{{ .Branch }}-{{ .Revision }} | ||
key: *CACHE_KEY_NODE_MODULES | ||
- persist_to_workspace: | ||
root: *WORKSPACE_ROOT | ||
paths: | ||
- blocks | ||
|
||
test: | ||
<<: *job_defaults | ||
|
||
parameters: | ||
node-version: | ||
type: string | ||
executor: node<< parameters.node-version >> | ||
working_directory: *JOB_WORKING_DIR | ||
steps: | ||
- restore_cache: | ||
keys: | ||
- blocks-{{ .Branch }}-{{ .Revision }} | ||
|
||
- attach_workspace: | ||
at: *WORKSPACE_ROOT | ||
- run: | ||
name: "blocks: Run linter" | ||
command: "npm run lint" | ||
|
||
name: "[eslint, markdownlint]: Lint" | ||
command: | | ||
npm run lint | ||
- run: | ||
name: "blocks: Run tests" | ||
command: "npm run test" | ||
|
||
coverage: | ||
<<: *job_defaults | ||
name: "[tape]: Unit tests" | ||
command: "npm test" | ||
|
||
submit-coverage: | ||
executor: node16 | ||
working_directory: *JOB_WORKING_DIR | ||
steps: | ||
- restore_cache: | ||
keys: | ||
- blocks-{{ .Branch }}-{{ .Revision }} | ||
|
||
- attach_workspace: | ||
at: *WORKSPACE_ROOT | ||
- run: | ||
name: "blocks: Publish test coverage to COVERALLS" | ||
command: "npm run coverage:ci" | ||
|
||
publish: | ||
<<: *job_defaults | ||
name: "[coveralls]: Publish test coverage to COVERALLS" | ||
command: "npm run coverage" | ||
|
||
release-npm: | ||
executor: node16 | ||
working_directory: *JOB_WORKING_DIR | ||
steps: | ||
- restore_cache: | ||
keys: | ||
- blocks-{{ .Branch }}-{{ .Revision }} | ||
|
||
- attach_workspace: | ||
at: *WORKSPACE_ROOT | ||
- run: | ||
name: "blocks: Release to npm with semantic-release" | ||
command: "npx semantic-release" | ||
name: | ||
"[semantic-release]: Update version, generate release, publish npm | ||
package" | ||
command: "npm run release" | ||
|
||
# Workflows - https://circleci.com/docs/2.0/workflows/ | ||
# | ||
# Treat workflows as a jobs/commands pipe: | ||
# cmd1 -p1 lorem | cmd2 -foo bar | ... | cmdN) | ||
|
||
workflows: | ||
test: | ||
jobs: | ||
- detect-secrets: | ||
filters: | ||
branches: | ||
ignore: [master] | ||
- setup: | ||
requires: [detect-secrets] | ||
- test: | ||
name: "test_node14" | ||
requires: [setup] | ||
node-version: "14" | ||
- test: | ||
name: "test_node16" | ||
requires: [setup] | ||
node-version: "16" | ||
|
||
release: | ||
jobs: | ||
- detect-secrets: | ||
filters: | ||
branches: | ||
only: [master] | ||
- setup: | ||
requires: [detect-secrets] | ||
- test: | ||
name: "test_node14" | ||
requires: [setup] | ||
node-version: "14" | ||
- test: | ||
name: "test_node16" | ||
requires: [setup] | ||
node-version: "16" | ||
- submit-coverage: | ||
requires: [test_node14, test_node16] | ||
- release-npm: | ||
requires: [test_node14, test_node16] |
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 @@ | ||
{ | ||
"extends": ["@commitlint/config-conventional"] | ||
} |
File renamed without changes.
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 @@ | ||
.gitignore |
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 |
---|---|---|
@@ -1,20 +1,10 @@ | ||
{ | ||
"parser": "babel-eslint", | ||
"root": true, | ||
"extends": [ | ||
"@asd14/eslint-config/targets/node" | ||
], | ||
"extends": ["@asd14/eslint-config/targets/node-esm"], | ||
"settings": { | ||
"import/resolver": "node", | ||
|
||
// Recommended if you use eslint_d | ||
"import/cache": { | ||
"lifetime": 5 | ||
} | ||
}, | ||
"rules": { | ||
"unicorn/consistent-function-scoping": "warn", | ||
"promise/avoid-new": "off", | ||
"valid-jsdoc": "off" | ||
}, | ||
"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,9 @@ | ||
#!/bin/sh | ||
|
||
# Dont run when in CI environment. | ||
# For ex. when pushing changelogs via "semantic-release". | ||
if [ -n "$CI" ]; then | ||
exit 0 | ||
fi | ||
|
||
npx --no-install commitlint < "$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,12 @@ | ||
#!/bin/sh | ||
|
||
# Exit script if any statement returns a non-true return value | ||
set -e | ||
|
||
packageLockChanged=$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD \ | ||
| grep -c "package-lock.json" \ | ||
) | ||
|
||
if [ "$packageLockChanged" != "0" ]; then | ||
npm install --no-audit --progress=false | ||
fi |
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 @@ | ||
#!/bin/sh | ||
|
||
# Exit script if any statement returns a non-true return value | ||
set -e | ||
|
||
packageLockChanged=$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD \ | ||
| grep -c "package-lock.json" \ | ||
) | ||
|
||
if [ "$packageLockChanged" != "0" ]; then | ||
npm install --no-audit --progress=false | ||
fi |
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 @@ | ||
#!/bin/sh | ||
|
||
npx --no-install lint-staged |
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,7 @@ | ||
#!/bin/sh | ||
|
||
# Exit script if any statement returns a non-true return value | ||
set -e | ||
|
||
npm run lint | ||
npm run test |
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 |
---|---|---|
|
@@ -57,6 +57,7 @@ typings/ | |
|
||
# dotenv environment variables file | ||
.env | ||
!.env.* | ||
|
||
# next.js build output | ||
.next | ||
|
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 @@ | ||
.gitignore |
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
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,33 @@ | ||
{ | ||
"branches": [{ "name": "master" }], | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
[ | ||
"@semantic-release/release-notes-generator", | ||
{ | ||
"preset": "conventionalcommits", | ||
"presetConfig": { | ||
"types": [ | ||
{ "type": "feat", "section": "Features" }, | ||
{ "type": "fix", "section": "Bug Fixes" }, | ||
{ "type": "perf", "section": "Performance Improvements" }, | ||
{ "type": "style", "section": "Styles", "hidden": false }, | ||
{ "type": "test", "section": "Tests", "hidden": false }, | ||
{ "type": "docs", "section": "Documentation", "hidden": false }, | ||
{ "type": "build", "section": "Build System", "hidden": false }, | ||
{ "type": "refactor", "section": "Refactors", "hidden": false }, | ||
{ "type": "ci", "section": "CI", "hidden": false } | ||
] | ||
} | ||
} | ||
], | ||
"@semantic-release/npm", | ||
[ | ||
"@semantic-release/git", | ||
{ | ||
"assets": ["package.json", "package-lock.json"] | ||
} | ||
], | ||
"@semantic-release/github" | ||
] | ||
} |
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
Oops, something went wrong.