Skip to content

Commit

Permalink
Merge pull request #92 from skalenetwork/enhancement-NO_ANSI_COLORS
Browse files Browse the repository at this point in the history
Added support for NO_ANSI_COLORS=1 for github actions
  • Loading branch information
sergiy-skalelabs authored Feb 9, 2024
2 parents f2bef69 + e409c46 commit 0b953f3
Show file tree
Hide file tree
Showing 18 changed files with 148 additions and 67 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/comprehensive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
cd cli-hh
export PATH=$PATH:$(dirname $(which npx))
yarn install
export NO_ANSI_COLORS=1
./clean.sh || true
./init.sh
Expand Down Expand Up @@ -134,14 +135,15 @@ jobs:
cd comprehensive-test
export DETECTED_UBUNTU_VERSION=$(lsb_release -r | cut -f2)
export TRYING_SKALED_AT_PATH=./app_cache/bin_$DETECTED_UBUNTU_VERSION/skaled
$TRYING_SKALED_AT_PATH --colors --version
$TRYING_SKALED_AT_PATH --version
$TRYING_SKALED_AT_PATH --help
- name: INIT - generate configuration files for S-Chain nodes
working-directory: ${{env.working-directory}}
run: |
export PATH=$PATH:$(dirname $(which npx))
cd comprehensive-test/s_chain_gen
export NO_ANSI_COLORS=1
./init.sh
- name: INIT - download Skale Manager
Expand Down Expand Up @@ -211,6 +213,7 @@ jobs:
working-directory: ${{env.working-directory}}
run: |
cd comprehensive-test/engine/create_pems
export NO_ANSI_COLORS=1
./create_pems.sh
- name: RUN - full test - everything up and running
Expand All @@ -225,6 +228,7 @@ jobs:
export PATH=$PATH:$(dirname $(which npx))
export COUNT_OF_SKALED_INSTANCES_TO_SKIP_START=0
export COUNT_OF_IMA_AGENT_INSTANCES_TO_SKIP_START=0
export NO_ANSI_COLORS=1
node ./index.js
- name: RUN - full test - one SKALED is down
Expand All @@ -239,6 +243,7 @@ jobs:
export PATH=$PATH:$(dirname $(which npx))
export COUNT_OF_SKALED_INSTANCES_TO_SKIP_START=1
export COUNT_OF_IMA_AGENT_INSTANCES_TO_SKIP_START=0
export NO_ANSI_COLORS=1
node ./index.js
- name: RUN - full test - one IMA Agent is down
Expand All @@ -253,6 +258,7 @@ jobs:
export PATH=$PATH:$(dirname $(which npx))
export COUNT_OF_SKALED_INSTANCES_TO_SKIP_START=0
export COUNT_OF_IMA_AGENT_INSTANCES_TO_SKIP_START=1
export NO_ANSI_COLORS=1
node ./index.js
- name: RUN - full test - one SKALED and one IMA Agent are down
Expand All @@ -267,6 +273,7 @@ jobs:
export PATH=$PATH:$(dirname $(which npx))
export COUNT_OF_SKALED_INSTANCES_TO_SKIP_START=1
export COUNT_OF_IMA_AGENT_INSTANCES_TO_SKIP_START=1
export NO_ANSI_COLORS=1
node ./index.js
- name: RUN - full test - Main Net connectivity problems testing
Expand All @@ -281,6 +288,7 @@ jobs:
export PATH=$PATH:$(dirname $(which npx))
export ENABLED_IMA_MAIN_NET_TUNNELLING=true
export ENABLED_IMA_MAIN_NET_CONNECTION_PROBLEMS=true
export NO_ANSI_COLORS=1
node ./index.js
- name: SHUTDOWN - stop SGX Wallet
Expand Down
20 changes: 9 additions & 11 deletions .github/workflows/container-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ jobs:
pwd
export PATH=$PATH:$(dirname $(which npx))
cd cli-hh
export NO_ANSI_COLORS=1
./clean.sh
./init.sh
Expand Down Expand Up @@ -148,7 +149,7 @@ jobs:
cd comprehensive-test
export DETECTED_UBUNTU_VERSION=$(lsb_release -r | cut -f2)
export TRYING_SKALED_AT_PATH=./app_cache/bin_$DETECTED_UBUNTU_VERSION/skaled
$TRYING_SKALED_AT_PATH --colors --version
$TRYING_SKALED_AT_PATH --version
$TRYING_SKALED_AT_PATH --help
- name: INIT - generate configuration files for S-Chain nodes
Expand All @@ -157,6 +158,7 @@ jobs:
export PATH=$PATH:$(dirname $(which npx))
cd comprehensive-test/s_chain_gen
yarn install
export NO_ANSI_COLORS=1
./clean.sh || true
./init.sh
Expand Down Expand Up @@ -282,6 +284,7 @@ jobs:
sudo rm -rf ./client.key || true
sudo rm -rf ./client.pem || true
sudo rm -rf ./client.crt || true
export NO_ANSI_COLORS=1
./create_pems.sh
- name: RUN - full test - everything up and running
Expand All @@ -292,7 +295,6 @@ jobs:
cd comprehensive-test/engine
export ALL_SKALE_TEST_CLOUD_RUN=1
export DISABLE_S2S_TESTS=1
#
export VERSION=13.13.13-test.13
echo "Docker image(will run) version is:" $VERSION
export NAME=ima
Expand All @@ -301,11 +303,11 @@ jobs:
export IMAGE_NAME=$REPO_NAME:$VERSION
export LATEST_IMAGE_NAME=$REPO_NAME:latest
echo "Docker image(will run) name for IMA Agent is:" $IMAGE_NAME
#
export SEPARATED_IMA_AGENT_MODE=1
export PATH=$PATH:$(dirname $(which npx))
export COUNT_OF_SKALED_INSTANCES_TO_SKIP_START=0
export COUNT_OF_IMA_AGENT_INSTANCES_TO_SKIP_START=0
export NO_ANSI_COLORS=1
node ./index.js
- name: RUN - full test - one SKALED is down
Expand All @@ -316,7 +318,6 @@ jobs:
cd comprehensive-test/engine
export ALL_SKALE_TEST_CLOUD_RUN=1
export DISABLE_S2S_TESTS=1
#
export VERSION=13.13.13-test.13
echo "Docker image(will run) version is:" $VERSION
export NAME=ima
Expand All @@ -325,11 +326,11 @@ jobs:
export IMAGE_NAME=$REPO_NAME:$VERSION
export LATEST_IMAGE_NAME=$REPO_NAME:latest
echo "Docker image(will run) name for IMA Agent is:" $IMAGE_NAME
#
export SEPARATED_IMA_AGENT_MODE=1
export PATH=$PATH:$(dirname $(which npx))
export COUNT_OF_SKALED_INSTANCES_TO_SKIP_START=1
export COUNT_OF_IMA_AGENT_INSTANCES_TO_SKIP_START=0
export NO_ANSI_COLORS=1
node ./index.js
- name: RUN - full test - one IMA Agent is down
Expand All @@ -340,7 +341,6 @@ jobs:
cd comprehensive-test/engine
export ALL_SKALE_TEST_CLOUD_RUN=1
export DISABLE_S2S_TESTS=1
#
export VERSION=13.13.13-test.13
echo "Docker image(will run) version is:" $VERSION
export NAME=ima
Expand All @@ -349,11 +349,11 @@ jobs:
export IMAGE_NAME=$REPO_NAME:$VERSION
export LATEST_IMAGE_NAME=$REPO_NAME:latest
echo "Docker image(will run) name for IMA Agent is:" $IMAGE_NAME
#
export SEPARATED_IMA_AGENT_MODE=1
export PATH=$PATH:$(dirname $(which npx))
export COUNT_OF_SKALED_INSTANCES_TO_SKIP_START=0
export COUNT_OF_IMA_AGENT_INSTANCES_TO_SKIP_START=1
export NO_ANSI_COLORS=1
node ./index.js
- name: RUN - full test - one SKALED and one IMA Agent are down
Expand All @@ -364,7 +364,6 @@ jobs:
cd comprehensive-test/engine
export ALL_SKALE_TEST_CLOUD_RUN=1
export DISABLE_S2S_TESTS=1
#
export VERSION=13.13.13-test.13
echo "Docker image(will run) version is:" $VERSION
export NAME=ima
Expand All @@ -373,11 +372,11 @@ jobs:
export IMAGE_NAME=$REPO_NAME:$VERSION
export LATEST_IMAGE_NAME=$REPO_NAME:latest
echo "Docker image(will run) name for IMA Agent is:" $IMAGE_NAME
#
export SEPARATED_IMA_AGENT_MODE=1
export PATH=$PATH:$(dirname $(which npx))
export COUNT_OF_SKALED_INSTANCES_TO_SKIP_START=1
export COUNT_OF_IMA_AGENT_INSTANCES_TO_SKIP_START=1
export NO_ANSI_COLORS=1
node ./index.js
- name: RUN - full test - one SKALED and one IMA Agent are down
Expand All @@ -388,7 +387,6 @@ jobs:
cd comprehensive-test/engine
export ALL_SKALE_TEST_CLOUD_RUN=1
export DISABLE_S2S_TESTS=1
#
export VERSION=13.13.13-test.13
echo "Docker image(will run) version is:" $VERSION
export NAME=ima
Expand All @@ -397,11 +395,11 @@ jobs:
export IMAGE_NAME=$REPO_NAME:$VERSION
export LATEST_IMAGE_NAME=$REPO_NAME:latest
echo "Docker image(will run) name for IMA Agent is:" $IMAGE_NAME
#
export SEPARATED_IMA_AGENT_MODE=1
export PATH=$PATH:$(dirname $(which npx))
export ENABLED_IMA_MAIN_NET_TUNNELLING=true
export ENABLED_IMA_MAIN_NET_CONNECTION_PROBLEMS=true
export NO_ANSI_COLORS=1
node ./index.js
- name: SHUTDOWN - stop SGX Wallet
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
- name: Run test (JS part)
working-directory: ./test
run: |
export NO_ANSI_COLORS=1
yarn test
- name: Prepare test (PY part)
Expand All @@ -95,4 +96,5 @@ jobs:
run: |
export URL_W3_ETHEREUM="http://127.0.0.1:8545"
export URL_W3_S_CHAIN="http://127.0.0.1:8545"
export NO_ANSI_COLORS=1
python3 test.py
2 changes: 1 addition & 1 deletion .github/workflows/network-browser-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:

