From cb00e0b0faf5ec3829d3ec92cc93122381c0a526 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sat, 4 Oct 2025 23:59:21 +0100 Subject: [PATCH 1/5] Updates Docker workflow repo name --- .github/workflows/docker.yml | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index dbb3422..36061cc 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -21,8 +21,7 @@ on: type: boolean env: - REPO_NAME: 'lissy93/networking-toolbox' - # REPO_NAME: ${{ vars.REPO_NAME || github.repository }} + REPO_NAME: ${{ github.repository }} jobs: build: @@ -77,23 +76,38 @@ jobs: uses: docker/login-action@v3 with: registry: ghcr.io - username: ${{ github.actor }} + username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: ๐Ÿ“‹ Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ env.REPO_NAME }} + tags: | + type=raw,value=${{ steps.tags.outputs.tags }} + labels: | + org.opencontainers.image.title=Networking Toolbox + org.opencontainers.image.description=All-in-one Swiss Army knife for sysadmins and network engineers - a collection of 100+ offline-first essential networking tools in a single, easy-to-use Docker image. + org.opencontainers.image.url=https://github.com/${{ github.repository }} + org.opencontainers.image.source=https://github.com/${{ github.repository }} + org.opencontainers.image.vendor=${{ github.repository_owner }} + - name: ๐Ÿ”จ Build and push if: steps.tags.outputs.tags != '' uses: docker/build-push-action@v6 with: context: . platforms: linux/amd64,linux/arm64 - push: ${{ !inputs.dry_run }} + push: ${{ !inputs.dry_run && github.event_name != 'pull_request' }} tags: ${{ steps.tags.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - labels: | - org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} - org.opencontainers.image.revision=${{ github.sha }} - org.opencontainers.image.created=${{ github.event.head_commit.timestamp }} + build-args: | + BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} + VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} + REVISION=${{ github.sha }} - name: โš ๏ธ Warning if skipped if: steps.tags.outputs.tags == '' From 4c920ee519922b27bc7a93249dd0b8de54be50eb Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sat, 4 Oct 2025 23:59:29 +0100 Subject: [PATCH 2/5] Resolves mirroring on tag issue --- .github/workflows/mirror.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml index e8deb1b..a74b885 100644 --- a/.github/workflows/mirror.yml +++ b/.github/workflows/mirror.yml @@ -40,4 +40,5 @@ jobs: chmod 600 ~/.ssh/id_rsa ssh-keyscan codeberg.org >> ~/.ssh/known_hosts git remote add mirror ${{ env.MIRROR_HOST }}:${{ env.MIRROR_USER }}/${{ env.MIRROR_REPO }}.git || true - git push mirror --mirror + git push mirror --all + git push mirror --tags From 929d43309a1d20c7504dc9835ae8b5124bf3ae57 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sun, 5 Oct 2025 14:12:22 +0100 Subject: [PATCH 3/5] Test workflow running on forks, and coverage reporting --- .github/workflows/tests.yml | 64 +++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c432cd5..32e5539 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,9 +1,11 @@ name: ๐Ÿงช Run Tests on: - pull_request: + pull_request_target: + types: [opened, synchronize, reopened] push: branches: [main] + workflow_dispatch: concurrency: group: ci-${{ github.ref }} @@ -14,6 +16,12 @@ permissions: id-token: write # For OIDC with Codecov checks: write # For test reporting +env: + # PR context helpers for conditional logic + IS_PR: ${{ github.event_name == 'pull_request_target' }} + IS_FORK: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository }} + HAS_BOT_TOKEN: ${{ secrets.BOT_TOKEN != '' }} + jobs: unit-tests: name: Unit Tests @@ -22,7 +30,12 @@ jobs: NODE_OPTIONS: "--max_old_space_size=8192" steps: + # Secure checkout for external PRs - uses: actions/checkout@v4 + with: + # For PRs from forks, check out the PR head to prevent token exposure + ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }} + - uses: actions/setup-node@v4 with: node-version: 22 @@ -33,6 +46,7 @@ jobs: id: test run: | npx vitest run \ + --coverage \ --reporter=github-actions \ --reporter=verbose \ --reporter=junit \ @@ -51,7 +65,7 @@ jobs: path: test-result-unit.txt - name: Upload coverage to Codecov - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} @@ -64,20 +78,22 @@ jobs: - name: Unit Test Report id: unit-test-report uses: dorny/test-reporter@v1 - if: always() + if: always() && (env.IS_FORK != 'true' || env.HAS_BOT_TOKEN == 'true') with: name: Unit Tests path: test-results.xml reporter: java-junit fail-on-error: false + token: ${{ env.IS_FORK == 'true' && secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }} + continue-on-error: true - name: Save unit test report data if: always() run: | - echo "passed=${{ steps.unit-test-report.outputs.passed }}" > unit-report-data.txt - echo "failed=${{ steps.unit-test-report.outputs.failed }}" >> unit-report-data.txt - echo "skipped=${{ steps.unit-test-report.outputs.skipped }}" >> unit-report-data.txt - echo "time=${{ steps.unit-test-report.outputs.time }}" >> unit-report-data.txt + echo "passed=${{ steps.unit-test-report.outputs.passed || '0' }}" > unit-report-data.txt + echo "failed=${{ steps.unit-test-report.outputs.failed || '0' }}" >> unit-report-data.txt + echo "skipped=${{ steps.unit-test-report.outputs.skipped || '0' }}" >> unit-report-data.txt + echo "time=${{ steps.unit-test-report.outputs.time || '0' }}" >> unit-report-data.txt - name: Upload unit test report data if: always() @@ -104,7 +120,12 @@ jobs: NODE_OPTIONS: "--max_old_space_size=8192" steps: + # Secure checkout for external PRs - uses: actions/checkout@v4 + with: + # For PRs from forks, check out the PR head to prevent naughty people finding my token + ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }} + - uses: actions/setup-node@v4 with: node-version: 22 @@ -142,20 +163,22 @@ jobs: - name: API Test Report id: api-test-report uses: dorny/test-reporter@v1 - if: always() + if: always() && (env.IS_FORK != 'true' || env.HAS_BOT_TOKEN == 'true') with: name: API Contract Tests path: api-test-results.xml reporter: java-junit fail-on-error: false + token: ${{ env.IS_FORK == 'true' && secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }} + continue-on-error: true - name: Save API test report data if: always() run: | - echo "passed=${{ steps.api-test-report.outputs.passed }}" > api-report-data.txt - echo "failed=${{ steps.api-test-report.outputs.failed }}" >> api-report-data.txt - echo "skipped=${{ steps.api-test-report.outputs.skipped }}" >> api-report-data.txt - echo "time=${{ steps.api-test-report.outputs.time }}" >> api-report-data.txt + echo "passed=${{ steps.api-test-report.outputs.passed || '0' }}" > api-report-data.txt + echo "failed=${{ steps.api-test-report.outputs.failed || '0' }}" >> api-report-data.txt + echo "skipped=${{ steps.api-test-report.outputs.skipped || '0' }}" >> api-report-data.txt + echo "time=${{ steps.api-test-report.outputs.time || '0' }}" >> api-report-data.txt - name: Upload API test report data if: always() @@ -175,7 +198,12 @@ jobs: NODE_OPTIONS: "--max_old_space_size=8192" steps: + # Secure checkout for external PRs - uses: actions/checkout@v4 + with: + # For PRs from forks, check out the PR head to prevent token exposure + ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }} + - uses: actions/setup-node@v4 with: node-version: 22 @@ -219,20 +247,22 @@ jobs: - name: E2E Test Report id: e2e-test-report uses: dorny/test-reporter@v1 - if: always() + if: always() && (env.IS_FORK != 'true' || env.HAS_BOT_TOKEN == 'true') with: name: E2E Tests path: e2e-results.xml reporter: java-junit fail-on-error: false + token: ${{ env.IS_FORK == 'true' && secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }} + continue-on-error: true - name: Save e2e test report data if: always() run: | - echo "passed=${{ steps.e2e-test-report.outputs.passed }}" > e2e-report-data.txt - echo "failed=${{ steps.e2e-test-report.outputs.failed }}" >> e2e-report-data.txt - echo "skipped=${{ steps.e2e-test-report.outputs.skipped }}" >> e2e-report-data.txt - echo "time=${{ steps.e2e-test-report.outputs.time }}" >> e2e-report-data.txt + echo "passed=${{ steps.e2e-test-report.outputs.passed || '0' }}" > e2e-report-data.txt + echo "failed=${{ steps.e2e-test-report.outputs.failed || '0' }}" >> e2e-report-data.txt + echo "skipped=${{ steps.e2e-test-report.outputs.skipped || '0' }}" >> e2e-report-data.txt + echo "time=${{ steps.e2e-test-report.outputs.time || '0' }}" >> e2e-report-data.txt - name: Upload e2e test report data if: always() From 5e1f0a47b0154cb2b048238e2f36d33e16b50f01 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sun, 5 Oct 2025 14:12:59 +0100 Subject: [PATCH 4/5] Added more deployment options and scripts listing to readme --- .github/README.md | 52 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/.github/README.md b/.github/README.md index 563d664..8003390 100644 --- a/.github/README.md +++ b/.github/README.md @@ -29,21 +29,27 @@ You can then start the server with `node build`.
More Deployment Options -#### Option 4 - Source: Static -Follow the dev steps below. -Then run `npm run build:static` to compile output.
-And upload the contents of `./build` to any web server, CDN or static host. - -#### Option 5 - Source: Docker -Follow the dev steps below. -Then run `docker build -t networking-toolbox .` to build the image.
-You can then start the container with `docker run -p 8080:80 networking-toolbox`. - -#### Option 6 - GitHub Pages +#### Option 4 - GitHub Pages Fork the repo.
Head to the Actions tab, find the "Deploy to GitHub Pages" workflow, and trigger it.
Then go to Settings > Pages > Source and select the `gh-pages` branch.
Visit `https://.github.io/networking-toolbox/` to see your deployed app. + +#### Option 5 - Source: Static +Follow the dev steps below. +Then run `npm run build:static` to compile output.
+And upload the contents of `./build` to any web server, CDN or static host. + +#### Option 6 - Source: Docker +Follow the dev steps below. +Then run `docker build -t networking-toolbox .` to build the image.
+You can then start the container with `docker run -p 8080:80 networking-toolbox`. + +#### Option 7 - Source: Other Platforms +You can build the app from source for a variety of platforms. This is done via SvelteKit adapters.
+First, follow the dev steps below. +Then, simply set the `DEPLOY_ENV` environmental variable, to one of `vercel`, `node`, `docker`, `netlify`, `static` or just `auto`, and build the app
+For example: `DEPLOY_ENV='node' npm run build`
--- @@ -71,6 +77,30 @@ Before merging, code must pass all unit and end-to-end tests, as well as linting yarn test ``` +
+

Project Commands

+ +##### Building +- `npm run dev` - Starts the development server with hot reload/HMR +- `npm run build` - Builds the app for production + - Note: choose adapter for platform by setting the `DEPLOY_ENV` var (see above) +- `npm run preview` - Test your build locally (build required first) +- `npm start` - Starts the production app (build required first) + +##### Testing +- `npm test` โ€” Run unit tests with Vitest +- `npm run test:api` โ€” Run API tests +- `npm run test:e2e` โ€” Run Playwright end-to-end tests +- `npm run test:coverage` โ€” Generate test coverage + +##### Checking +- `npm run check` โ€” SvelteKit checks (types & diagnostics) +- `npm run types` โ€” TypeScript-specific strict checking +- `npm run lint` โ€” ESLint on all TS and Svelte files +- `npm run format` โ€” Format files with Prettier +- `npm run build-check` โ€” Quitley check build works +
+ --- ### Contributing From 1da304afc8ce2c00e0f0621533200df203588cb6 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sun, 5 Oct 2025 14:13:19 +0100 Subject: [PATCH 5/5] Allows test config to report coverage --- package.json | 4 +--- vitest.config.ts | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index c079797..6cce1a2 100644 --- a/package.json +++ b/package.json @@ -16,11 +16,9 @@ "build:node": "DEPLOY_ENV='node' npm run build", "build:static": "DEPLOY_ENV='static' npm run build", "test": "vitest", - "test:ui": "vitest --ui", "test:coverage": "vitest --coverage", "test:api": "vitest run --config tests/vitest.api.config.ts", - "test:e2e": "playwright test", - "test:e2e:ui": "playwright test --ui" + "test:e2e": "playwright test" }, "dependencies": {}, "devDependencies": { diff --git a/vitest.config.ts b/vitest.config.ts index 8d40192..2f2af9e 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -20,6 +20,7 @@ export default defineConfig({ 'src/hooks.server.ts', 'src/service-worker.ts' ], + reporter: ['text', 'lcov', 'html'], thresholds: { global: { statements: 85,