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

chore: move test scripts from 'package.json' to 'Taskfile' #1485

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
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: 7 additions & 1 deletion .github/workflows/flow-deploy-release-artifact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ jobs:
git_commit_gpgsign: true
git_tag_gpgsign: false

- name: Install Task
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
with:
version: 3.39.2
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
Expand All @@ -150,7 +156,7 @@ jobs:
npm install
echo "VERSION=${{ needs.prepare-release.outputs.version }}"
[[ -n "${{ needs.prepare-release.outputs.version }}" ]] && npm version ${{ needs.prepare-release.outputs.version }} -f --no-git-tag-version
npm run build
task build

- name: Setup JFrog CLI
uses: jfrog/setup-jfrog-cli@f748a0599171a192a2668afee8d0497f7c1069df # v4.5.6
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/flow-gcs-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ jobs:
node-version: 20
cache: npm

- name: Install Task
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
with:
version: 3.39.2
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Helm
uses: azure/setup-helm@b9e51907a09c216f16ebe8536097933489208112 # v4.3.0
with:
Expand All @@ -102,7 +108,7 @@ jobs:
npm install -g @hashgraph/solo

- name: Compile Project
run: npm run build
run: task build

- name: Run GCS Test Script for type ${{ matrix.storageType }}
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/flow-task-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ jobs:
run: |
cd examples/external-database-test
export CONSENSUS_NODE_VERSION=v0.58.3
SOLO_CLUSTER_NAME=solo-task-test-${{ matrix.type }}-${{ github.run_id }}-${{ github.run_attempt }} task install
task destroy
SOLO_CLUSTER_NAME=solo-task-test-${{ matrix.type }}-${{ github.run_id }}-${{ github.run_attempt }} task install:external-database
task destroy:external-database
22 changes: 11 additions & 11 deletions .github/workflows/script/gcs_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,24 @@ SOLO_DEPLOYMENT=solo-e2e

kind delete cluster -n "${SOLO_CLUSTER_NAME}"
kind create cluster -n "${SOLO_CLUSTER_NAME}"
npm run solo-test -- init
npm run solo-test -- cluster setup \
task solo-test -- init
task solo-test -- cluster setup \
-s "${SOLO_CLUSTER_SETUP_NAMESPACE}"
npm run solo-test -- node keys --gossip-keys --tls-keys -i node1
npm run solo-test -- deployment create -i node1 -n "${SOLO_NAMESPACE}" --context kind-"${SOLO_CLUSTER_NAME}" --email [email protected] --deployment-clusters kind-"${SOLO_CLUSTER_NAME}" --cluster-ref kind-${SOLO_CLUSTER_NAME} --deployment "${SOLO_DEPLOYMENT}"
npm run solo-test -- network deploy -i node1 --deployment "${SOLO_DEPLOYMENT}" \
task solo-test -- node keys --gossip-keys --tls-keys -i node1
task solo-test -- deployment create -i node1 -n "${SOLO_NAMESPACE}" --context kind-"${SOLO_CLUSTER_NAME}" --email [email protected] --deployment-clusters kind-"${SOLO_CLUSTER_NAME}" --cluster-ref kind-${SOLO_CLUSTER_NAME} --deployment "${SOLO_DEPLOYMENT}"
task solo-test -- network deploy -i node1 --deployment "${SOLO_DEPLOYMENT}" \
--storage-type "${storageType}" \
"${STORAGE_OPTIONS[@]}" \
--backup-bucket "${streamBackupBucket}" \
--google-credential gcp_service_account.json

npm run solo-test -- node setup -i node1 --deployment "${SOLO_DEPLOYMENT}"
npm run solo-test -- node start -i node1 --deployment "${SOLO_DEPLOYMENT}"
npm run solo-test -- mirror-node deploy --deployment "${SOLO_DEPLOYMENT}" --cluster-ref kind-${SOLO_CLUSTER_NAME} \
task solo-test -- node setup -i node1 --deployment "${SOLO_DEPLOYMENT}"
task solo-test -- node start -i node1 --deployment "${SOLO_DEPLOYMENT}"
task solo-test -- mirror-node deploy --deployment "${SOLO_DEPLOYMENT}" --cluster-ref kind-${SOLO_CLUSTER_NAME} \
--storage-type "${storageType}" \
"${MIRROR_STORAGE_OPTIONS[@]}" \

