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

test: cli test solution for zksync-cli #123

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
44 changes: 44 additions & 0 deletions .github/workflows/test-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Tests

on: pull_request

jobs:
tests:
permissions:
contents: read
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
node-version: ['18.17.1', '20.11.0'] # lts/* for lts node
runs-on: ${{ matrix.os }}

name: '${{ matrix.os }} / Node ${{ matrix.node-version }}'
steps:
- uses: actions/checkout@v4

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

# Second 'npm i' call is required to avoid CI issue with wrong build package version detection
- name: Install dependencies and build
run: |
npm ci && npm run build && npm i -g .
echo "zksync-cli version: " && npx zksync-cli --version

- name: Run tests
env:
CI: true
E2E_TESTNET_PK: ${{ secrets.E2E_TESTNET_PK }}
run: |
echo "Run tests"
if [ $RUNNER_OS != 'Linux' ]; then
echo "Run without docker tests"
npx jest --verbose --testPathIgnorePatterns=dev.test.ts
else
echo "Run all tests"
npx jest --verbose --testPathPattern=
fi
shell: bash
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ node_modules
bin

# Workflow
junit.xml
junit.xml

# IDEA
.idea
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,18 @@ If you're using [local setup (dockerized testing node)](https://github.com/matte

### Testing

At the moment, we don't have any tests, but we are working on it.
At the moment, we are working on CLI tests.
In the meantime, you can test the code manually by running the code in [development mode](#run-in-development-mode).

### CLI tests

To run CLI tests for zksync-cli do the following:
1. Make preparation steps `1` and `2` from `Building for production`, or just run `npm i && npm run build`
2. Make sure you see your development build `0.0.0-development` using `npx zksync-cli --version`. If not, install it in depends of your OS settings: `npm i -g .` or `sudo npm i -g .` If you have any other zksync-cli package installed globally `npm ls -g`, just remove it in advance `npm remove zksync-cli -g`.
3. Make sure you have [Docker](https://docs.docker.com/engine/install/) on your system.
4. Rename `.env.example` to `.env` in `./test/src/` dir and add your wallet private key to this file. F.e.: It may looks like `E2E_TESTNET_PK=012345...abcdef`
5. Run `npm run test`

## 🌍 Official Links

- [Website](https://zksync.io/)
Expand Down
13 changes: 13 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".test.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}
Loading
Loading