From b442f86cfec43215fc773aa7bad6eca55fdd2990 Mon Sep 17 00:00:00 2001 From: Serhii Volovyk Date: Thu, 19 May 2022 09:18:25 +0300 Subject: [PATCH] GitHub actions added (#969) * GitHub actions added * danger ci test simlified * small github actions fix * init new function bug fixed --- .github/workflows/danger.yml | 11 +++++++++++ .github/workflows/linter.yml | 11 +++++++++++ .github/workflows/test-matrix.yml | 19 +++++++++++++++++++ .travis.yml | 16 ---------------- README.md | 1 - bin/near-cli.js | 1 - commands/dev-deploy.js | 5 ++++- index.js | 4 ++++ 8 files changed, 49 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/danger.yml create mode 100644 .github/workflows/linter.yml create mode 100644 .github/workflows/test-matrix.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml new file mode 100644 index 00000000..b7764e5f --- /dev/null +++ b/.github/workflows/danger.yml @@ -0,0 +1,11 @@ +name: Danger +on: push +jobs: + eslint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install modules + run: yarn + - name: Run Danger + run: yarn danger ci diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 00000000..e150cd9b --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,11 @@ +name: Linter +on: push +jobs: + eslint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install modules + run: yarn + - name: Run ESLint + run: yarn lint --max-warnings 0 diff --git a/.github/workflows/test-matrix.yml b/.github/workflows/test-matrix.yml new file mode 100644 index 00000000..ded202df --- /dev/null +++ b/.github/workflows/test-matrix.yml @@ -0,0 +1,19 @@ +name: Tests +on: push +jobs: + tests: + strategy: + matrix: + platform: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: "12" + - name: Install modules + run: yarn + - name: Run tests + env: + NODE_ENV: ci + run: yarn test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0c11c89e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: node_js -node_js: - - 12 -env: - - NODE_ENV=ci -cache: yarn -script: - - yarn lint - - yarn test - - yarn danger ci -notifications: - email: - recipients: - - devx@near.org - on_success: never # default: change - on_failure: change # default: always diff --git a/README.md b/README.md index 43d621e2..2d8b11aa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # NEAR CLI (command line interface) -[![Build Status](https://travis-ci.com/near/near-cli.svg?branch=master)](https://travis-ci.com/near/near-cli) [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/near/near-cli) NEAR CLI is a Node.js application that relies on [`near-api-js`](https://github.com/near/near-api-js) to connect to and interact with the NEAR blockchain. Create accounts, access keys, sign & send transactions with this versatile command line interface tool. diff --git a/bin/near-cli.js b/bin/near-cli.js index f09b53fd..5277746b 100644 --- a/bin/near-cli.js +++ b/bin/near-cli.js @@ -106,7 +106,6 @@ const deploy = { .option('initFunction', { desc: 'Initialization method', type: 'string', - default: 'new' }) .option('initArgs', { desc: 'Initialization arguments', diff --git a/commands/dev-deploy.js b/commands/dev-deploy.js index eff1c649..037f56b3 100644 --- a/commands/dev-deploy.js +++ b/commands/dev-deploy.js @@ -28,7 +28,6 @@ module.exports = { .option('initFunction', { desc: 'Initialization method', type: 'string', - default: 'new' }) .option('initArgs', { desc: 'Initialization arguments', @@ -85,6 +84,10 @@ async function devDeploy(options) { // Deploy with init function and args const actions = [transactions.deployContract(readFileSync(options.wasmFile))]; + if (options.initArgs && !options.initFunction) { + options.initFunction = 'new'; + } + if (options.initFunction) { if (!options.initArgs) { await eventtracking.track(eventtracking.EVENT_ID_DEPLOY_END, { success: false, error: 'Must add initialization arguments' }, options); diff --git a/index.js b/index.js index 8ce38954..a66dace9 100644 --- a/index.js +++ b/index.js @@ -60,6 +60,10 @@ exports.deploy = async function (options) { // Deploy with init function and args const txs = [transactions.deployContract(fs.readFileSync(options.wasmFile))]; + if (options.initArgs && !options.initFunction) { + options.initFunction = 'new'; + } + if (options.initFunction) { if (!options.initArgs) { console.error('Must add initialization arguments.\nExample: near deploy --accountId near.testnet --initFunction "new" --initArgs \'{"key": "value"}\'');