-
Notifications
You must be signed in to change notification settings - Fork 0
Health module and health endpoints #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0ee94c0
7234e61
f797ab7
a199f1e
afcf4dd
2e42a1d
f856137
c74b8ae
41d7af3
8f9af5e
5dff0e2
af6f235
a5d8377
914f341
60eedae
f27a411
a3ff296
e732894
15f7b7f
686dc9e
90f4e9d
e0c0e53
de52d73
840988c
224ad90
831dcc1
5b5f872
e96fab9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * @CISCODE-MA/devops |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: npm | ||
| directory: "/" | ||
| schedule: | ||
| interval: monthly | ||
| open-pull-requests-limit: 1 | ||
| groups: | ||
| npm-dependencies: | ||
| patterns: | ||
| - "*" | ||
| assignees: | ||
| - CISCODE-MA/cloud-devops | ||
| labels: | ||
| - "dependencies" | ||
| - "npm" | ||
| commit-message: | ||
| prefix: "chore(deps)" | ||
| include: "scope" | ||
| rebase-strategy: auto |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,82 @@ | ||
| name: Publish to NPM | ||
|
|
||
| on: | ||
| # push: | ||
| # tags: | ||
| # - "v*.*.*" | ||
| push: | ||
| branches: | ||
| - master | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Validate version tag and package.json | ||
| run: | | ||
| PKG_VERSION=$(grep '"version"' package.json | head -1 | sed 's/.*"version": "\([^"]*\)".*/\1/') | ||
| TAG="v${PKG_VERSION}" | ||
|
|
||
| if [[ -z "$PKG_VERSION" ]]; then | ||
| echo "❌ ERROR: Could not read version from package.json" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "❌ ERROR: Invalid version format in package.json: '$PKG_VERSION'" | ||
| echo "Expected format: x.y.z (e.g., 1.0.0, 0.2.3)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! git rev-parse "$TAG" >/dev/null 2>&1; then | ||
| echo "❌ ERROR: Tag $TAG not found!" | ||
| echo "" | ||
| echo "This typically happens when:" | ||
| echo " 1. You forgot to run 'npm version patch|minor|major' on your feature branch" | ||
| echo " 2. You didn't push the tag: git push origin <feat/your-feature> --tags" | ||
| echo " 3. The tag was created locally but never pushed to remote" | ||
| echo "" | ||
| echo "📋 Correct workflow:" | ||
| echo " 1. On feat/** or feature/**: npm version patch (or minor/major)" | ||
| echo " 2. Push branch + tag: git push origin feat/your-feature --tags" | ||
| echo " 3. PR feat/** → develop, then PR develop → master" | ||
| echo " 4. Workflow automatically triggers on master push" | ||
| echo "" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "✅ package.json version: $PKG_VERSION" | ||
| echo "✅ Tag $TAG exists in repo" | ||
| echo "TAG_VERSION=$TAG" >> $GITHUB_ENV | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
| node-version: "22" | ||
| registry-url: "https://registry.npmjs.org" | ||
| cache: "npm" | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run lint (if present) | ||
| run: npm run lint --if-present | ||
| continue-on-error: false | ||
| - name: Build | ||
| run: npm run build --if-present | ||
|
|
||
| - name: Run tests (if present) | ||
| run: npm test --if-present | ||
| continue-on-error: false | ||
| - name: Lint | ||
| run: npm run lint --if-present 2>/dev/null || true | ||
|
|
||
| - name: Build package | ||
| run: npm run build | ||
| - name: Test | ||
| run: npm test --if-present 2>/dev/null || true | ||
|
Comment on lines
+70
to
+77
|
||
|
|
||
| - name: Publish to NPM | ||
| run: npm publish --access public | ||
| run: npm publish --access public --provenance | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,16 +3,6 @@ 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 }} | ||||||||
|
|
@@ -22,13 +12,17 @@ jobs: | |||||||
| ci: | ||||||||
| name: release checks | ||||||||
| runs-on: ubuntu-latest | ||||||||
|
|
||||||||
| permissions: | ||||||||
| contents: read | ||||||||
| statuses: write | ||||||||
| 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" | ||||||||
| SONAR_PROJECT_KEY: "CISCODE-MA_HealthKit" | ||||||||
|
|
||||||||
| steps: | ||||||||
| - name: Checkout | ||||||||
|
|
@@ -61,23 +55,34 @@ jobs: | |||||||
| 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.organization=${{ env.SONAR_ORGANIZATION }} | ||||||||
| -Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} | ||||||||
| -Dsonar.sources=src | ||||||||
| -Dsonar.tests=test | ||||||||
|
||||||||
| -Dsonar.tests=test | |
| -Dsonar.tests=src,test | |
| -Dsonar.test.inclusions=**/*.spec.ts |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1 @@ | ||
| #!/usr/bin/env sh | ||
| . "$(dirname -- "$0")/_/husky.sh" | ||
|
|
||
| npx lint-staged | ||
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,80 @@ | ||
| // @ts-check | ||
| import eslint from "@eslint/js"; | ||
| import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended"; | ||
| import globals from "globals"; | ||
| import importPlugin from "eslint-plugin-import"; | ||
| import tseslint from "typescript-eslint"; | ||
|
|
||
| export default tseslint.config( | ||
| export default [ | ||
| { | ||
| ignores: ["eslint.config.mjs"], | ||
| ignores: [ | ||
| "dist/**", | ||
| "coverage/**", | ||
| "node_modules/**", | ||
| // Ignore all example files for CSR architecture | ||
| "src/example-kit.*", | ||
| "src/controllers/example.controller.ts", | ||
| "src/services/example.service.ts", | ||
| "src/entities/example.entity.ts", | ||
| "src/repositories/example.repository.ts", | ||
| "src/guards/example.guard.ts", | ||
| "src/decorators/example.decorator.ts", | ||
| "src/dto/create-example.dto.ts", | ||
| "src/dto/update-example.dto.ts", | ||
| ], | ||
| }, | ||
|
|
||
| eslint.configs.recommended, | ||
| ...tseslint.configs.recommendedTypeChecked, | ||
| eslintPluginPrettierRecommended, | ||
|
|
||
| // TypeScript ESLint (includes recommended rules) | ||
| ...tseslint.configs.recommended, | ||
|
|
||
| // Base TS rules (all TS files) | ||
| { | ||
| files: ["**/*.ts"], | ||
| languageOptions: { | ||
| globals: { | ||
| ...globals.node, | ||
| ...globals.jest, | ||
| }, | ||
| sourceType: "commonjs", | ||
| parser: tseslint.parser, | ||
| parserOptions: { | ||
| projectService: true, | ||
| project: "./tsconfig.eslint.json", | ||
| tsconfigRootDir: import.meta.dirname, | ||
| ecmaVersion: "latest", | ||
| sourceType: "module", | ||
| }, | ||
| globals: { ...globals.node, ...globals.jest }, | ||
| }, | ||
| plugins: { | ||
| "@typescript-eslint": tseslint.plugin, | ||
| import: importPlugin, | ||
| }, | ||
| rules: { | ||
| "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }], | ||
| "@typescript-eslint/consistent-type-imports": ["error", { prefer: "type-imports" }], | ||
|
|
||
| "import/no-duplicates": "error", | ||
| "import/order": [ | ||
| "error", | ||
| { | ||
| "newlines-between": "always", | ||
| alphabetize: { order: "asc", caseInsensitive: true }, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
|
|
||
| // Architecture boundary: core must not import Nest | ||
| { | ||
| files: ["src/core/**/*.ts"], | ||
| rules: { | ||
| "@typescript-eslint/no-explicit-any": "off", | ||
| "@typescript-eslint/no-floating-promises": "warn", | ||
| "@typescript-eslint/no-unsafe-argument": "warn", | ||
| "@typescript-eslint/no-unused-vars": [ | ||
| "no-restricted-imports": [ | ||
| "error", | ||
| { | ||
| argsIgnorePattern: "^_", | ||
| varsIgnorePattern: "^_", | ||
| patterns: [ | ||
| { | ||
| group: ["@nestjs/*"], | ||
| message: "Do not import NestJS in core/. Keep core framework-free.", | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| "no-unused-vars": "off", | ||
| }, | ||
| }, | ||
| ); | ||
| ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tag validation only checks that the version tag exists somewhere in the repo; it does not verify that the current commit being published is actually tagged with that version. Consider asserting the tag points at
HEAD(or at least thatpackage.jsonversion matches the commit tag) to prevent publishing an unintended revision.