fix(ci/config): Improve CI workflows, update project configuration, and clean up code formatting

This commit is contained in:
Philipp Kunz 2025-04-28 12:58:01 +00:00
parent db01586eb9
commit dba1855eb6
13 changed files with 292 additions and 171 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

3
.gitignore vendored
View File

@ -3,7 +3,6 @@
# artifacts
coverage/
public/
pages/
# installs
node_modules/
@ -17,4 +16,4 @@ node_modules/
dist/
dist_*/
# custom
#------# custom

View File

@ -1,141 +0,0 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- security
- test
- release
- metadata
before_script:
- npm install -g @shipzone/npmci
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
allow_failure: true
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
stage: metadata
script:
- npmci node install lts
- npmci command npm install -g @git.zone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

View File

@ -1,5 +1,14 @@
# Changelog
## 2025-04-28 - 3.0.4 - fix(ci/config)
Improve CI workflows, update project configuration, and clean up code formatting
- Added new Gitea workflow files (default_nottags.yaml and default_tags.yaml) to replace GitLab CI
- Updated package.json with new buildDocs script, revised homepage URL, bug tracking info, and pnpm overrides
- Refined code formatting in TypeScript files, including improved error handling in Cloudflare speed tests and consistent callback structure
- Enhanced tsconfig.json by adding baseUrl and paths for better module resolution
- Introduced readme.plan.md outlining future improvements and feature enhancements
## 2025-04-28 - 3.0.3 - fix(deps)
Update dependency namespaces and bump package versions in CI configuration and source imports

View File

@ -10,7 +10,8 @@
"license": "MIT",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild --web --allowimplicitany)"
"build": "(tsbuild --web --allowimplicitany)",
"buildDocs": "tsdoc"
},
"devDependencies": {
"@git.zone/tsbuild": "^2.1.61",
@ -56,10 +57,16 @@
"network utility",
"TypeScript"
],
"homepage": "https://code.foss.global/push.rocks/smartnetwork",
"homepage": "https://code.foss.global/push.rocks/smartnetwork#readme",
"repository": {
"type": "git",
"url": "https://code.foss.global/push.rocks/smartnetwork.git"
},
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6"
}
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6",
"bugs": {
"url": "https://code.foss.global/push.rocks/smartnetwork/issues"
},
"pnpm": {
"overrides": {}
}
}

View File

@ -1,4 +1,5 @@
# @push.rocks/smartnetwork
network diagnostics
## Install
@ -58,7 +59,7 @@ const checkLocalPort = async (port: number) => {
}
};
checkLocalPort(8080); // Example port number
checkLocalPort(8080); // Example port number
```
### Checking Remote Port Availability
@ -75,7 +76,7 @@ const checkRemotePort = async (hostname: string, port: number) => {
}
};
checkRemotePort('example.com', 443); // Checking HTTPS port on example.com
checkRemotePort('example.com', 443); // Checking HTTPS port on example.com
```
### Using Ping
@ -131,7 +132,7 @@ These examples offer a glimpse into the module's utility in real-world scenarios
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.

47
readme.plan.md Normal file
View File

