Skip to content

Commit

Permalink
feat: CI CD
Browse files Browse the repository at this point in the history
  • Loading branch information
BeroBurny committed Jul 15, 2022
1 parent b141728 commit 559ba72
Show file tree
Hide file tree
Showing 12 changed files with 178 additions and 37 deletions.
8 changes: 8 additions & 0 deletions .github/.dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "yarn"
allow:
# Allow both direct and indirect updates for all packages
- dependency-type: "production"
commit-message:
prefix: "chore: "
49 changes: 49 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release
on:
push:
branches:
- master
jobs:
maybe-release:
name: release
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:

# you should probably do this after your regular CI checks passes
- uses: google-github-actions/release-please-action@v3 # it will analyze commits and create PR with new version and updated CHANGELOG:md file. On merging it will create github release page with changelog
id: release
with:
command: manifest
token: ${{secrets.GITHUB_TOKEN}}
default-branch: master
release-type: node
monorepo-tags: true
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false}]'

- uses: actions/checkout@v3
# these if statements ensure that a publication only occurs when
# a new release is created:
if: ${{ steps.release.outputs.releases_created }}

- uses: actions/setup-node@v3
with:
cache: 'yarn'
node-version: 16
registry-url: 'https://registry.npmjs.org'
if: ${{ steps.release.outputs.releases_created }}

- run: yarn install --immutable
if: ${{ steps.release.outputs.releases_created }}

- run: yarn build
if: ${{ steps.release.outputs.releases_created }}

- env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
if: ${{ steps.release.outputs.releases_created }}
run: |
echo npmAuthToken: "$NODE_AUTH_TOKEN" >> ./.yarnrc.yml
- run: yarn workspaces foreach -v --exclude root --no-private npm publish --tolerate-republish --access public
if: ${{ steps.release.outputs.releases_created }}
23 changes: 20 additions & 3 deletions .github/workflows/ci-workflow.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: ci
# This workflow is triggered on pushes to the repository.
on: [push, pull_request]
on:
push:
branches:
- master
pull_request:
branches:
- '**'

jobs:
build:
Expand All @@ -12,11 +18,22 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
cache: yarn
node-version: '16.x'
- run: yarn install --immutable
- name: Build
run: yarn run build
- name: Run linter
run: yarn run lint
- name: Build
run: yarn run build
- uses: tj-actions/verify-changed-files@v9
id: verify-changed-files
with:
files: |
packages/snap/snap.manifest.json
- name: Check if snap manifest updated
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
echo "Snap manifest not updated: ${{ steps.verify-changed-files.outputs.changed_files }}"
exit 1
- name: Run tests
run: yarn run test
21 changes: 21 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Semantic PR"
on:
pull_request_target:
types:
- opened
- edited
- synchronize
jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
fix
feat
chore
validateSingleCommit: true #single commit can ovveride squash merge commit message
5 changes: 5 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"packages/snap": "0.3.0",
"packages/types": "0.3.0",
"packages/adapter": "0.3.1"
}
Empty file added packages/adapter/CHANGELOG.md
Empty file.
Empty file added packages/snap/CHANGELOG.md
Empty file.
8 changes: 5 additions & 3 deletions packages/snap/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "polkadot-snap",
"name": "@chainsafe/polkadot-snap",
"version": "0.3.0",
"private": true,
"description": "Metamask snap to interact with Polkadot dapps.",
"main": "build/index.js",
"scripts": {
Expand All @@ -15,7 +14,10 @@
"type-check:watch": "npm run type-check -- --watch",
"build": "yarn run build:tsc && yarn run build:snap",
"build:tsc": "tsc --pretty --project tsconfig.build.json",
"build:snap": "mm-snap build --transpilationMode localAndDeps --stripComments",
"build:snap": "yarn build:snap:bundle && yarn build:snap:postprocess && yarn build:snap:eval",
"build:snap:bundle": "mm-snap build -s build/index.js --verboseErrors --transpilationMode localAndDeps --stripComments --eval false",
"build:snap:postprocess": "mm-snap manifest --fix",
"build:snap:eval": "mm-snap eval -b dist/bundle.js --verboseErrors",
"snapEval": "mm-snap eval",
"watch": "concurrently --raw --kill-others \"yarn run watch:tsc\" \"yarn run watch:snap\" \"yarn run serve\"",
"watch:tsc": "yarn run build:tsc --watch",
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"location": {
"npm": {
"filePath": "./dist/bundle.js",
"packageName": "polkadot-snap",
"packageName": "@chainsafe/polkadot-snap",
"registry": "https://registry.npmjs.org/"
}
}
Expand Down
Empty file added packages/types/CHANGELOG.md
Empty file.
39 changes: 39 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"plugins": [],
"packages": {
"packages/adapter": {
"releaseType": "node",
"draft": false,
"prerelease": false,
"bumpMinorPreMajor": false,
"bumpPatchForMinorPreMajor": false,
"changelogPath": "CHANGELOG.md",
"versioning": "default"
},
"packages/types": {
"releaseType": "node",
"draft": false,
"prerelease": false,
"bumpMinorPreMajor": false,
"bumpPatchForMinorPreMajor": false,
"changelogPath": "CHANGELOG.md",
"versioning": "default"
},
"packages/snap": {
"releaseType": "node",
"draft": false,
"prerelease": false,
"bumpMinorPreMajor": false,
"bumpPatchForMinorPreMajor": false,
"changelogPath": "CHANGELOG.md",
"versioning": "default",
"extra-files": [
{
"type": "json",
"path": "snap.manifest.json",
"jsonpath": "$.version"
}
]
}
}
}
60 changes: 30 additions & 30 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,36 @@ __metadata:
languageName: unknown
linkType: soft

