Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release: CICD for testnet and branches, using Tonomy contract #105

Merged
merged 33 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3684629
change demo to testnet
sadiabbasi Dec 28, 2023
f7b8e75
change demo to testnet
sadiabbasi Dec 28, 2023
c0033ea
update to pangea
sadiabbasi Dec 28, 2023
4efdebb
change pangea domain
sadiabbasi Jan 9, 2024
b343901
update sdk
sadiabbasi Jan 9, 2024
9262b63
update sdk
sadiabbasi Jan 9, 2024
d70945a
Merge pull request #92 from Tonomy-Foundation/feature/160-demo-to-tes…
sadiabbasi Jan 9, 2024
0df2afe
feat: Change IDContract to EosioContract
theblockstalk Jan 11, 2024
2f4f833
feat: Changed to tonomy contract
theblockstalk Jan 12, 2024
53a83de
feat: Update SDK version
theblockstalk Jan 15, 2024
203b59f
Merge branch 'master' of github.com:Tonomy-Foundation/Tonomy-Communic…
theblockstalk Jan 15, 2024
cd5b376
Merge pull request #94 from Tonomy-Foundation/feature/77-contract-TODOs
theblockstalk Jan 15, 2024
76f49e4
ci: CD
theblockstalk Jan 15, 2024
41abb63
Merge pull request #95 from Tonomy-Foundation/feature/159-cicd
theblockstalk Jan 16, 2024
182b6a1
Merge pull request #93 from Tonomy-Foundation/development
sadiabbasi Jan 22, 2024
3f21ded
feat: Using Tonomy Ops key for environment variable
theblockstalk Jan 23, 2024
7371b73
ci: Fixed lint error
theblockstalk Jan 24, 2024
4967c85
build: Update SDK version
theblockstalk Jan 25, 2024
1afb3d2
Merge pull request #96 from Tonomy-Foundation/feature/84-bootstrap-tests
theblockstalk Jan 25, 2024
de60382
build: update sdk script fix
theblockstalk Jan 30, 2024
25f5ebd
build: SDK updated to testnet
theblockstalk Jan 30, 2024
7a14d2f
Merge branch 'testnet' of github.com:Tonomy-Foundation/Tonomy-Communi…
theblockstalk Jan 30, 2024
abe0284
Merge pull request #98 from Tonomy-Foundation/testnet-release
theblockstalk Jan 30, 2024
3f176be
Merge pull request #97 from Tonomy-Foundation/development
theblockstalk Jan 30, 2024
35c3295
docs: Updated env variables
theblockstalk Apr 2, 2024
bfce457
Merge branch 'testnet' of github.com:Tonomy-Foundation/Tonomy-Communi…
theblockstalk Apr 2, 2024
4de7221
build: Updated SDK to rc release
theblockstalk Apr 2, 2024
9456c59
Merge pull request #100 from Tonomy-Foundation/release/547-testnet-re…
theblockstalk Apr 2, 2024
009565e
Merge pull request #101 from Tonomy-Foundation/development
theblockstalk Apr 2, 2024
8d6d58d
feat: changed production API endpoint
theblockstalk Apr 22, 2024
5fd4372
Merge branch 'testnet' of github.com:Tonomy-Foundation/Tonomy-Communi…
theblockstalk Apr 22, 2024
5102747
build: updated SDK version
theblockstalk Apr 22, 2024
dc6885c
Merge pull request #104 from Tonomy-Foundation/development
theblockstalk Apr 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/check-sdk-version.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Test - Check SDK version

on: pull_request
on:
pull_request:
branches:
- master
- testnet
- development

jobs:
check-sdk-version:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/deploy-testnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy - Testnet

on:
pull_request:
types:
- closed
branches:
- testnet

jobs:
build:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
target: tonomy_communication_base
push: true
tags: tonomy/communication:rc
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Test - Pull Requests (not to master)
name: Test - Pull Requests

on:
pull_request:
branches-ignore:
- master
branches:
- development

jobs:
tests:
Expand Down
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ yarn run updateSdkVersion master
## Environment variables and configuration

`NODE_ENV` - Determines which config file in `./src/config` to use
`CREATE_ACCOUNT_PRIVATE_KEY` - The private key used to sign the transaction to create a new account
`TONOMY_OPS_PRIVATE_KEY` - The private key used to sign the transaction to create a new account
`HCAPTCHA_SECRET` - The hCaptcha account secret key

## Test
Expand Down Expand Up @@ -68,9 +68,3 @@ Build command: `yarn -v && yarn install && yarn run build`
- NOTE: we need to run `yarn install` again so that we install with `[email protected]` which we force via`.yarnrc.yml` and `.yarn/releases/yarn-3.1.1.cjs`. See <https://github.com/Tonomy-Foundation/Tonomy-Communication/issues/85> for more details.

Run command: `yarn run start:prod`

Environment variables

- NODE_ENV
- CREATE_ACCOUNT_PRIVATE_KEY
- HCAPTCHA_SECRET
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@nestjs/platform-socket.io": "^10.2.3",
"@nestjs/swagger": "^7.1.10",
"@nestjs/websockets": "^10.2.3",
"@tonomy/tonomy-id-sdk": "0.18.0",
"@tonomy/tonomy-id-sdk": "0.19.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"hcaptcha": "^0.1.1",
Expand Down
6 changes: 3 additions & 3 deletions src/accounts/accounts.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { Name, PrivateKey } from '@wharfkit/antelope';
import settings from '../settings';
import { PushTransactionResponse } from '@wharfkit/antelope/src/api/v1/types';
import {
IDContract,
TonomyContract,
EosioUtil,
AntelopePushTransactionError,
} from '@tonomy/tonomy-id-sdk';
import { verify } from 'hcaptcha';

