Skip to content

Commit

Permalink
feat!: JOIN-19248 configure semantic release (#52)
Browse files Browse the repository at this point in the history
* feat!: Configure semantic release
  • Loading branch information
kirpichenko authored Jun 17, 2022
1 parent 425754b commit b0e0acd
Show file tree
Hide file tree
Showing 32 changed files with 4,435 additions and 5,889 deletions.
118 changes: 77 additions & 41 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,100 @@
version: 2.1

docker-auth: &docker-auth
auth:
username: ${DOCKER_LOGIN}
password: ${DOCKER_PASSWORD}

defaults: &defaults
working_directory: /home/circleci/pubsub
working_directory: ~/pubsub
docker:
- image: node:14.17.2
version: 2
- image: cimg/node:16.14.1
<<: *docker-auth

references:
auth_with_registry: &auth_with_registry
run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > .npmrc

remove_auth_with_registry: &remove_auth_with_registry
run:
name: Remove authentication with registry
command: rm .npmrc

yarn_install: &yarn_install
run:
name: yarn install
command: yarn --frozen-lockfile --cache-folder ~/.cache/yarn

yarn_cache_key: &yarn_cache_key yarn-lock-{{ checksum "yarn.lock" }}

save_yarn_cache: &save_yarn_cache
save_cache:
name: 'Saving Yarn Cache'
key: *yarn_cache_key
paths:
- ~/.cache/yarn

restore_yarn_cache: &restore_yarn_cache
restore_cache:
name: Restoring Yarn Cache
key: *yarn_cache_key

jobs:
build:
lint:
<<: *defaults
steps:
- checkout
- restore_cache:
key: v1-yarn-lock-cache-{{ checksum "yarn.lock" }}
- *restore_yarn_cache
- *auth_with_registry
- *yarn_install
- run:
name: yarn install
command: yarn install
- save_cache:
key: v1-yarn-lock-cache-{{ checksum "yarn.lock" }}
paths:
- node_modules
name: lint
command: yarn lint
- *save_yarn_cache
- *remove_auth_with_registry

test:
<<: *defaults
steps:
- checkout
- restore_cache:
key: v1-yarn-lock-cache-{{ checksum "yarn.lock" }}
- run:
name: yarn install
command: yarn install
- *restore_yarn_cache
- *auth_with_registry
- *yarn_install
- run:
name: test
command: yarn lerna run test
- store_test_results:
path: log
- store_artifacts:
path: log
destination: log
lint:
command: yarn test
- *save_yarn_cache
- *remove_auth_with_registry

release:
<<: *defaults
steps:
- checkout
- restore_cache:
key: v1-yarn-lock-cache-{{ checksum "yarn.lock" }}
- run:
name: yarn install
command: yarn install
- *restore_yarn_cache
- *auth_with_registry
- *yarn_install
- run:
name: lint
command: yarn lerna run lint
- store_test_results:
path: log
- store_artifacts:
path: log
destination: log
name: release
command: yarn release
- *remove_auth_with_registry

workflows:
version: 2
build_test_deploy:
jobs:
- build
- test:
requires:
- build
- lint:
context: Global
- test:
context: Global
- release:
context: Global
filters:
branches:
only:
- master
- alpha
requires:
- build
- lint
- test
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@join-private/backend/typescript', '@join-private/backend/jest'],
}
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'monthly'
allow:
- dependency-type: 'production'
rebase-strategy: 'disabled'
commit-message:
prefix: "build"
include: "scope"
24 changes: 24 additions & 0 deletions .github/workflows/lint-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'Lint PR title'

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
lint:
name: lint-pr-title
runs-on: ubuntu-latest
steps:
- name: semantic-pull-request
uses: amannn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
with:
subjectPattern: ^((JOIN-\d+([, ]JOIN-\d+)*)|TECH|bump) (?![A-Z]).+$
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
doesn't start with an uppercase character and includes jira ticket.
3 changes: 3 additions & 0 deletions .hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