"@chainsafe/polkadot-snap@workspace:packages/snap":
version: 0.0.0-use.local
resolution: "@chainsafe/polkadot-snap@workspace:packages/snap"
dependencies:
"@chainsafe/metamask-polkadot-types": "workspace:^"
"@metamask/key-tree": ^4.0.0
"@metamask/snaps-cli": 0.15.0
"@polkadot/api": ^8.7.1
"@polkadot/types": ^8.7.1
"@polkadot/util": 9.4.1
"@types/chai": ^4.2.10
"@types/mocha": ^7.0.2
"@types/sinon": ^7.5.2
"@types/sinon-chai": ^3.2.3
"@typescript-eslint/eslint-plugin": ^5.27.1
"@typescript-eslint/parser": ^5.27.1
axios: 0.27.2
chai: ^4.2.0
concurrently: ^5.1.0
deepmerge: ^4.2.2
eslint: ^8.17.0
mocha: ^7.1.1
sinon: ^9.0.1
sinon-chai: ^3.5.0
strict-event-emitter-types: ^2.0.0
ts-node: ^8.6.2
typescript: 4.7.3
languageName: unknown
linkType: soft

"@chainsafe/strip-comments@npm:^1.0.7":
version: 1.0.7
resolution: "@chainsafe/strip-comments@npm:1.0.7"
Expand Down Expand Up @@ -14057,36 +14087,6 @@ __metadata:
languageName: node
linkType: hard

"polkadot-snap@workspace:packages/snap":
version: 0.0.0-use.local
resolution: "polkadot-snap@workspace:packages/snap"
dependencies:
"@chainsafe/metamask-polkadot-types": "workspace:^"
"@metamask/key-tree": ^4.0.0
"@metamask/snaps-cli": 0.15.0
"@polkadot/api": ^8.7.1
"@polkadot/types": ^8.7.1
"@polkadot/util": 9.4.1
"@types/chai": ^4.2.10
"@types/mocha": ^7.0.2
"@types/sinon": ^7.5.2
"@types/sinon-chai": ^3.2.3
"@typescript-eslint/eslint-plugin": ^5.27.1
"@typescript-eslint/parser": ^5.27.1
axios: 0.27.2
chai: ^4.2.0
concurrently: ^5.1.0
deepmerge: ^4.2.2
eslint: ^8.17.0
mocha: ^7.1.1
sinon: ^9.0.1
sinon-chai: ^3.5.0
strict-event-emitter-types: ^2.0.0
ts-node: ^8.6.2
typescript: 4.7.3
languageName: unknown
linkType: soft

"popper.js@npm:1.16.1-lts":
version: 1.16.1-lts
resolution: "popper.js@npm:1.16.1-lts"
Expand Down

0 comments on commit 559ba72

Please sign in to comment.