Skip to content

Commit

Permalink
ci: add steps for running unit test on windows platform (#225)
Browse files Browse the repository at this point in the history
Signed-off-by: Jeffrey Tang <[email protected]>
Signed-off-by: Jeffrey Tang <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
JeffreyDallas and github-actions[bot] authored Apr 11, 2024
1 parent d1017d8 commit 07f5fe4
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 34 deletions.
40 changes: 26 additions & 14 deletions .github/workflows/zxc-compile-code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ permissions:
jobs:
compile:
name: ${{ inputs.custom-job-label || 'Compiles' }}
runs-on: [self-hosted, Linux, medium, ephemeral]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- windows-2022
- [self-hosted, Linux, medium, ephemeral]
steps:
- name: Checkout Code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand All @@ -78,7 +83,7 @@ jobs:

- name: Setup Kind
uses: helm/kind-action@99576bfa6ddf9a8e612d83b513da5a75875caced # v1.9.0
if: ${{ inputs.enable-e2e-tests && !cancelled() && !failure() }}
if: ${{ runner.os == 'linux' && inputs.enable-e2e-tests && !cancelled() && !failure() }}
with:
install_only: true
node_image: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
Expand All @@ -92,43 +97,50 @@ jobs:
run: npm ci

- name: Check Code Style
if: ${{ inputs.enable-code-style-check && !cancelled() && !failure() }}
if: ${{ runner.os == 'linux' && inputs.enable-code-style-check && !cancelled() && !failure() }}
run: npm run check

- name: Run Unit Tests
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
run: npm test

- name: Publish Unit Test Report
- name: Publish Windows Unit Test Report
uses: EnricoMi/publish-unit-test-result-action/windows/[email protected]
if: ${{ runner.os == 'Windows' && inputs.enable-unit-tests && steps.npm-deps.conclusion == 'success' && !cancelled() }}
with:
check_name: 'Unit Test Results - ${{ runner.os }}'
files: "junit.xml"

- name: Publish Linux Unit Test Report
uses: EnricoMi/publish-unit-test-result-action@f355d34d53ad4e7f506f699478db2dd71da9de5f # v2.15.1
if: ${{ inputs.enable-unit-tests && steps.npm-deps.conclusion == 'success' && !cancelled() }}
if: ${{ runner.os == 'linux' && inputs.enable-unit-tests && steps.npm-deps.conclusion == 'success' && !cancelled() }}
with:
check_name: 'Unit Test Results'
check_name: 'Unit Test Results - ${{ runner.os }}'
files: "junit.xml"

- name: Publish Unit Test Coverage Report
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: ${{ inputs.enable-unit-tests && !cancelled() }}
if: ${{ runner.os == 'linux' && inputs.enable-unit-tests && !cancelled() }}
with:
name: Unit Test Coverage Report
path: 'coverage/unit'

- name: Pull Kind Docker Image
if: ${{ inputs.enable-e2e-tests && !cancelled() && !failure() }}
if: ${{ runner.os == 'linux' && inputs.enable-e2e-tests && !cancelled() && !failure() }}
run: docker image pull kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72

- name: Setup E2E Tests
if: ${{ inputs.enable-e2e-tests && !cancelled() && !failure() }}
if: ${{ runner.os == 'linux' && inputs.enable-e2e-tests && !cancelled() && !failure() }}
run: |
npm link
./test/e2e/setup-e2e.sh
- name: Run E2E Tests
if: ${{ inputs.enable-e2e-tests && !cancelled() && !failure() }}
if: ${{ runner.os == 'linux' && inputs.enable-e2e-tests && !cancelled() && !failure() }}
run: npm run test-e2e

- name: Upload E2E Logs to GitHub
if: ${{ inputs.enable-e2e-tests && !cancelled() }}
if: ${{ runner.os == 'linux' && inputs.enable-e2e-tests && !cancelled() }}
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: solo.log
Expand All @@ -138,21 +150,21 @@ jobs:

- name: Publish E2E Test Report
uses: EnricoMi/publish-unit-test-result-action@f355d34d53ad4e7f506f699478db2dd71da9de5f # v2.15.1
if: ${{ inputs.enable-e2e-tests && steps.npm-deps.conclusion == 'success' && !cancelled() }}
if: ${{ runner.os == 'linux' && inputs.enable-e2e-tests && steps.npm-deps.conclusion == 'success' && !cancelled() }}
with:
check_name: 'E2E Test Results'
files: "junit-e2e.xml"

- name: Publish E2E Coverage Report
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: ${{ inputs.enable-e2e-tests && !cancelled() }}
if: ${{ runner.os == 'linux' && inputs.enable-e2e-tests && !cancelled() }}
with:
name: E2E Coverage Report
path: 'coverage/e2e'

- name: Publish Test Reports
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: ${{ inputs.enable-unit-tests && steps.npm-deps.conclusion == 'success' && !cancelled() }}
if: ${{ runner.os == 'linux' && inputs.enable-unit-tests && steps.npm-deps.conclusion == 'success' && !cancelled() }}
with:
name: Test Reports
path: "junit*.xml"
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ You can now use your cluster with:
kubectl cluster-info --context kind-solo
Thanks for using kind! 😊
Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community 🙂
```

You may now view pods in your cluster using `k9s -A` as below:
Expand Down Expand Up @@ -178,9 +178,9 @@ Kubernetes Namespace : solo
✔ Clean up temp files
✔ Generate gossip keys
✔ Backup old files
✔ TLS key for node: node2
✔ TLS key for node: node0
✔ TLS key for node: node1
✔ TLS key for node: node0
✔ TLS key for node: node2
✔ Generate gRPC TLS keys
✔ Finalize
```
Expand Down Expand Up @@ -269,8 +269,8 @@ Kubernetes Namespace : solo
✔ Prepare config.txt for the network
✔ Prepare staging directory
✔ Node: node0
✔ Node: node2
✔ Node: node1
✔ Node: node2
✔ Fetch platform software into network nodes
✔ Copy Gossip keys
✔ Copy Gossip keys
Expand All @@ -282,11 +282,11 @@ Kubernetes Namespace : solo
✔ Copy configuration files
✔ Copy configuration files
✔ Set file permissions
✔ Node: node1
✔ Node: node2
✔ Set file permissions
✔ Node: node0
✔ Set file permissions
✔ Node: node2
✔ Node: node1
✔ Setup network nodes
✔ Finalize
```
Expand All @@ -308,13 +308,13 @@ Kubernetes Cluster : kind-solo
Kubernetes Namespace : solo
**********************************************************************************
✔ Initialize
✔ Check network pod: node1
✔ Check network pod: node0
✔ Check network pod: node2
✔ Check network pod: node1
✔ Identify network pods
✔ Start node: node1
✔ Start node: node0
✔ Start node: node2
✔ Start node: node0
✔ Starting nodes
✔ Check node: node0
✔ Check node: node1
Expand Down Expand Up @@ -375,7 +375,7 @@ Kubernetes Namespace : solo
*** Deployed Relays ***
-------------------------------------------------------------------------------
- fullstack-deployment [fullstack-deployment-0.24.2]
- fullstack-deployment [fullstack-deployment-0.24.3]
- relay-node0-node1 [hedera-json-rpc-relay-0.26.0-SNAPSHOT]
- relay-node0-node1-node2 [hedera-json-rpc-relay-0.26.0-SNAPSHOT]
Expand Down Expand Up @@ -453,7 +453,7 @@ Kubernetes Namespace : solo
*** Deployed Relays ***
-------------------------------------------------------------------------------
- fullstack-deployment [fullstack-deployment-0.24.2]
- fullstack-deployment [fullstack-deployment-0.24.3]
- relay-node0-node1 [hedera-json-rpc-relay-0.26.0-SNAPSHOT]
Expand Down Expand Up @@ -516,9 +516,9 @@ Kubernetes Namespace : solo
✔ Gossip pem key for node: node2
✔ Generate gossip keys
✔ Backup old files
✔ TLS key for node: node0
✔ TLS key for node: node1
✔ TLS key for node: node2
✔ TLS key for node: node1
✔ TLS key for node: node0
✔ Generate gRPC TLS keys
✔ Finalize
```
Expand Down Expand Up @@ -579,6 +579,6 @@ Contributions are welcome. Please see the [contributing guide](https://github.co
This project is governed by the [Contributor Covenant Code of Conduct](https://github.com/hashgraph/.github/blob/main/CODE_OF_CONDUCT.md). By participating, you are
expected to uphold this code of conduct.

## License
## License

[Apache License 2.0](LICENSE)
22 changes: 21 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"access": "public"
},
"scripts": {
"test": "NODE_OPTIONS=--experimental-vm-modules JEST_SUITE_NAME='Unit Tests' jest --runInBand --detectOpenHandles --forceExit --coverage --coverageDirectory='coverage/unit' --testPathIgnorePatterns=\".*/e2e/.*\"",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules JEST_SUITE_NAME=\"Unit Tests\" jest --runInBand --detectOpenHandles --forceExit --coverage --coverageDirectory='coverage/unit' --testPathIgnorePatterns=\".*/e2e/.*\"",
"test-e2e": "NODE_OPTIONS=--experimental-vm-modules JEST_SUITE_NAME='Jest E2E Tests' JEST_JUNIT_OUTPUT_NAME='junit-e2e.xml' jest --runInBand --detectOpenHandles --forceExit --coverage --coverageDirectory='coverage/e2e' --testPathIgnorePatterns=\\\".*/unit/.*\\\"",
"solo": "NODE_OPTIONS=--experimental-vm-modules node --no-deprecation solo.mjs",
"check": "remark . --quiet --frail && eslint .",
Expand Down Expand Up @@ -68,6 +68,7 @@
"remark-lint-unordered-list-marker-style": "^3.1.2",
"remark-preset-lint-consistent": "^5.1.2",
"remark-preset-lint-recommended": "^6.1.3",
"cross-env": "^7.0.3",
"seedrandom": "^3.0.5"
},
"repository": {
Expand All @@ -76,7 +77,8 @@
},
"os": [
"darwin",
"linux"
"linux",
"win32"
],
"engines": {
"node": ">=18.18.2",
Expand Down
8 changes: 7 additions & 1 deletion src/core/dependency_managers/helm_dependency_manager.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { constants, Templates } from '../index.mjs'
import * as version from '../../../version.mjs'
import { ShellRunner } from '../shell_runner.mjs'
import * as semver from 'semver'
import { OS_WIN32, OS_WINDOWS } from '../constants.mjs'

// constants required by HelmDependencyManager
const HELM_RELEASE_BASE_URL = 'https://get.helm.sh'
Expand Down Expand Up @@ -55,7 +56,12 @@ export class HelmDependencyManager extends ShellRunner {
this.downloader = downloader
this.zippy = zippy
this.installationDir = installationDir
this.osPlatform = osPlatform
// Node.js uses 'win32' for windows in package.json os field, but helm uses 'windows'
if (osPlatform === OS_WIN32) {
this.osPlatform = OS_WINDOWS
} else {
this.osPlatform = osPlatform
}
this.osArch = ['x64', 'x86-64'].includes(osArch) ? 'amd64' : osArch
this.helmVersion = helmVersion
this.helmPath = Templates.installationPath(constants.HELM, this.osPlatform, this.installationDir)
Expand Down
9 changes: 7 additions & 2 deletions src/core/dependency_managers/keytool_dependency_manager.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { constants, Keytool, Templates } from '../index.mjs'
import * as version from '../../../version.mjs'
import { ShellRunner } from '../shell_runner.mjs'
import got from 'got'
import { OS_WIN32, OS_WINDOWS } from '../constants.mjs'

/**
* Installs or uninstalls JRE client at SOLO_HOME_DIR/bin/jre directory
Expand All @@ -49,8 +50,12 @@ export class KeytoolDependencyManager extends ShellRunner {
this.zippy = zippy
this.installationDir = installationDir
this.jreDir = path.join(this.installationDir, 'jre')
this.osPlatform = ['mac', 'darwin'].includes(osPlatform) ? constants.OS_MAC : osPlatform

// Node.js uses 'win32' for windows in package.json os field, but jdk too uses 'windows'
if (osPlatform === OS_WIN32) {
this.osPlatform = OS_WINDOWS
} else {
this.osPlatform = ['mac', 'darwin'].includes(osPlatform) ? constants.OS_MAC : osPlatform
}
switch (osArch) {
case 'x64':
case 'x86-64':
Expand Down
2 changes: 1 addition & 1 deletion test/unit/commands/base.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('BaseCommand', () => {
await expect(baseCmd.run('INVALID_PROGRAM')).rejects.toThrowError()
})
it('should succeed during valid program check', async () => {
await expect(baseCmd.run('date')).resolves.not.toBeNull()
await expect(baseCmd.run('echo')).resolves.not.toBeNull()
})
})
})

0 comments on commit 07f5fe4

Please sign in to comment.