Skip to content

Commit

Permalink
ci: Using new SDK update mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
theblockstalk committed Sep 6, 2023
1 parent 75f313a commit d6a5fbe
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 41 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/check-sdk-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test - Check SDK version

on:
pull_request

jobs:
check-sdk-version:
runs-on: ubuntu-20.04

steps:
- name: 🏗 Setup repo
uses: actions/checkout@v3

- name: 📦 Check it is using the latest version of the SDK
uses: actions/setup-node@v3
with:
node-version: 18.12.1
- run: corepack enable
- run: yarn install --immutable
- run: yarn run updateSdkVersion $GITHUB_BASE_REF check
28 changes: 0 additions & 28 deletions .github/workflows/master-pr-tests.yaml

This file was deleted.

14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
yarn install
```

For the `development` branch

```bash
yarn add @tonomy/tonomy-id-sdk@development
```

## Running the app

```bash
Expand All @@ -29,6 +23,14 @@ yarn run start:dev
yarn run start:prod
```

## Update the Tonomy-ID-SDK version to the latest

```bash
yarn run updateSdkVersion development
# or
yarn run updateSdkVersion master
```

## Environment variables and configuration

`NODE_ENV` - Determines which config file in `./src/config` to use
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
"test:e2e": "jest --config ./test/jest-e2e.json",
"updateSdkVersion": "./update_sdk_version.sh"
},
"dependencies": {
"@nestjs/common": "^10.2.3",
Expand All @@ -27,7 +28,7 @@
"@nestjs/platform-socket.io": "^10.2.3",
"@nestjs/swagger": "^7.1.10",
"@nestjs/websockets": "^10.2.3",
"@tonomy/tonomy-id-sdk": "^0.15.0-development.2",
"@tonomy/tonomy-id-sdk": "0.15.0-development.3",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"hcaptcha": "^0.1.1",
Expand Down
42 changes: 42 additions & 0 deletions update_sdk_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

BRANCH=${1-default}
CHECK=${2-default}

echo "yarn run updateSdkVersion $@"

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}" == "development" ]; then
VERSION=$(npm view @tonomy/tonomy-id-sdk@development version)
else
# Print help
echo "Usage: yarn run updateSdkVersion master|development [check]"
echo ""
echo "Example: yarn run updateSdkVersion development"
echo "Example: yarn run updateSdkVersion master check"
echo ""
exit 1
fi

# Get the sha256sum of yarn.lock before updating the SDK
YARNLOCK_SHA256_OLD=$(sha256sum yarn.lock)

# Update the SDK
echo "Updating package @tonomy/tonomy-id-sdk@${VERSION}"
yarn up "@tonomy/tonomy-id-sdk@${VERSION}"

# Get the sha256sum of yarn.lock after updating the SDK
YARNLOCK_SHA256_NEW=$(sha256sum yarn.lock)

if [ "${CHECK}" == "check" ]; then
echo "Checking if yarn.lock has changed"
if [ "${YARNLOCK_SHA256_NEW}" != "${YARNLOCK_SHA256_OLD}" ]; then
echo "yarn.lock has changed while updating @tonomy/tonomy-id-sdk@${VERSION}"
echo "Please run \"yarn run installSdkVersion\" to fix"
exit 1
fi
fi
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.15.0-development.2":
version: 0.15.0-development.2
resolution: "@tonomy/tonomy-id-sdk@npm:0.15.0-development.2"
"@tonomy/tonomy-id-sdk@npm:0.15.0-development.3":
version: 0.15.0-development.3
resolution: "@tonomy/tonomy-id-sdk@npm:0.15.0-development.3"
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: 33d6031035c480da14ad603a7bb4e94ffcc6138677ae9fcf301f962a96328a449ee636c7fdec7825bda79853b93fc9781586da62eae341763c6686c3b58afcdc
checksum: 6ddbf3175f95f994fdba13d9d99d2ae9454b54a8bc264bb754c59fd3aa40460a6856fe4270710bfa4a6e735505753cb4a205c25fe0ff8dbd2b863387165158b4
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.15.0-development.2
"@tonomy/tonomy-id-sdk": 0.15.0-development.3
"@types/express": ^4.17.13
"@types/jest": 29.2.4
"@types/node": 18.11.18
Expand Down

0 comments on commit d6a5fbe

Please sign in to comment.