Skip to content

Commit

Permalink
Merge pull request #400 from tiagosiebler/pubtype
Browse files Browse the repository at this point in the history
v2.9.5: feat() use github action for test, feat() publish with provenance, fix(#398) bestBid/bestAskPrice property in 24hr ticker formatted type
  • Loading branch information
tiagosiebler authored Feb 13, 2024
2 parents b716de2 + 0b75569 commit 754afe1
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 40 deletions.
51 changes: 25 additions & 26 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,26 @@ on:
branches:
- master

permissions:
id-token: 'write'
contents: 'read'

jobs:
build:
name: 'Publish NPM'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- name: 'Checkout source code'
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 12
# - run: npm ci
# - run: npm test
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org/'
cache: 'npm'

publish-npm:
needs: build
name: 'Publish NPM'
runs-on: ubuntu-latest
steps:
- name: Package Version Updated
Expand All @@ -31,36 +38,28 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v2
- name: 'Checkout source code'
if: steps.version-updated.outputs.has-updated
uses: actions/checkout@v4

- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
if: steps.version-updated.outputs.has-updated
with:
node-version: 12
registry-url: https://registry.npmjs.org/
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org/'
cache: 'npm'

- run: npm ci --ignore-scripts
- name: Install
run: npm ci --ignore-scripts
if: steps.version-updated.outputs.has-updated

- run: npm run clean
if: steps.version-updated.outputs.has-updated

- run: npm run build
if: steps.version-updated.outputs.has-updated
- run: npm publish --ignore-scripts

- run: npm publish --ignore-scripts --provenance
if: steps.version-updated.outputs.has-updated
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

#publish-gpr:
#needs: build
#runs-on: ubuntu-latest
#steps:
#- uses: actions/checkout@v2
#- uses: actions/setup-node@v1
# with:
# node-version: 12
# registry-url: https://npm.pkg.github.com/
#- run: npm ci
#- run: npm publish
# env:
# NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: 'Build & Test'

on: [push]

jobs:
build:
name: 'Build & Test'
runs-on: ubuntu-latest

steps:
- name: 'Checkout source code'
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org/'
cache: 'npm'

- name: Install
run: npm ci --ignore-scripts

- name: Build
run: npm run build

- name: Test
run: npm run test
env:
API_KEY_COM: ${{ secrets.API_KEY_COM }}
API_SECRET_COM: ${{ secrets.API_SECRET_COM }}
PROXY_ENABLED: ${{ secrets.PROXY_ENABLED }}
PROXY_HOST: ${{ secrets.PROXY_HOST }}
PROXY_PORT: ${{ secrets.PROXY_PORT }}
PROXY_USER: ${{ secrets.PROXY_USER }}
PROXY_PASS: ${{ secrets.PROXY_PASS }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "binance",
"version": "2.9.4",
"version": "2.9.5",
"description": "Node.js & JavaScript SDK for Binance REST APIs & WebSockets, with TypeScript & end-to-end tests.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/types/websockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export interface WsMessage24hrTickerFormatted extends WsSharedBase {
closeQuantity: number;
bestBid: number;
bestBidQuantity: number;
bestAsk: number;
bestAskPrice: number;
bestAskQuantity: number;
open: number;
high: number;
Expand Down
2 changes: 1 addition & 1 deletion test/futures-coinm/private.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Private Futures USDM REST API Endpoints', () => {
api_key: API_KEY,
api_secret: API_SECRET,
},
{ httpsAgent: getTestProxy() },
getTestProxy(),
);
let book: CoinMSymbolOrderBookTicker[];

Expand Down
2 changes: 1 addition & 1 deletion test/futures-usdm/private.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Private Futures USDM REST API Endpoints', () => {
api_key: API_KEY,
api_secret: API_SECRET,
},
{ httpsAgent: getTestProxy() },
getTestProxy(),
);

const symbol = 'BTCUSDT';
Expand Down
2 changes: 1 addition & 1 deletion test/futures-usdm/public.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { USDMClient } from '../../src/usdm-client';
import { getTestProxy } from '../proxy.util';

describe('Public Futures USDM REST API Endpoints', () => {
const api = new USDMClient({}, { httpsAgent: getTestProxy() });
const api = new USDMClient({}, getTestProxy());

const symbol = 'BTCUSDT';
const interval = '15m';
Expand Down
21 changes: 15 additions & 6 deletions test/proxy.util.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
import { getHttpsProxyAgent } from '../src';
import { AxiosRequestConfig } from 'axios';

export function getTestProxy() {
export function getTestProxy(): AxiosRequestConfig {
if (process.env.PROXY_ENABLED !== 'true') {
return;
return {};
}
const host = process.env.PROXY_HOST;
const port = process.env.PROXY_PORT;
const user = process.env.PROXY_USER;
const pass = process.env.PROXY_PASS;
if (!host || !port || !user || !pass) {
throw new Error(`One or more env vars missing for proxy support`);
throw new Error('One or more env vars missing for proxy support');
}

const httpsAgent = getHttpsProxyAgent(host, port, user, pass);
return httpsAgent;
return {
proxy: {
host,
port: Number(port),
auth: {
username: user,
password: pass,
},
protocol: 'http',
},
};
}
2 changes: 1 addition & 1 deletion test/spot/private.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Private Spot REST API Endpoints', () => {
},
{
timeout: 1000 * 60,
httpsAgent: getTestProxy(),
...getTestProxy(),
},
);

Expand Down
2 changes: 1 addition & 1 deletion test/spot/public.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '../response.util';

describe('Public Spot REST API Endpoints', () => {
const api = new MainClient({}, { httpsAgent: getTestProxy() });
const api = new MainClient({}, getTestProxy());

const symbol = 'BTCUSDT';
const interval = '15m';
Expand Down
2 changes: 1 addition & 1 deletion test/spot/staking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Staking API Endpoints', () => {
},
{
timeout: 1000 * 60,
httpsAgent: getTestProxy(),
...getTestProxy(),
},
);

Expand Down

0 comments on commit 754afe1

Please sign in to comment.