From 7470c64cd0b437fe7c14ec5a0c1e14014b912e61 Mon Sep 17 00:00:00 2001 From: Zaiidmo Date: Tue, 24 Feb 2026 11:21:53 +0000 Subject: [PATCH 1/2] ops: updated workflows & added vitest config for tests coverage --- .../workflows/{ci .yml => pr-validation.yml} | 28 ++++--- .github/workflows/publish.yml | 41 +++++---- .github/workflows/release-check.yml | 83 +++++++++++++++++++ vitest.config.ts | 20 +++++ 4 files changed, 145 insertions(+), 27 deletions(-) rename .github/workflows/{ci .yml => pr-validation.yml} (50%) create mode 100644 .github/workflows/release-check.yml create mode 100644 vitest.config.ts diff --git a/.github/workflows/ci .yml b/.github/workflows/pr-validation.yml similarity index 50% rename from .github/workflows/ci .yml rename to .github/workflows/pr-validation.yml index bb1b64e..fc872ed 100644 --- a/.github/workflows/ci .yml +++ b/.github/workflows/pr-validation.yml @@ -1,37 +1,41 @@ -name: CI +name: CI - PR Validation on: pull_request: - branches: [master, develop] - push: branches: [develop] - workflow_dispatch: permissions: contents: read jobs: - ci: + validate: + name: CI - PR Validation runs-on: ubuntu-latest + steps: - name: Checkout uses: actions/checkout@v4 - - name: Use Node.js + - name: Setup Node uses: actions/setup-node@v4 with: - node-version: 22 + node-version: 20 cache: npm - registry-url: https://registry.npmjs.org/ - - name: Install dependencies + - name: Install run: npm ci + - name: Format (check) + run: npm run format + - name: Lint - run: npm run lint --if-present + run: npm run lint + + - name: Typecheck + run: npm run typecheck - name: Test - run: npm test --if-present + run: npm test - name: Build - run: npm run build --if-present + run: npm run build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c3d032d..57fb5bb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,33 +1,44 @@ -name: Publish to npm +name: Publish to NPM on: push: - branches: - - master tags: - "v*.*.*" workflow_dispatch: -permissions: - contents: read - id-token: write - jobs: publish: runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 with: - node-version: 22 - registry-url: https://registry.npmjs.org/ - cache: npm + node-version: "20" + registry-url: "https://registry.npmjs.org" + - name: Install dependencies run: npm ci - - name: Build library + + - name: Run lint (if present) + run: npm run lint --if-present + continue-on-error: false + + - name: Run tests (if present) + run: npm test --if-present + continue-on-error: false + + - name: Build package run: npm run build - - name: Publish to npm - run: npm publish --access public --provenance + + - name: Publish to NPM + run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release-check.yml b/.github/workflows/release-check.yml new file mode 100644 index 0000000..1a05af2 --- /dev/null +++ b/.github/workflows/release-check.yml @@ -0,0 +1,83 @@ +name: CI - Release Check + +on: + pull_request: + branches: [master] + workflow_dispatch: + inputs: + sonar: + description: "Run SonarCloud analysis" + required: true + default: "false" + type: choice + options: + - "false" + - "true" + +concurrency: + group: ci-release-${{ github.ref }} + cancel-in-progress: true + +jobs: + ci: + name: release checks + runs-on: ubuntu-latest + timeout-minutes: 25 + + # Config stays in the workflow file (token stays in repo secrets) + env: + SONAR_HOST_URL: "https://sonarcloud.io" + SONAR_ORGANIZATION: "ciscode" + SONAR_PROJECT_KEY: "CISCODE-MA_LoggingKit" + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: "22" + cache: "npm" + + - name: Install + run: npm ci + + - name: Format + run: npm run format + + - name: Typecheck + run: npm run typecheck + + - name: Lint + run: npm run lint + + - name: Test (with coverage) + run: npm run test:cov + + - name: Build + run: npm run build + + - name: SonarCloud Scan + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.sonar == 'true' }} + uses: SonarSource/sonarqube-scan-action@v6 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ env.SONAR_HOST_URL }} + with: + args: > + -Dsonar.organization=${{ env.SONAR_ORGANIZATION }} \ + -Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} \ + -Dsonar.sources=src \ + -Dsonar.tests=test \ + -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info + + - name: SonarCloud Quality Gate + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.sonar == 'true' }} + uses: SonarSource/sonarqube-quality-gate-action@v1 + timeout-minutes: 10 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ env.SONAR_HOST_URL }} diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..639dd47 --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,20 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + environment: "node", + coverage: { + enabled: true, + reporter: ["text", "html", "lcov"], + exclude: ["**/node_modules/**", "**/dist/**", "**/test/**"], + threshold: { + lines: 80, + functions: 80, + branches: 80, + statements: 80, + }, + }, + globals: true, + watch: false, + }, +}); From d001fee71bbfd5f547ebf2ae5338337519bd15c5 Mon Sep 17 00:00:00 2001 From: Zaiidmo Date: Tue, 24 Feb 2026 11:36:43 +0000 Subject: [PATCH 2/2] changeset --- .changeset/gold-chairs-pull.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/gold-chairs-pull.md diff --git a/.changeset/gold-chairs-pull.md b/.changeset/gold-chairs-pull.md new file mode 100644 index 0000000..f00f31a --- /dev/null +++ b/.changeset/gold-chairs-pull.md @@ -0,0 +1,5 @@ +--- +"@ciscode/logging-kit": patch +--- + +First release of @ciscode/loggingKit