yarn lint
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.17.2
16.14.1
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.md
*.yaml
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"semi": false,
"printWidth": 120,
"singleQuote": true,
"parser": "typescript",
"trailingComma": "none",
"trailingComma": "all",
"arrowParens": "avoid"
}
46 changes: 46 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"branches": [
{ "name": "main" },
{ "name": "master" },
{ "name": "alpha", "prerelease": true }
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{ "type": "build", "scope": "deps", "release": "patch" }
]
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{ "type": "feat", "section": "Features" },
{ "type": "fix", "section": "Bug Fixes" },
{ "type": "build", "section": "Dependencies" },
{ "type": "chore", "hidden": true },
{ "type": "docs", "hidden": true },
{ "type": "style", "hidden": true },
{ "type": "refactor", "hidden": true },
{ "type": "perf", "hidden": true },
{ "type": "test", "hidden": true }
]
}
}
],
"@semantic-release/npm",
[
"@semantic-release/github",
{
"labels": false,
"releasedLabels": false,
"successComment": false
}
]
]
}
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry "https://registry.npmjs.org/"
8 changes: 0 additions & 8 deletions lerna.json

This file was deleted.

44 changes: 14 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,25 @@
{
"name": "@join-com/pubsub",
"version": "0.0.20",
"description": "Google Cloud PubSub wrapper",
"main": "lib/index.js",
"types": "./lib/index.d.ts",
"repository": "github:join-com/pubsub",
"author": "JOIN AG",
"license": "UNLICENSED",
"private": true,
"workspaces": [
"packages/*"
"packages/pubsub"
],
"scripts": {
"makepretty": "prettier --write '**/*.ts'"
"build": "yarn workspaces run build",
"lint": "yarn workspaces run lint",
"test": "yarn workspaces run test",
"release": "yarn workspaces run semantic-release -e semantic-release-monorepo -d",
"postinstall": "if [ -d .git ]; then git config core.hooksPath .hooks; fi"
},
"husky": {
"hooks": {
"pre-commit": "lerna run build && lint-staged"
}
"engines": {
"node": ">=14.0.0"
},
"lint-staged": {
"*.{ts}": [
"yarn prettier --write"
],
"src/**/*.ts": [
"npm run lint --fix"
]
},
"keywords": [
"pubsub",
"gcloud"
],
"devDependencies": {
"husky": "^4.3.6",
"lerna": "^3.22.1",
"lint-staged": "^10.5.3",
"prettier": "^2.2.1"
"conventional-changelog-conventionalcommits": "^5.0.0",
"semantic-release": "^19.0.3",
"semantic-release-monorepo": "^7.0.5"
},
"dependencies": {}
"resolutions": {
"@semantic-release/npm": "8.0.3"
}
}
3 changes: 3 additions & 0 deletions packages/pubsub/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
generated/
node_modules/
3 changes: 3 additions & 0 deletions packages/pubsub/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const baseConfig = require('../../.eslintrc.js')

module.exports = baseConfig
10 changes: 10 additions & 0 deletions packages/pubsub/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
coverage/
node_modules/
src/
.eslintignore
.eslintrc.js
.npmignore
jest.config.js
tsconfig.prod.tsbuildinfo
tsconfig.prod.json
tsconfig.json
3 changes: 0 additions & 3 deletions packages/pubsub/__mocks__/@join-com/node-trace/index.ts

This file was deleted.

14 changes: 6 additions & 8 deletions packages/pubsub/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules/', '/support/'],
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname'
],
setupFilesAfterEnv: ['jest-extended/all'],
testPathIgnorePatterns: ['/node_modules/', 'generated', 'support'],
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
globals: {
'ts-jest': {
diagnostics: false
}
}
diagnostics: false,
},
},
}
Loading

0 comments on commit b0e0acd

Please sign in to comment.