diff --git a/.eslintrc.json b/.eslintrc.json index 72b4e34..546ba31 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -12,7 +12,7 @@ "plugin:security/recommended", "prettier" ], - "ignorePatterns": ["index.ts", "types.ts", "src/util/*.ts", "test/*"], + "ignorePatterns": ["index.ts", "src/util/*.ts", "test/*"], "rules": { "no-empty": [ 1, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fee96b3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: Node CI Workflow + +on: + push: + branches: + - dev + pull_request: + branches: + - dev + workflow_dispatch: + inputs: + workflowBranch: + description: 'Select the branch to run the workflow on' + required: true + default: 'main' + type: choice + options: + - dev + - main +jobs: + ci-dev: + if: ${{ github.event.inputs.workflowBranch == 'dev' }} + uses: shardeum/github-automation/.github/workflows/node-ci-shared.yml@dev + + ci-main: + if: ${{ github.event.inputs.workflowBranch == 'main' || !github.event.inputs.workflowBranch }} + uses: shardeum/github-automation/.github/workflows/node-ci-shared.yml@main \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 83803a4..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,66 +0,0 @@ -include: - - remote: 'https://gitlab.com/pod_security/shared-ci/-/raw/main/security.yml' - -image: 'registry.gitlab.com/shardus/dev-container:latest_node18' - -cache: - paths: - - node_modules/ - -stages: - - prepare - - build - - test - - appsec - -# Prepare job: Install Node.js dependencies -prepare-job: - stage: prepare - script: - - node -v - - apt-get update - - npm i #install Node.js dependencies - -format-job: - stage: build - script: - - echo "Running Prettier..." - - npm run format-check - - echo "Running Prettier complete." - -# Build Job: Compiles the code -build-job: - cache: - paths: - - node_modules/ - stage: build - script: - - echo "Compiling the code..." - - npm run compile - - echo "Compile complete." - -# Lint Job: Runs ESLint for code linting -lint-job: - stage: build - script: - - echo "Running ESlint..." - - npm run lint - - echo "Running ESlint complete." - -run-test: - stage: test - script: - - npm run test - -rust-lint: - stage: build - script: - - cargo clippy --all-targets --all-features -- -D warnings - - RUSTFLAGS=-Wunused-crate-dependencies cargo build - -rust-audit: - stage: appsec - before_script: - - cargo install cargo-audit - script: - - cargo audit diff --git a/package.json b/package.json index f37e68b..aedf07a 100644 --- a/package.json +++ b/package.json @@ -24,18 +24,18 @@ "release": "np --no-cleanup --no-yarn --any-branch", "prepack": "npm run build-node", "postinstall": "npm run build-rust", - "test": "cargo test", + "test": "npm run test:cargo", "test2": "ts-node test/test_lru.ts -p 44001 -c 2", + "test:cargo": "cargo test", "build:rust": "cargo build --workspace && npm run postbuild-cargo", "postbuild-cargo": "node scripts/copy-rename.js", - "lint": "eslint ./src/**/*.ts --quiet", - "lint-windows": "eslint ./src/**/*.ts --quiet", - "format-check": "prettier --check './src/**/*.ts'", + "lint": "eslint \"./src/**/*.ts\"", + "format-check": "prettier --check \"./src/**/*.ts\"", "clean": "cargo clean" }, "repository": { "type": "git", - "url": "https://gitlab.com/Shardus/shardus-net.git" + "url": "https://github.com/shardeum/lib-net.git" }, "publishConfig": { "access": "public" diff --git a/src/index.ts b/src/index.ts index bd73cf4..a37b0e1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -182,7 +182,7 @@ export const Sn = (opts: SnOpts) => { sendCallback ) } - } else{ + } else { /* prettier-ignore */ if(logFlags.net_verbose) console.log('sending without header') _net.send(port, address, stringifiedData, sendCallback) } diff --git a/src/types.ts b/src/types.ts index 14d2d51..b995221 100644 --- a/src/types.ts +++ b/src/types.ts @@ -66,7 +66,7 @@ export type SnOpts = { * @param opts - The options object to validate. * @throws An error if the options object is not valid. */ -export const validateSnOpts = (opts: SnOpts) => { +export const validateSnOpts = (opts: SnOpts): void => { if (!opts) throw new Error('snq: must supply options') if (!opts.port || typeof opts.port !== 'number') throw new Error('snq: must supply port')