@ -0,0 +1,47 @@
# Plan to Enhance Code Quality, Feature Set & Documentation
This plan focuses on three pillars to elevate `@push.rocks/smartnetwork`: 1) Code Quality, 2) Feature Enhancements, and 3) Documentation.
## 1. Code Quality Improvements
- Enable strict TypeScript (`strict`, `noImplicitAny`, `strictNullChecks`).
- Enforce linting (ESLint) and formatting (Prettier) with pre-commit hooks.
- Audit and refactor core modules for:
- Clear separation of concerns (IO, business logic, helpers).
- Removal of duplicated logic and dead code.
- Consistent use of async/await and error propagation.
- Introduce custom error classes (e.g., `NetworkError`, `TimeoutError`) for predictable failure handling.
- Augment logging support via injectable logger interface.
- Establish a baseline of ≥90% unit-test coverage and enforce via CI.
## 2. Feature Enhancements
- Expand diagnostics:
- Traceroute functionality with hop-by-hop latency.
- DNS lookup (A, AAAA, MX records).
- HTTP(s) endpoint health check (status codes, headers, latency).
- Improve existing methods:
- `getSpeed`: allow configurable test duration and parallel streams.
- `ping`: add statistical summary (min, max, stddev) and continuous mode.
- `isRemotePortAvailable`: support TCP/UDP checks with timeout and retry.
- Introduce plugin architecture:
- Define `Plugin` interface for third-party extensions.
- Enable runtime registration/unregistration.
- Provide sample plugins (e.g., custom ping strategies, alternate speed providers).
- Optional in-memory caching with TTL for expensive calls (`getPublicIps`, `getGateways`).
## 3. Documentation & Examples
- Upgrade README:
- Detailed API reference with method signatures and option parameters.
- Real-world usage snippets and full example projects.
- Add TSDoc comments to all public classes, methods, and types.
- Create a `docs/` folder with:
- Getting Started guide.
- Advanced topics (plugin development, custom error handling).
- FAQ and troubleshooting section.
- Integrate TypeDoc for automated documentation site generation.
- Update `CONTRIBUTING.md` and `CHANGELOG.md` to reflect development and release practices.
## Next Steps
1. Review and prioritize high-impact items per pillar.
2. Kick off Phase 1 (Code Quality) with linting, TS config, and core refactor.
3. Schedule sprints for Feature and Documentation phases.
4. Configure CI pipeline to enforce quality gates and publish docs.

View File

@ -20,6 +20,6 @@ tap.test('should state when a ping is not alive ', async () => {
tap.test('should send a ping to an IP', async () => {
await expectAsync(testSmartnetwork.ping('192.168.186.999')).property('alive').toBeFalse();
})
});
tap.start();

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartnetwork',
version: '3.0.3',
version: '3.0.4',
description: 'A toolkit for network diagnostics including speed tests, port availability checks, and more.'
}

View File

@ -50,7 +50,7 @@ export class CloudflareSpeed {
},
(error) => {
console.log(`Error: ${error}`);
}
},
);
}
@ -74,7 +74,7 @@ export class CloudflareSpeed {
},
(error) => {
console.log(`Error: ${error}`);
}
},
);
}
@ -92,7 +92,7 @@ export class CloudflareSpeed {
},
(error) => {
console.log(`Error: ${error}`);
}
},
);
}
@ -138,7 +138,7 @@ export class CloudflareSpeed {
req.on('error', (err) => {
reject(err);
});
}
},
);
req.end();

View File

@ -16,7 +16,10 @@ export class SmartNetwork {
return test;
}
public async ping(hostArg: string, timeoutArg: number = 500): Promise<ReturnType<typeof plugins.smartping.Smartping.prototype.ping>> {
public async ping(
hostArg: string,
timeoutArg: number = 500,
): Promise<ReturnType<typeof plugins.smartping.Smartping.prototype.ping>> {
const smartpingInstance = new plugins.smartping.Smartping();
const pingResult = await smartpingInstance.ping(hostArg, timeoutArg);
return pingResult;
@ -120,18 +123,22 @@ export class SmartNetwork {
public async getPublicIps() {
return {
v4: await plugins.publicIp.publicIpv4({
timeout: 1000,
onlyHttps: true,
}).catch(async (err) => {
return null
}),
v6: await plugins.publicIp.publicIpv6({
timeout: 1000,
onlyHttps: true,
}).catch(async (err) => {
return null
})
v4: await plugins.publicIp
.publicIpv4({
timeout: 1000,
onlyHttps: true,
})
.catch(async (err) => {
return null;
}),
v6: await plugins.publicIp
.publicIpv6({
timeout: 1000,
onlyHttps: true,
})
.catch(async (err) => {
return null;
}),
};
}
}

View File

@ -6,9 +6,11 @@
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
"verbatimModuleSyntax": true,
"baseUrl": ".",
"paths": {}
},
"exclude": [
"dist_*/**/*.d.ts"
]
}
}