Skip to content

Commit

Permalink
feat: Change workflow trigger to manually build SDK (#90)
Browse files Browse the repository at this point in the history
* feat: Change workflow trigger to manually build SDK

* feat: fix Type in trigger name for manually building workflow

* feat: Implement uninstall step in the workflow (#91)

* feat: Implement uninstall step in the workflow

* feat: Improve SDK readme docs (#92)
  • Loading branch information
fmarek-kindred authored Oct 26, 2023
1 parent edda736 commit 800228e
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 43 deletions.
50 changes: 44 additions & 6 deletions .github/workflows/npm_publish_light.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
# could build it locally.
# Performs a basic build test by installing "cohort_sdk_client" into
# "cohort_banking_initiator_js", "cohort_banking_replicator_js" apps and then builds apps.
# If tests building of initiator and replicator fails then SDK version is removed from NPM.
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

name: Build and Publish Cohort SDK NPMs
on:
#workflow_call:
push:
workflow_dispatch:
env:
SDK_JS_PACKAGE_NAME: "@kindredgroup/cohort_sdk_js"
SDK_JS_PACKAGE_NAME_SHORT: "cohort_sdk_js"
SDK_CLIENT_PACKAGE_NAME: "@kindredgroup/cohort_sdk_client"
SDK_CLIENT_PACKAGE_NAME_SHORT: "cohort_sdk_client"
REGISTRY: "https://npm.pkg.github.com"
API_URL: "https://github.com/gitapi/orgs/kindredgroup/packages/npm"
API_VERSION: "2022-11-28"
jobs:
npm:
strategy:
Expand Down Expand Up @@ -53,7 +57,7 @@ jobs:
pwd
ls -l
npm ci --foreground-scripts
../../scripts/github-actions-ci/set-npm-dev-version.sh ${{ env.SDK_JS_PACKAGE_NAME }} "SDK_JS_PACKAGE_VERSION"
../../scripts/cohort/github-actions-ci/set-npm-dev-version.sh ${{ env.SDK_JS_PACKAGE_NAME }} "SDK_JS_PACKAGE_VERSION"
echo ""
- name: Build and Publish ${{ matrix.settings.dirSdkJs }}
Expand Down Expand Up @@ -83,7 +87,7 @@ jobs:
rm package-lock.json || true
echo "D: npm install $SDK_JS_PACKAGE_NAME@$SDK_JS_PACKAGE_VERSION --foreground-scripts"
npm install "$SDK_JS_PACKAGE_NAME@$SDK_JS_PACKAGE_VERSION" --foreground-scripts
../scripts/github-actions-ci/set-npm-dev-version.sh ${{ env.SDK_CLIENT_PACKAGE_NAME }} "SDK_CLIENT_PACKAGE_VERSION"
../scripts/cohort/github-actions-ci/set-npm-dev-version.sh ${{ env.SDK_CLIENT_PACKAGE_NAME }} "SDK_CLIENT_PACKAGE_VERSION"
echo ""
- name: Build and Publish ${{ matrix.settings.dirSdkJsClient }} NPM
Expand Down Expand Up @@ -116,6 +120,23 @@ jobs:
npm install "$SDK_CLIENT_PACKAGE_NAME@$SDK_CLIENT_PACKAGE_VERSION" --foreground-scripts
npm run build --foreground-scripts
- name: Unublish SDK NPMs on failure
if: ${{ failure() }}
shell: bash
env:
SDK_JS_PACKAGE_VERSION: ${{ steps.sdk-js-version.outputs.SDK_JS_PACKAGE_VERSION }}
SDK_CLIENT_PACKAGE_VERSION: ${{ steps.sdk-client-version.outputs.SDK_CLIENT_PACKAGE_VERSION }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |-
currentDir=$(pwd)
cd ${{ matrix.settings.dirSdkJsClient }}
../scripts/cohort/github-actions-ci/unpublish-sdk-version.sh "$SDK_CLIENT_PACKAGE_NAME_SHORT" "$SDK_CLIENT_PACKAGE_VERSION"
echo ""
cd $currentDir
cd ${{ matrix.settings.dirSdkJs }}
../../scripts/cohort/github-actions-ci/unpublish-sdk-version.sh "$SDK_JS_PACKAGE_NAME_SHORT" "$SDK_JS_PACKAGE_VERSION"
- name: Build ${{ matrix.settings.dirCohortReplicator }}
env:
SDK_CLIENT_PACKAGE_VERSION: ${{ steps.sdk-client-version.outputs.SDK_CLIENT_PACKAGE_VERSION }}
Expand All @@ -129,4 +150,21 @@ jobs:
rm package-lock.json || true
echo "D: npm install $SDK_CLIENT_PACKAGE_NAME@$SDK_CLIENT_PACKAGE_VERSION --foreground-scripts"
npm install "$SDK_CLIENT_PACKAGE_NAME@$SDK_CLIENT_PACKAGE_VERSION" --foreground-scripts
npm run build --foreground-scripts
npm run build --foreground-scripts
- name: Unublish SDK NPMs on failure
if: ${{ failure() }}
shell: bash
env:
SDK_JS_PACKAGE_VERSION: ${{ steps.sdk-js-version.outputs.SDK_JS_PACKAGE_VERSION }}
SDK_CLIENT_PACKAGE_VERSION: ${{ steps.sdk-client-version.outputs.SDK_CLIENT_PACKAGE_VERSION }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |-
currentDir=$(pwd)
cd ${{ matrix.settings.dirSdkJsClient }}
../scripts/cohort/github-actions-ci/unpublish-sdk-version.sh "$SDK_CLIENT_PACKAGE_NAME_SHORT" "$SDK_CLIENT_PACKAGE_VERSION"
echo ""
cd $currentDir
cd ${{ matrix.settings.dirSdkJs }}
../../scripts/cohort/github-actions-ci/unpublish-sdk-version.sh "$SDK_JS_PACKAGE_NAME_SHORT" "$SDK_JS_PACKAGE_VERSION"
20 changes: 12 additions & 8 deletions cohort_banking_initiator_js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Cohort Initiator JS is TypeScript app. When launched it connects to Postgres dat
### Setup your machine

#### Install development ecosystem for Rust

<em>This step is curently required but in the future we might be able to optimise build process and remove it. In the readme of "packages/cohort_sdk_js", please read more why it is compiled locally on user machine.</em>

Refer to https://www.rust-lang.org/tools/install

Check:
Expand All @@ -39,6 +42,8 @@ info: This is the version for the rustup toolchain manager, not the rustc compil
info: The currently active `rustc` version is `rustc 1.72.0 (5680fa18f 2023-08-23)`
```

<em>For reader convenience this step is also described in the `../cohort_sdk_client` readme. When making changes to install procedure, please update another location as well.</em>

#### Start Postgres server

```
Expand All @@ -64,7 +69,7 @@ Please refer to Talos Certifier readme.

#### Generate data file

Generate data JSON file containing some number of random banking transactions.
Generate data JSON file containing some number of bank accounts.

```
cd $TALOS/
Expand All @@ -91,25 +96,24 @@ make withenv RECIPE=cohort_banking.migrate_db
make withenv RECIPE=cohort_banking.preload_db args="--accounts $accounts_file"
```


### Building Cohort Replicator and Initiator apps

These sample apps depend on `@kindredgroup/cohort_sdk_client` package. It is hosted at [GitHub Packages](https://npm.pkg.github.com) repository.

#### Authenticate to repository GitHub Packages
TODO: (explain where to obtain token)
```
touch .npmrc-talos
echo "@kindredgroup:registry=https://npm.pkg.github.com" >> .npmrc-talos
NPM_CONFIG_USERCONFIG=.npmrc-talos
npm login --registry https://npm.pkg.github.com
touch $(pwd)/.npmrc-talos
echo "@kindredgroup:registry=https://npm.pkg.github.com" >> $(pwd)/.npmrc-talos
# Using this method the ".npmrc-talos" file will be updated with your token. Do not commit the file!
NPM_CONFIG_USERCONFIG=$(pwd)/.npmrc-talos npm login --registry https://npm.pkg.github.com
# password is your GitHub token
# Obtain token at GitHub website Profile -> Settings -> Developer settings -> Personal access tokens -> Tokens (classic)
```

#### For local development

This section describes how to install cohort client SDK for local development of cohort.
This section describes how to install cohort client SDK for local development of cohort (or for running examples locally).

In the Talos project at GitHub, under ["Packages"](https://github.com/orgs/kindredgroup/packages?repo_name=talos) find `cohort_sdk_client` and the version number you need to install locally.

Expand Down
Loading

0 comments on commit 800228e

Please sign in to comment.