- name: Run network-browser tests
working-directory: network-browser
run: bash run_tests.sh
run: bash run_tests.sh
5 changes: 5 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ jobs:
with:
python-version: 3.8

- name: Ensure deps are latest and build everything
run: |
yarn install
yarn rebuild
- name: Build and publish container
run: |
export BRANCH=${GITHUB_REF##*/}
Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
* @sergiy-skalelabs @kladkogex @DmytroNazarenko
* @sergiy-skalelabs @dmytrotkk @DmytroNazarenko
*.md @skalenetwork/docowners
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ COPY package.json package.json

COPY runner runner
COPY src src
COPY src/pow src/build/pow
RUN mkdir IMA
COPY IMA/proxy IMA/proxy
COPY IMA/package.json IMA/package.json
Expand Down
20 changes: 11 additions & 9 deletions network-browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
getMainnetManagerAbi,
getMainnetProvider
} from './src/contracts'
import { delay, pingUrl, withTimeout } from './src/tools'
import { delay, getLoggerConfig, checkEndpoint, withTimeout } from './src/tools'
import { BrowserTimeoutError } from './src/errors'
import { browse } from './src/browser'
import {
Expand All @@ -37,14 +37,12 @@ import {
NETWORK_BROWSER_DELAY,
MULTICALL,
CONNECTED_ONLY,
SCHAIN_RPC_URL,
LOG_LEVEL,
LOG_PRETTY
SCHAIN_RPC_URL
} from './src/constants'

import { Logger, type ILogObj } from 'tslog'

const log = new Logger<ILogObj>({ minLevel: LOG_LEVEL, stylePrettyLogs: LOG_PRETTY })
const log = new Logger<ILogObj>(getLoggerConfig('loop'))

async function safeNetworkBrowserLoop() {
log.info(`Running network-browser...`)
Expand All @@ -55,24 +53,28 @@ async function safeNetworkBrowserLoop() {
log.info(`NETWORK_BROWSER_TIMEOUT: ${NETWORK_BROWSER_TIMEOUT}`)
log.info(`NETWORK_BROWSER_DELAY: ${NETWORK_BROWSER_DELAY}`)

log.info(`Trying to connect to the sChain RPC: ${SCHAIN_RPC_URL}`)
await checkEndpoint(SCHAIN_RPC_URL)
log.info(`Trying to connect to the mainnet RPC`)
await checkEndpoint(MAINNET_RPC_URL)

const provider = await getMainnetProvider(MAINNET_RPC_URL, MULTICALL)
const managerAbi = getMainnetManagerAbi()
const schainsInternal = schainsInternalContract(managerAbi, provider)
const nodes = nodesContract(managerAbi, provider)
log.info(`Trying to connect to the sChain RPC: ${SCHAIN_RPC_URL}`)
await pingUrl(SCHAIN_RPC_URL)

while (true) {
try {
await withTimeout(browse(schainsInternal, nodes), NETWORK_BROWSER_TIMEOUT)
await delay(NETWORK_BROWSER_DELAY)
} catch (error) {
if (error instanceof BrowserTimeoutError) {
console.error(
log.error(
`A timeout (${NETWORK_BROWSER_TIMEOUT} ms) error occurred:`,
error.message
)
} else {
console.error('An error occurred in browse:', error)
log.error('An error occurred in browse:', error)
}
await delay(POST_ERROR_DELAY)
}
Expand Down
6 changes: 3 additions & 3 deletions network-browser/src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import {
filterConnectedHashes
} from './schains'
import { getNodesGroups } from './nodes'
import { CONNECTED_ONLY, IMA_NETWORK_BROWSER_DATA_PATH, LOG_LEVEL, LOG_PRETTY } from './constants'
import { writeJson, currentTimestamp, chainIdInt } from './tools'
import { CONNECTED_ONLY, IMA_NETWORK_BROWSER_DATA_PATH } from './constants'
import { writeJson, currentTimestamp, chainIdInt, getLoggerConfig } from './tools'

const log = new Logger<ILogObj>({ minLevel: LOG_LEVEL, stylePrettyLogs: LOG_PRETTY })
const log = new Logger<ILogObj>(getLoggerConfig('browser'))

export async function browse(schainsInternal: Contract, nodes: Contract): Promise<void> {
log.info('Browse iteration started, collecting chains')
Expand Down
3 changes: 3 additions & 0 deletions network-browser/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ export const NETWORK_BROWSER_TIMEOUT = secondsEnv(process.env.NETWORK_BROWSER_TI

export const LOG_LEVEL = optionalEnvNumber('NETWORK_BROWSER_LOG_LEVEL', 1)
export const LOG_PRETTY = booleanEnv('NETWORK_BROWSER_LOG_PRETTY', false)
export const LOG_FORMAT =
'{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}\t{{logLevelName}}\t{{name}}\t'
export const LOG_PREFIX = 'snb::'
Loading

0 comments on commit 0b953f3

Please sign in to comment.