Skip to content

Commit

Permalink
test: command run automation
Browse files Browse the repository at this point in the history
  • Loading branch information
pcheremu committed Dec 5, 2023
1 parent cc567a8 commit 8dc2a7f
Show file tree
Hide file tree
Showing 3 changed files with 209 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/run-test-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Call the CLI testing
on: pull_request


jobs:
cli_test_linux_amd64:
name: CLI tests on linux
uses: ./.github/workflows/test-cli.yml
permissions:
contents: read
with:
name: build_linux_amd64
runner: matterlabs-ci-runner

cli_test_windows:
name: CLI tests on Windows
uses: ./.github/workflows/test-cli.yml
permissions:
contents: read
with:
name: build_windows_amd64
runner: windows-2022-github-hosted-16core

cli_test_macos_amd64:
name: CLI tests on macOS
uses: ./.github/workflows/test-cli.yml
permissions:
contents: read
with:
name: build_macos_amd64
runner: macos-12-large
52 changes: 52 additions & 0 deletions .github/workflows/test-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Test CLI

on:
workflow_call:
inputs:
name:
type: string
default: 'build_linux_amd64'
required: true
runner:
type: string
default: 'matterlabs-ci-runner'
required: true


jobs:
preparation_and_running_tests:
runs-on: ${{inputs.runner}}
permissions:
contents: read
strategy:
matrix:
node-version: ['lts/*'] # or 18.17.1
tags: [
"default"
]


name: '${{ matrix.tags }}'
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: npm

- name: Install dependencies
run: |
yes | npx zksync-cli
- if: runner.os == 'Windows'
name: Run tests
run: |
./src/tests/test_zksync_cli.sh
shell: bash

- if: runner.os == 'Linux' || runner.os == 'macOS'
name: Run tests
run: |
./src/tests/test_zksync_cli.sh
126 changes: 126 additions & 0 deletions src/tests/test_zksync_cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#!/bin/bash

declare -i RESULT_COMMON=0

verify_result () {
RESULT_COMMON+=$?
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo success
else
echo failed
fi
}


#BASIC
echo "----- BASIC -----"
echo ">>> Basic command like zksync-cli"

npx zksync-cli
verify_result


echo ""
echo ">>> zksync-cli -V"

npx zksync-cli -V
verify_result

echo ""
echo ">>> zksync-cli -h"

npx zksync-cli -h
verify_result


#DEV PART
echo ""
echo "----- DEV PART -----"
echo ">>> zksync-cli dev"

npx zksync-cli dev
verify_result


echo ""
echo ">>> zksync-cli dev config"

yes | npx zksync-cli dev config
verify_result


#############

echo ""
echo ">>> zksync-cli dev start"

npx zksync-cli dev start
verify_result

echo ""
echo ">>> zksync-cli dev stop"

npx zksync-cli dev stop
verify_result

echo ""
echo ">>> zksync-cli dev restart"

npx zksync-cli dev restart
verify_result

##########

echo ""
echo ">>> zksync-cli dev logs"

npx zksync-cli dev logs
verify_result

echo ""
echo ">>> zksync-cli dev clean"

npx zksync-cli dev clean
verify_result

echo ""
echo ">>> zksync-cli dev install [email protected]"

npx zksync-cli dev install [email protected]
verify_result

##########


echo ""
echo ">>> zksync-cli dev update zksync-web3"

npx zksync-cli dev update zksync-web3
verify_result

echo ""
echo ">>> zksync-cli dev uninstall zksync-web3"

npx zksync-cli dev uninstall zksync-web3
verify_result

echo ""
echo ">>> zksync-cli dev modules"

npx zksync-cli dev modules
verify_result
##########

echo ""
echo ">>> zksync-cli create"
yes | npx zksync-cli create
verify_result

if [ $RESULT_COMMON -eq 0 ]; then
echo success
else
echo ERROR: RESULT_COMMON = $RESULT_COMMON
exit 1 # terminate and indicate error
fi

0 comments on commit 8dc2a7f

Please sign in to comment.