Skip to content

Commit

Permalink
test: update structure
Browse files Browse the repository at this point in the history
  • Loading branch information
pcheremu committed Mar 14, 2024
1 parent d6e9744 commit 0095274
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 112 deletions.
87 changes: 20 additions & 67 deletions .github/workflows/test-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,81 +2,28 @@ name: Tests

on: pull_request

# macos-latest
jobs:
tests_linux:
tests:
permissions:
contents: read
strategy:
matrix:
node-version: ['18.17.1', '20.11.0'] # or 18.17.1
tags: ["common.test.ts"]
os: ['macos-latest', 'ubuntu-latest', 'windows-latest']
node-version: ['18.17.1', '20.11.0']
tags: ['common.test.ts', 'dev.test.ts']
runs-on: ubuntu-latest
services:
docker:
image: docker:latest


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

- name: Setup Node.js
uses: actions/setup-node@v3
- name: Install Docker
if: runner.os == 'Linux'
uses: docker/setup-docker@v2
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: |
npx jest --verbose --testPathPattern=${{ matrix.tags }}
shell: bash

tests_windows:
permissions:
contents: read
strategy:
matrix:
node-version: ['18.17.1', '20.11.0'] # or 18.17.1
tags: ["common.test.ts"]
runs-on: windows-latest
version: 'latest'

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

# - name: Check if Docker Desktop installer is cached
# id: check_cache
# uses: actions/cache@v2
# with:
# path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey\docker-desktop\4.28.0
# key: docker-desktop-installer

# - name: Install Docker Desktop
# if: steps.check_cache.outputs.cache-hit != 'true'
# run: |
# choco install docker-desktop -y
# Start-Sleep -s 120

# - name: Use cached Docker Desktop installer
# if: steps.check_cache.outputs.cache-hit == 'true'
# shell: pwsh
# run: |
# Start-Process -FilePath "C:\Users\runneradmin\AppData\Local\Temp\chocolatey\docker-desktop\4.28.0\Docker for Windows Installer.exe" -ArgumentList "install --quiet" -RedirectStandardOutput "docker.log" -Wait

# - if: runner.os == 'macOS'
# run: |
# brew install --cask docker
# docker --version

- name: Setup Node.js
uses: actions/setup-node@v3
with:
Expand All @@ -85,16 +32,22 @@ jobs:

# Second 'npm i' call is required to avoid CI issue with wrong build package version detection
- name: Install dependencies and build
shell: bash
run: |
docker --version
npm ci && npm run build && npm i -g .
echo "zksync-cli version: " && npx zksync-cli --version
- name: Run tests
env:
if: ${{ runner.os }} != 'Linux'
env:
CI: true
E2E_TESTNET_PK: ${{ secrets.E2E_TESTNET_PK }}
run: |
npx jest --verbose --testPathPattern=${{ matrix.tags }}
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
45 changes: 0 additions & 45 deletions test/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,48 +164,3 @@ describe("Common tests", () => {
});
});
});

describe("Dev tests", () => {

//
describe("Check zksync-cli dev", () => {

it("npx zksync-cli dev config", () => {
const command = "yes | npx zksync-cli dev config";
const result = executeCommand(command);
console.log(result.output);
expect(result.exitCode).toBe(0);
});

it("npx zksync-cli dev start", () => {
const command = "npx zksync-cli dev start";
const result1 = executeCommand(command);
console.log("first run:" + result1.output);
const result2 = executeCommand(command);
console.log("first run:" + result2.output);
expect(result2.exitCode).toBe(0);
});

//id1718 - excluded
it("npx zksync-cli dev update module", () => {
const command = "npx zksync-cli dev update zkcli-portal";
const result = executeCommand(command);
expect(result.output).toMatch(/(Updating module)/i);
expect(result.exitCode).toBe(0);
});

it("npx zksync-cli dev restart", () => {
const command = "npx zksync-cli dev restart";
const result = executeCommand(command);
// console.log(result.output);
expect(result.exitCode).toBe(0);
});

it("npx zksync-cli dev stop", () => {
const command = "npx zksync-cli dev stop";
const result = executeCommand(command);
// console.log(result.output);
expect(result.exitCode).toBe(0);
});
});
});
43 changes: 43 additions & 0 deletions test/dev.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { executeCommand } from "./src/helper";


describe("Check zksync-cli dev", () => {

it("npx zksync-cli dev config", () => {
const command = "yes | npx zksync-cli dev config";
const result = executeCommand(command);
console.log(result.output);
expect(result.exitCode).toBe(0);
});

it("npx zksync-cli dev start", () => {
const command = "npx zksync-cli dev start";
const result1 = executeCommand(command);
console.log("first run:" + result1.output);
const result2 = executeCommand(command);
console.log("first run:" + result2.output);
expect(result2.exitCode).toBe(0);
});

//id1718
it("npx zksync-cli dev update module", () => {
const command = "npx zksync-cli dev update zkcli-portal";
const result = executeCommand(command);
expect(result.output).toMatch(/(Updating module)/i);
expect(result.exitCode).toBe(0);
});

it("npx zksync-cli dev restart", () => {
const command = "npx zksync-cli dev restart";
const result = executeCommand(command);
// console.log(result.output);
expect(result.exitCode).toBe(0);
});

it("npx zksync-cli dev stop", () => {
const command = "npx zksync-cli dev stop";
const result = executeCommand(command);
// console.log(result.output);
expect(result.exitCode).toBe(0);
});
});

0 comments on commit 0095274

Please sign in to comment.