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

feat(cli): implement tests and dependency checks for init command #438

Merged
merged 12 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions .github/workflows/flow-pull-request-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ jobs:
custom-job-label: Standard
enable-unit-tests: true

nodejs-tests:
name: NodeJS CLI Tests
uses: ./.github/workflows/zxc-compile-code.yaml
with:
custom-job-label: Standard
enable-unit-tests: false
enable-nodejs-tests: true

codecov:
name: CodeCov
uses: ./.github/workflows/zxc-code-analysis.yaml
Expand Down
25 changes: 20 additions & 5 deletions .github/workflows/zxc-compile-code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ on:
type: boolean
required: false
default: false
enable-nodejs-tests:
description: "NodeJS Testing Enabled"
type: boolean
required: false
default: false
enable-spotless-check:
description: "Spotless Check Enabled"
type: boolean
Expand Down Expand Up @@ -100,7 +105,7 @@ jobs:

- name: Setup Kind
uses: helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140 # v1.8.0
if: ${{ inputs.enable-unit-tests && !cancelled() }}
if: ${{ (inputs.enable-unit-tests || inputs.enable-nodejs-tests) && !cancelled() && !failure() }}
with:
config: dev/dev-cluster.yaml
version: v0.19.0
Expand All @@ -109,19 +114,19 @@ jobs:

- name: Setup Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
if: ${{ inputs.enable-unit-tests && !cancelled() }}
if: ${{ (inputs.enable-unit-tests || inputs.enable-nodejs-tests) && !cancelled() && !failure() }}
with:
version: "v3.12.3" # helm version

- name: Setup Kubernetes Operators
working-directory: dev
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
if: ${{ (inputs.enable-unit-tests || inputs.enable-nodejs-tests) && !cancelled() && !failure() }}
run: |
make deploy-prometheus-operator

# Technically, this step is not required for the unit tests to run, but it is useful for debugging setup issues.
- name: Kubernetes Cluster Info
if: ${{ inputs.enable-unit-tests && !cancelled() }}
if: ${{ (inputs.enable-unit-tests || inputs.enable-nodejs-tests) && !cancelled() && !failure() }}
run: |
kubectl config get-contexts
kubectl get crd
Expand All @@ -132,7 +137,7 @@ jobs:
- name: Authenticate to Google Cloud
id: google-auth
uses: google-github-actions/auth@35b0e87d162680511bf346c299f71c9c5c379033 # v1.1.1
if: ${{ inputs.enable-unit-tests && !cancelled() }}
if: ${{ (inputs.enable-unit-tests || inputs.enable-nodejs-tests) && !cancelled() && !failure() }}
with:
token_format: 'access_token'
workload_identity_provider: "projects/101730247931/locations/global/workloadIdentityPools/hedera-registry-pool/providers/hedera-registry-gh-actions"
Expand All @@ -144,6 +149,13 @@ jobs:
if: ${{ inputs.enable-unit-tests && !cancelled() }}
uses: google-github-actions/setup-gcloud@e30db14379863a8c79331b04a9969f4c1e225e0b # v1.1.1

- name: NodeJS CLI Tests
id: nodejs-test
working-directory: fullstack-network-manager
if: ${{ inputs.enable-nodejs-tests && !cancelled() && !failure() }}
run:
npm i && NODE_OPTIONS=--experimental-vm-modules npm test --coverage

# This step tests the Helm chart direct mode of operation which uses the ubi8-init-java17 image.
- name: Helm Chart Test (Direct Install)
working-directory: dev
Expand All @@ -159,13 +171,15 @@ jobs:
- name: Compile
id: gradle-build
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: assemble --scan

- name: Examples Compile
id: gradle-build-examples
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: assemble --scan
Expand All @@ -174,6 +188,7 @@ jobs:
- name: Gradle Plugin Compile
id: gradle-build-gradle-plugin
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: assemble --scan
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -514,3 +514,4 @@ dev/local-node/config.txt
dev/temp/.env
charts/deleteme.yaml
node_modules
fullstack-network-manager/coverage
11 changes: 9 additions & 2 deletions fullstack-network-manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

fullstack-network-manager is a CLI tool to manage and deploy a Hedera Network using Helm chart for local testing.

## Develop
- In order to support ES6 modules with `jest`, set an env variable `export NODE_OPTIONS=--experimental-vm-modules >> ~/.zshrc`
- If you are using Intellij and would like to use debugger tools, you will need to enable `--experimental-vm-modules` for `Jest`.
- `Run->Edit Configurations->Edit Configuration Templates->Jest` and then set `--experimental-vm-modules` in `Node Options`.
- Run `npx jest` or `npm test` to run the tests
- Run `npm link` so that the CLI can be run using `fsnetman` in the terminal

## Install
- Run `nmp -i hedera/fullstack-network-manager`
- In order to install directly from this repository, run `npm link`
- Run `nmp -i @hedera/fullstack-network-manager`
- In order to install directly from this repository, run `npm link` from this directory.
- Once installed, the CLI will available as the following aliases:
- `fsnetman`

Expand Down
3 changes: 2 additions & 1 deletion fullstack-network-manager/fsnetman.mjs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/usr/bin/env node
import * as fnm from './src/index.mjs'
import * as fnm from './src/index.mjs'
const cli = fnm.main(process.argv)
7 changes: 7 additions & 0 deletions fullstack-network-manager/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const config = {
verbose: true,
transform: {},
};

export default config

Loading