From 96b6cdc084dec539a7a6c3e9a2cb4637b1ca30a5 Mon Sep 17 00:00:00 2001 From: Nathan Klick Date: Tue, 20 Feb 2024 00:35:40 -0600 Subject: [PATCH] chore(ci): finalize CI workflows after final sync (#30) Signed-off-by: Nathan Klick --- .github/workflows/flow-build-application.yaml | 21 +++++++++-- .../workflows/flow-pull-request-checks.yaml | 4 +- .github/workflows/zxc-code-analysis.yaml | 17 +++++++-- .github/workflows/zxc-compile-code.yaml | 37 ++++++++++++++++--- resources/extract-jar.sh | 1 + src/core/k8.mjs | 8 ++++ src/core/platform_installer.mjs | 6 ++- test/e2e/core/platform_installer_e2e.test.mjs | 4 +- test/e2e/setup-e2e.sh | 6 ++- 9 files changed, 84 insertions(+), 20 deletions(-) diff --git a/.github/workflows/flow-build-application.yaml b/.github/workflows/flow-build-application.yaml index f0f26faf4..719c206f1 100644 --- a/.github/workflows/flow-build-application.yaml +++ b/.github/workflows/flow-build-application.yaml @@ -46,9 +46,6 @@ jobs: code: name: Code uses: ./.github/workflows/zxc-compile-code.yaml - with: - enable-unit-tests: ${{ github.event_name == 'push' || github.event.inputs.enable-unit-tests == 'true' }} - #enable-e2e-tests: ${{ github.event_name == 'push' || github.event.inputs.enable-e2e-tests == 'true' }} code-style: name: Code Style @@ -59,16 +56,32 @@ jobs: custom-job-label: Check enable-code-style-check: true + unit-tests: + name: Unit Tests + uses: ./.github/workflows/zxc-compile-code.yaml + with: + custom-job-label: Standard + enable-unit-tests: ${{ github.event_name == 'push' || github.event.inputs.enable-unit-tests == 'true' }} + + e2e-tests: + name: E2E Tests + uses: ./.github/workflows/zxc-compile-code.yaml + with: + custom-job-label: Standard + enable-e2e-tests: ${{ github.event_name == 'push' || github.event.inputs.enable-e2e-tests == 'true' }} + analyze: name: Analyze uses: ./.github/workflows/zxc-code-analysis.yaml needs: - - code + - unit-tests + - e2e-tests if: ${{ github.event_name == 'push' || github.event.inputs.enable-unit-tests == 'true' || github.event.inputs.enable-e2e-tests == 'true' }} with: custom-job-label: Source Code #enable-snyk-scan: ${{ github.event_name == 'push' || github.event.inputs.enable-snyk-scan == 'true' }} enable-codecov-analysis: ${{ github.event_name == 'push' || github.event.inputs.enable-unit-tests == 'true' || github.event.inputs.enable-e2e-tests == 'true' }} + enable-e2e-coverage-report: true secrets: snyk-token: ${{ secrets.SNYK_TOKEN }} codecov-token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/flow-pull-request-checks.yaml b/.github/workflows/flow-pull-request-checks.yaml index 5e979592d..bd7cf15f5 100644 --- a/.github/workflows/flow-pull-request-checks.yaml +++ b/.github/workflows/flow-pull-request-checks.yaml @@ -59,7 +59,6 @@ jobs: uses: ./.github/workflows/zxc-compile-code.yaml needs: - code-style - if: false with: custom-job-label: Standard enable-e2e-tests: true @@ -69,11 +68,12 @@ jobs: uses: ./.github/workflows/zxc-code-analysis.yaml needs: - unit-tests - #- e2e-tests + - e2e-tests if: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name && github.actor != 'dependabot[bot]' }} with: custom-job-label: Standard enable-codecov-analysis: true + enable-e2e-coverage-report: true secrets: codecov-token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/zxc-code-analysis.yaml b/.github/workflows/zxc-code-analysis.yaml index 179e4465a..c2a36b8e2 100644 --- a/.github/workflows/zxc-code-analysis.yaml +++ b/.github/workflows/zxc-code-analysis.yaml @@ -30,6 +30,11 @@ on: type: boolean required: false default: false + enable-e2e-coverage-report: + description: "E2E Coverage Report Enabled" + type: boolean + required: false + default: false enable-snyk-scan: description: "Snyk Scan Enabled" type: boolean @@ -80,11 +85,17 @@ jobs: with: node-version: ${{ inputs.node-version }} - - name: Download Coverage Reports + - name: Download Unit Test Coverage Report + uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 + if: ${{ inputs.enable-codecov-analysis && !cancelled() && !failure() }} + with: + name: Unit Test Coverage Report + + - name: Download Unit Test Coverage Report uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 - if: ${{ (inputs.enable-codecov-analysis || inputs.enable-sonar-analysis) && !cancelled() && !failure() }} + if: ${{ inputs.enable-codecov-analysis && inputs.enable-e2e-coverage-report && !cancelled() && !failure() }} with: - name: Coverage Reports + name: E2E Coverage Report - name: Publish To Codecov uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # v4.0.1 diff --git a/.github/workflows/zxc-compile-code.yaml b/.github/workflows/zxc-compile-code.yaml index c74a5b972..f9d313b78 100644 --- a/.github/workflows/zxc-compile-code.yaml +++ b/.github/workflows/zxc-compile-code.yaml @@ -70,12 +70,27 @@ jobs: - name: Checkout Code uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Checkout Helm Charts + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + if: ${{ inputs.enable-e2e-tests && !cancelled() && !failure() }} + with: + repository: hashgraph/full-stack-testing + sparse-checkout: charts + path: helm-charts + - name: Setup Node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: ${{ inputs.node-version }} cache: npm + - name: Setup Java + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 + if: ${{ inputs.enable-e2e-tests && !cancelled() && !failure() }} + with: + distribution: temurin + java-version: 21 + - name: Setup Kind uses: helm/kind-action@99576bfa6ddf9a8e612d83b513da5a75875caced # v1.9.0 if: ${{ inputs.enable-e2e-tests && !cancelled() && !failure() }} @@ -112,10 +127,21 @@ jobs: check_name: 'Unit Test Results' files: "junit.xml" + - name: Publish Unit Test Coverage Report + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + if: ${{ 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() }} run: docker image pull kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72 + - name: Stage Helm Charts + if: ${{ inputs.enable-e2e-tests && !cancelled() && !failure() }} + run: mv -vf helm-charts/charts/ ./ && rm -rf helm-charts + - name: Setup E2E Tests if: ${{ inputs.enable-e2e-tests && !cancelled() && !failure() }} run: | @@ -124,8 +150,7 @@ jobs: - name: Run E2E Tests if: ${{ inputs.enable-e2e-tests && !cancelled() && !failure() }} - run: | - npm run test-e2e + run: npm run test-e2e - name: Publish E2E Test Report uses: EnricoMi/publish-unit-test-result-action@8885e273a4343cd7b48eaa72428dea0c3067ea98 # v2.14.0 @@ -134,12 +159,12 @@ jobs: check_name: 'E2E Test Results' files: "junit-e2e.xml" - - name: Publish Coverage Report + - name: Publish E2E Coverage Report uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - if: ${{ (inputs.enable-unit-tests || inputs.enable-e2e-tests) && !cancelled() }} + if: ${{ inputs.enable-e2e-tests && !cancelled() }} with: - name: Coverage Reports - path: 'coverage' + name: E2E Coverage Report + path: 'coverage/e2e' - name: Publish Test Reports uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 diff --git a/resources/extract-jar.sh b/resources/extract-jar.sh index 1b473a064..9237bab8f 100644 --- a/resources/extract-jar.sh +++ b/resources/extract-jar.sh @@ -12,4 +12,5 @@ if [ -z "${2}" ]; then exit 1 fi +[[ -d "${2}" ]] || mkdir -p "${2}" cd "${2}" && jar xvf "${1}" diff --git a/src/core/k8.mjs b/src/core/k8.mjs index de2bdae15..385b94f9b 100644 --- a/src/core/k8.mjs +++ b/src/core/k8.mjs @@ -378,6 +378,14 @@ export class K8 { ) === 'true' } + async mkdir (podName, containerName, destPath) { + return this.execContainer( + podName, + containerName, + ['bash', '-c', 'mkdir -p "' + destPath + '"'] + ) + } + /** * Copy a file into a container * diff --git a/src/core/platform_installer.mjs b/src/core/platform_installer.mjs index 1d7575f1f..b9e9528b3 100644 --- a/src/core/platform_installer.mjs +++ b/src/core/platform_installer.mjs @@ -57,7 +57,7 @@ export class PlatformInstaller { for (const p of resetPaths) { await this.k8.execContainer(podName, containerName, `rm -rf ${p}`) - await this.k8.execContainer(podName, containerName, `mkdir ${p}`) + await this.k8.execContainer(podName, containerName, `mkdir -p ${p}`) } await this.setPathPermission(podName, constants.HEDERA_SERVICES_PATH) @@ -159,6 +159,10 @@ export class PlatformInstaller { throw new FullstackTestingError(`file does not exist: ${srcPath}`) } + if (!await this.k8.hasDir(podName, container, destDir)) { + await this.k8.mkdir(podName, container, destDir) + } + this.logger.debug(`Copying file into ${podName}: ${srcPath} -> ${destDir}`) await this.k8.copyTo(podName, container, srcPath, destDir) diff --git a/test/e2e/core/platform_installer_e2e.test.mjs b/test/e2e/core/platform_installer_e2e.test.mjs index 6794c5330..9d38eaa41 100644 --- a/test/e2e/core/platform_installer_e2e.test.mjs +++ b/test/e2e/core/platform_installer_e2e.test.mjs @@ -122,10 +122,10 @@ describe('PackageInstallerE2E', () => { const tmpDir = getTmpDir() const keysDir = path.join(tmpDir, 'keys') const shellRunner = new ShellRunner(testLogger) - await shellRunner.run(`test/scripts/gen-legacy-keys.sh node0,node1 ${keysDir}`) + await shellRunner.run(`test/scripts/gen-legacy-keys.sh node0,node1,node2 ${keysDir}`) await installer.resetHapiDirectories(podName) - const fileList = await installer.copyGossipKeys(podName, tmpDir, ['node0', 'node1'], constants.KEY_FORMAT_PFX) + const fileList = await installer.copyGossipKeys(podName, tmpDir, ['node0', 'node1', 'node2'], constants.KEY_FORMAT_PFX) const destDir = `${constants.HEDERA_HAPI_PATH}/data/keys` expect(fileList.length).toBe(2) diff --git a/test/e2e/setup-e2e.sh b/test/e2e/setup-e2e.sh index 3cb9ec662..fb8ec0620 100755 --- a/test/e2e/setup-e2e.sh +++ b/test/e2e/setup-e2e.sh @@ -1,11 +1,13 @@ #!/usr/bin/env bash +readonly KIND_IMAGE="kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72" + SOLO_CLUSTER_NAME=solo-e2e SOLO_NAMESPACE=solo-e2e SOLO_CLUSTER_SETUP_NAMESPACE=solo-e2e-cluster kind delete cluster -n "${SOLO_CLUSTER_NAME}" || true -kind create cluster -n "${SOLO_CLUSTER_NAME}" || exit 1 +kind create cluster -n "${SOLO_CLUSTER_NAME}" --image "${KIND_IMAGE}" || exit 1 kubectl create ns "${SOLO_NAMESPACE}" || exit 1 kubectl create ns "${SOLO_CLUSTER_SETUP_NAMESPACE}" || exit 1 -solo init -d ../charts --namespace "${SOLO_NAMESPACE}" -i node0,node1,node2 -t v0.42.5 -s "${SOLO_CLUSTER_SETUP_NAMESPACE}" || exit 1 # cache args for subsequent commands +solo init --namespace "${SOLO_NAMESPACE}" -d ./charts -i node0,node1,node2 -t v0.42.5 -s "${SOLO_CLUSTER_SETUP_NAMESPACE}" || exit 1 # cache args for subsequent commands solo cluster setup || exit 1 solo network deploy || exit 1