npm run solo-test -- explorer deploy -s "${SOLO_CLUSTER_SETUP_NAMESPACE}" --deployment "${SOLO_DEPLOYMENT}" --cluster-ref kind-${SOLO_CLUSTER_NAME}
task solo-test -- explorer deploy -s "${SOLO_CLUSTER_SETUP_NAMESPACE}" --deployment "${SOLO_DEPLOYMENT}" --cluster-ref kind-${SOLO_CLUSTER_NAME}

kubectl port-forward -n "${SOLO_NAMESPACE}" svc/haproxy-node1-svc 50211:50211 > /dev/null 2>&1 &

Expand All @@ -112,7 +112,7 @@ cd ..; create_test_account ; cd -

node examples/create-topic.js

npm run solo-test -- node stop -i node1 --deployment "${SOLO_DEPLOYMENT}"
task solo-test -- node stop -i node1 --deployment "${SOLO_DEPLOYMENT}"

echo "Waiting for backup uploader to run"
# manually call script "backup.sh" from container backup-uploader since it only runs every 5 minutes
Expand All @@ -126,4 +126,4 @@ if grep -q \""error\"" backup-uploader.log; then
exit 1
fi

npm run solo-test -- network destroy --deployment "${SOLO_DEPLOYMENT}" --force -q
task solo-test -- network destroy --deployment "${SOLO_DEPLOYMENT}" --force -q
8 changes: 4 additions & 4 deletions .github/workflows/script/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ function create_test_account ()
cd solo

# create new account and extract account id
npm run solo-test -- account create --deployment solo-e2e --hbar-amount 100 --generate-ecdsa-key --set-alias > test.log
task solo-test -- account create --deployment solo-e2e --hbar-amount 100 --generate-ecdsa-key --set-alias > test.log
export OPERATOR_ID=$(grep "accountId" test.log | awk '{print $2}' | sed 's/"//g'| sed 's/,//g')
echo "OPERATOR_ID=${OPERATOR_ID}"
rm test.log

# get private key of the account
npm run solo-test -- account get --deployment solo-e2e --account-id ${OPERATOR_ID} --private-key > test.log
task solo-test -- account get --deployment solo-e2e --account-id ${OPERATOR_ID} --private-key > test.log

# retrieve the field privateKey but not privateKeyRaw
export OPERATOR_KEY=$(grep "privateKey" test.log | grep -v "privateKeyRaw" | awk '{print $2}' | sed 's/"//g'| sed 's/,//g')
export CONTRACT_TEST_KEY_ONE=0x$(grep "privateKeyRaw" test.log | awk '{print $2}' | sed 's/"//g'| sed 's/,//g')
echo "CONTRACT_TEST_KEY_ONE=${CONTRACT_TEST_KEY_ONE}"
rm test.log

npm run solo-test -- account create --deployment solo-e2e --hbar-amount 100 --generate-ecdsa-key --set-alias > test.log
task solo-test -- account create --deployment solo-e2e --hbar-amount 100 --generate-ecdsa-key --set-alias > test.log
export SECOND_KEY=$(grep "accountId" test.log | awk '{print $2}' | sed 's/"//g'| sed 's/,//g')
npm run solo-test -- account get --deployment solo-e2e --account-id ${SECOND_KEY} --private-key > test.log
task solo-test -- account get --deployment solo-e2e --account-id ${SECOND_KEY} --private-key > test.log
export CONTRACT_TEST_KEY_TWO=0x$(grep "privateKeyRaw" test.log | awk '{print $2}' | sed 's/"//g'| sed 's/,//g')
echo "CONTRACT_TEST_KEY_TWO=${CONTRACT_TEST_KEY_TWO}"
rm test.log
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/script/solo_smoke_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function start_background_transactions ()
# generate accounts as background traffic for two minutes
# so record stream files can be kept pushing to mirror node
cd solo
npm run solo-test -- account create --deployment solo-e2e --create-amount 15 > /dev/null 2>&1 &
task solo-test -- account create --deployment solo-e2e --create-amount 15 > /dev/null 2>&1 &
cd -
}

Expand All @@ -69,7 +69,7 @@ function start_contract_test ()
echo "Wait a few seconds for background transactions to start"
sleep 5
echo "Run smart contract test"
npm run hh:test
task hh:test
result=$?

