Skip to content

Commit

Permalink
Chore: setup semantic release
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovitDmytro committed Jul 10, 2022
1 parent b3b4176 commit 0256712
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ jobs:
condition:
not: << pipeline.parameters.skip-deploy >>
steps:
- setup_remote_docker:
version: 20.10.14
- restore_cache:
<<: *cache-defaults
- run:
Expand Down
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
!package-lock.json
!LICENSE.md
!CHANGELOG.md

!templates/*
8 changes: 4 additions & 4 deletions .nycrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
],
"report-dir": "./reports/coverage",
"temp-dir": "./reports/coverage",
"lines": 95,
"statements": 90,
"functions": 90,
"branches": 85,
"lines": 87,
"statements": 86,
"functions": 78,
"branches": 63,
"check-coverage": true
}
5 changes: 3 additions & 2 deletions .package-tester.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"copy": [
[ "tests/init.js", "tests-init.js" ],
[ "tests/test.env", ".env" ],
[ ".env.defaults", ".env.defaults" ]
[ ".env.defaults", ".env.defaults" ],
[ "templates", "templates" ]
],
"copyDefaultFiles": true,
"modules": [ "cls-hooked", "fs-extra", "uuid", "winston", "winston-array-transport" ]
"modules": [ "cls-hooked", "fs-extra", "uuid", "winston", "winston-array-transport", "supertest" ]
}
25 changes: 22 additions & 3 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,32 @@
}
],
[
"@semantic-release/npm",{
"tarballDir": "./"
"@google/semantic-release-replace-plugin",
{
"replacements": [
{
"files": ["package.json"],
"from": "\"version\":\\s*\".*\"",
"to": "\"version\": \"${nextRelease.version}\""
},
{
"files": ["docker/Admin.dockerfile", "docker/Worker.dockerfile"],
"from": "FROM pustovitdmytro/ianus-base:.*",
"to": "FROM pustovitdmytro/ianus-base:${nextRelease.version}"
}
]
}
],
[
"@semantic-release/exec", {
"verifyConditionsCmd": "./bin/release/verifyConditions.sh",
"prepareCmd": "./bin/release/prepare.sh ${nextRelease.version}",
"publishCmd": "./bin/release/publish.sh ${nextRelease.version}"
}
],
[
"@semantic-release/git", {
"assets": ["README.md", "CHANGELOG.md", "package.json"],
"assets": ["README.md", "CHANGELOG.md", "package.json", "docker/*.dockerfile"],
"message": "Chore: (release) add version ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
Expand Down
4 changes: 1 addition & 3 deletions bin/update-docker.sh → bin/release/prepare.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash

VERSION=$1

docker build -t pustovitdmytro/ianus-base:$VERSION -f docker/Base.dockerfile .
docker build -t pustovitdmytro/ianus-worker:$VERSION -f docker/Worker.dockerfile .
docker build -t pustovitdmytro/ianus-admin:$VERSION -f docker/Admin.dockerfile .
docker push pustovitdmytro/ianus-base:$VERSION
docker push pustovitdmytro/ianus-admin:$VERSION
docker push pustovitdmytro/ianus-worker:$VERSION
13 changes: 13 additions & 0 deletions bin/release/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

VERSION=$1
MINOR=${VERSION%.*}
MAJOR=${MINOR%.*}

for image in "pustovitdmytro/ianus-base" "pustovitdmytro/ianus-admin" "pustovitdmytro/ianus-worker"; do
for tag in $VERSION $MINOR $MAJOR "latest"; do
docker tag $image:$VERSION $image:$tag
docker push $image:$tag
echo "Pushed $image:$tag"
done;
done
3 changes: 3 additions & 0 deletions bin/release/verifyConditions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker login -u $DOCKER_REGISTRY_USER -p $DOCKER_REGISTRY_PASSWORD
File renamed without changes.
147 changes: 147 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"test:security": "npm audit --production && npm run test:lock",
"test:lint": "eslint src bin tests --no-error-on-unmatched-pattern",
"test:mocha": "mocha --config .mocharc.json 'tests/**/*test.js'",
"test:package": "npt test -c .package-tester.json",
"test:package": "npm run build:src && npt test -c .package-tester.json",
"test:coverage": "BUILD=0 MODE=test nyc mocha --config .mocharc.json 'tests/**/*test.js'",
"test:debt": "jscpd src --config .jscpd.json",
"test:lock": "lockfile-lint --path package-lock.json --validate-https --allowed-hosts npm",
"coverage-check": "MODE=test nyc check-coverage",
"test": "npm run test:lint && npm run test:security && BUILD=1 npm run test:mocha",
"sort-deps": "npm remove --save example; npm remove --save-dev example",
"semantic-release": "npx semantic-release",
"start:local": "docker-compose -f local.docker-compose.yml up"
"start:local": "docker-compose -f docker/local.docker-compose.yml up"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -45,7 +45,9 @@
"@babel/runtime": "^7.16.7",
"@commitlint/cli": "^16.1.0",
"@commitlint/lint": "^16.0.0",
"@google/semantic-release-replace-plugin": "^1.1.0",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"babel-plugin-module-resolver": "^4.1.0",
"chai": "^4.3.4",
Expand Down
1 change: 0 additions & 1 deletion tests/workers/binanceP2PRequest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { load } from '../utils';
import { mockAPI as mockBinance, unMockAPI as unmockBinance } from '../mock/Binance';
import { mockAPI as mockTg, unMockAPI as unmockTg } from '../mock/Telegram';
import { Job } from '../mock/Job';
// import seedRepositories from '../mock/seeds/repositories.json';

const factory = new Test();
const handler = load('workers/binanceP2PRequest').default;
Expand Down

0 comments on commit 0256712

Please sign in to comment.