Skip to content

Commit

Permalink
chore(ci): finalize CI workflows after final sync (#30)
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Klick <[email protected]>
  • Loading branch information
nathanklick authored Feb 20, 2024
1 parent e13d199 commit 96b6cdc
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 20 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/flow-build-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
4 changes: 2 additions & 2 deletions .github/workflows/flow-pull-request-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}

Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/zxc-code-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
37 changes: 31 additions & 6 deletions .github/workflows/zxc-compile-code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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() }}
Expand Down Expand Up @@ -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: |
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions resources/extract-jar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ if [ -z "${2}" ]; then
exit 1
fi

[[ -d "${2}" ]] || mkdir -p "${2}"
cd "${2}" && jar xvf "${1}"
8 changes: 8 additions & 0 deletions src/core/k8.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
6 changes: 5 additions & 1 deletion src/core/platform_installer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/core/platform_installer_e2e.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions test/e2e/setup-e2e.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 96b6cdc

Please sign in to comment.