const idContract = IDContract.Instance;
const tonomyContract = TonomyContract.Instance;

@Injectable()
export class AccountsService {
Expand Down Expand Up @@ -69,7 +69,7 @@ export class AccountsService {
let res: PushTransactionResponse;

try {
res = await idContract.newperson(
res = await tonomyContract.newperson(
createAccountRequest.usernameHash,
createAccountRequest.publicKey,
createAccountRequest.salt,
Expand Down
4 changes: 0 additions & 4 deletions src/config/config.demo.json

This file was deleted.

4 changes: 4 additions & 0 deletions src/config/config.production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"blockchainUrl": "https://blockchain-api.pangea.web4.world",
"loggerLevel": "info"
}
4 changes: 4 additions & 0 deletions src/config/config.testnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"blockchainUrl": "https://blockchain-api-testnet.pangea.web4.world",
"loggerLevel": "info"
}
26 changes: 14 additions & 12 deletions src/settings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as configDefault from './config/config.json';
import * as configStaging from './config/config.staging.json';
import * as configDemo from './config/config.demo.json';
import { EosioUtil } from '@tonomy/tonomy-id-sdk';
import * as configTestnet from './config/config.testnet.json';
import * as configProduction from './config/config.production.json';

const env = process.env.NODE_ENV || 'development';

Expand Down Expand Up @@ -57,11 +57,13 @@ switch (env) {
case 'staging':
config = configStaging as FixLoggerLevelEnumType<typeof configStaging>;
break;
case 'demo':
config = configDemo as FixLoggerLevelEnumType<typeof configDemo>;
case 'testnet':
config = configTestnet as FixLoggerLevelEnumType<typeof configTestnet>;
break;
case 'production':
throw new Error('Production config not implemented yet');
config = configProduction as FixLoggerLevelEnumType<
typeof configProduction
>;
default:
throw new Error('Unknown environment: ' + env);
}
Expand All @@ -77,19 +79,19 @@ if (process.env.BLOCKCHAIN_URL) {
if (env !== 'test') console.log('settings', settings);

settings.secrets = {
createAccountPrivateKey: EosioUtil.defaultAntelopePrivateKey.toString(),
createAccountPrivateKey:
'PVT_K1_24kG9VcMk3VkkgY4hh42X262AWV18YcPjBTd2Hox4YWoP8vRTU',
hCaptchaSecret: '0x0000000000000000000000000000000000000000',
};

if (process.env.CREATE_ACCOUNT_PRIVATE_KEY) {
console.log('Using CREATE_ACCOUNT_PRIVATE_KEY from env');
settings.secrets.createAccountPrivateKey =
process.env.CREATE_ACCOUNT_PRIVATE_KEY;
}

if (process.env.HCAPTCHA_SECRET) {
console.log('Using HCAPTCHA_SECRET from env');
settings.secrets.hCaptchaSecret = process.env.HCAPTCHA_SECRET;
}

if (process.env.TONOMY_OPS_PRIVATE_KEY) {
console.log('Using TONOMY_OPS_PRIVATE_KEY from env');
settings.secrets.createAccountPrivateKey = process.env.TONOMY_OPS_PRIVATE_KEY;
}

export default settings;
2 changes: 2 additions & 0 deletions update_sdk_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ set +e
# Get the latest version of the SDK for the correct npmjs tag based on branch
if [ "${BRANCH}" == "master" ]; then
VERSION=$(npm view @tonomy/tonomy-id-sdk version)
elif [ "${BRANCH}" == "testnet" ]; then
VERSION=$(npm view @tonomy/tonomy-id-sdk@testnet version)
elif [ "${BRANCH}" == "development" ]; then
VERSION=$(npm view @tonomy/tonomy-id-sdk@development version)
else
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1576,9 +1576,9 @@ __metadata:
languageName: node
linkType: hard

"@tonomy/tonomy-id-sdk@npm:0.18.0":
version: 0.18.0
resolution: "@tonomy/tonomy-id-sdk@npm:0.18.0"
"@tonomy/tonomy-id-sdk@npm:0.19.0":
version: 0.19.0
resolution: "@tonomy/tonomy-id-sdk@npm:0.19.0"
dependencies:
"@consento/sync-randombytes": ^1.0.5
"@tonomy/antelope-did": ^0.1.5
Expand All @@ -1593,7 +1593,7 @@ __metadata:
elliptic: ^6.5.4
socket.io-client: ^4.5.4
universal-base64url: ^1.1.0
checksum: 7d307eb4c38ba503608f4d15c83488572c52c03030b108a71460ffa0649b8f0bcd34b65b723873393cea177b618320e0c7ca2c0e115bf08dbc86581b1acf3d7e
checksum: 05bf0812a27d425f136ace2c27ec98f501a84d0004923047dd1c05d21fd5c1ae8068654ce157b4967f34453d5634af88b4d70fafc656659bc15be746a064ecef
languageName: node
linkType: hard

Expand Down Expand Up @@ -7713,7 +7713,7 @@ __metadata:
"@nestjs/swagger": ^7.1.10
"@nestjs/testing": ^10.2.3
"@nestjs/websockets": ^10.2.3
"@tonomy/tonomy-id-sdk": 0.18.0
"@tonomy/tonomy-id-sdk": 0.19.0
"@types/express": ^4.17.13
"@types/jest": 29.2.4
"@types/node": 18.11.18
Expand Down