cd -
Expand Down Expand Up @@ -134,7 +134,7 @@ function check_importer_log()
# then call solo account init before deploy mirror and relay node
if [ "$1" == "account-init" ]; then
echo "Call solo account init"
npm run solo-test -- account init --deployment solo-e2e
task solo-test -- account init --deployment solo-e2e
fi

echo "Change to parent directory"
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/zxc-code-style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ jobs:
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install Task
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
with:
version: 3.39.2
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
Expand All @@ -69,4 +75,4 @@ jobs:
run: npm ci

- name: Check Code Style
run: npm run check
run: task check
10 changes: 8 additions & 2 deletions .github/workflows/zxc-e2e-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,14 @@ jobs:
id: npm-deps
run: npm ci

- name: Install Task
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
with:
version: 3.39.2
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Compile Project
run: npm run build
run: task build

- name: Pull Kind Docker Image
run: docker image pull kindest/node:v1.31.4@sha256:2cb39f7295fe7eafee0842b1052a599a4fb0f8bcf3f83d96c7f4864c357c6c30
Expand Down Expand Up @@ -202,7 +208,7 @@ jobs:
- name: Run E2E Tests
run: |
echo "SOLO_TEST_CLUSTER=${{ inputs.cluster-name }}-c1"
SOLO_TEST_CLUSTER=${{ inputs.cluster-name }}-c1 ${{ env.CG_EXEC }} npm run ${{ inputs.npm-test-script }}
SOLO_TEST_CLUSTER=${{ inputs.cluster-name }}-c1 ${{ env.CG_EXEC }} task ${{ inputs.npm-test-script }}

# - name: Sleep on Failure
# if: ${{ failure() }}
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/zxc-unit-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ jobs:
with:
egress-policy: audit

- name: Install Task
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
with:
version: 3.39.2
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

Expand All @@ -76,7 +82,7 @@ jobs:
run: npm ci

- name: Run Unit Tests
run: npm test
run: task test

- name: Publish Windows Unit Test Report
uses: EnricoMi/publish-unit-test-result-action/windows/bash@170bf24d20d201b842d7a52403b73ed297e6645b # v2.18.0
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/zxc-update-readme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ jobs:
fetch-depth: 0
token: ${{ secrets.GH_ACCESS_TOKEN }}

- name: Install Task
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
with:
version: 3.39.2
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
with:
Expand Down Expand Up @@ -103,7 +109,7 @@ jobs:
npm install
echo "VERSION=${{ inputs.version }}"
[[ -n "${{ inputs.version }}" ]] && npm version ${{ inputs.version }} -f --no-git-tag-version
npm run build
task build
npm install -g @hashgraph/solo
npm link
which solo
Expand Down
12 changes: 6 additions & 6 deletions DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ Below we describe how you can set up local environment and contribute to `solo`.
* Run `npm i` to install the required packages
* Run `npm link` to install `solo` as the CLI
* Note: you need to do it once. If `solo` already exists in your path, you will need to remove it first.
* Alternative way would be to run `npm run solo-test -- <COMMAND> <ARGS>`
* Run `npm test` or `npm run test` to run the unit tests
* Alternative way would be to run `task solo-test -- <COMMAND> <ARGS>`
* Run `task test` to run the unit tests
* Run `solo` to access the CLI.
* Note that debug logs are stored at `$HOME/.solo/logs/solo.log`.
* So you may use `tail -f $HOME/.solo/logs/solo.log | jq` in a separate terminal to keep an eye on the logs.
* Before making a commit run `npm run format`
* Before making a commit run `task format`

## E2E tests

* In order to run E2E test, we need to set up cluster and install the chart.
* Run `./test/e2e/setup-e2e.sh`
* Run `npm run test-e2e-standard`, NOTE: this excludes some E2E tests that have their own command
* Run `task test-e2e-standard`, NOTE: this excludes some E2E tests that have their own command
* You can check the section `scripts` in file `package.json` for more other test commands available.

* Tests are run in random order. The random seed value is shown as message such as:
`Using timestamp seed 1711414247085 for random test order`

* If you like to rerun tests with the same seed, use environment variable `RANDOM_SEED=<integer_number>` with `npm run test-e2e-standard` command.
* Example: `RANDOM_SEED=20 npm run test-e2e-standard`,
* If you like to rerun tests with the same seed, use environment variable `RANDOM_SEED=<integer_number>` with `task test-e2e-standard` command.
* Example: `RANDOM_SEED=20 task test-e2e-standard`,
and you should see an output like: `Using preset seed 20 for random test order`
Loading
Loading