-
Notifications
You must be signed in to change notification settings - Fork 0
Develop #33
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
Develop #33
Changes from all commits
ee50492
9315596
8410542
8c4c8a6
eea8f5a
7ffac0d
c6afa3c
d090c49
1023053
4afd85e
043bc2f
5d1abfb
cffc665
97cd396
97ef834
c43dc64
707eb27
7f1b1b3
06bd9bd
d288699
6522bf0
99e1125
f0e8cdd
26b9575
319d84e
030bf0c
71eac3a
8bcea38
f2b63a8
10a708d
b1609d9
0f77ab4
2231826
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| 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 |
|---|---|---|
|
|
@@ -3,50 +3,43 @@ 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 | ||
|
|
||
| env: | ||
| SONAR_HOST_URL: "https://sonarcloud.io" | ||
| SONAR_ORGANIZATION: "ciscode" | ||
| SONAR_PROJECT_KEY: "CISCODE-MA_AuditKit" | ||
| NODE_VERSION: "22" | ||
|
|
||
| # ─── Job 1: Static checks (fast feedback, runs in parallel with test) ────────── | ||
| jobs: | ||
| ci: | ||
| name: release checks | ||
| quality: | ||
| name: Quality Checks | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 25 | ||
| timeout-minutes: 10 | ||
|
|
||
| # 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_AuditKit" | ||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v6 | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "22" | ||
| node-version: ${{ env.NODE_VERSION }} | ||
| cache: "npm" | ||
|
|
||
| - name: Install | ||
| run: npm ci | ||
|
|
||
| - name: Audit | ||
| run: npm audit --production | ||
| - name: Security Audit | ||
| # Only fail on high/critical — moderate noise in dev deps is expected | ||
| run: npm audit --production --audit-level=high | ||
|
|
||
| - name: Format | ||
| run: npm run format | ||
|
|
@@ -57,30 +50,149 @@ jobs: | |
| - name: Lint | ||
| run: npm run lint | ||
|
|
||
| # ─── Job 2: Tests + Coverage (artifact passed to Sonar) ──────────────────────── | ||
| test: | ||
| name: Test & Coverage | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ env.NODE_VERSION }} | ||
| cache: "npm" | ||
|
|
||
| - name: Install | ||
| run: npm ci | ||
|
|
||
| - name: Test (with coverage) | ||
| run: npm run test:cov | ||
|
|
||
| - name: Upload coverage report | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: coverage-report | ||
| path: coverage/ | ||
| retention-days: 1 | ||
|
|
||
| # ─── Job 3: Build ────────────────────────────────────────────────────────────── | ||
| build: | ||
| name: Build | ||
| runs-on: ubuntu-latest | ||
| needs: [quality, test] | ||
| timeout-minutes: 10 | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ env.NODE_VERSION }} | ||
| cache: "npm" | ||
|
|
||
| - name: Install | ||
| run: npm ci | ||
|
|
||
| - name: Build | ||
| run: npm run build | ||
|
|
||
| # ─── Job 4: SonarCloud (depends on test for coverage data) ───────────────────── | ||
| sonar: | ||
| name: SonarCloud Analysis | ||
| runs-on: ubuntu-latest | ||
| needs: [test] | ||
| timeout-minutes: 15 | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| # Full history required for accurate blame & new code detection | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Download coverage report | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: coverage-report | ||
| path: coverage/ | ||
|
|
||
| - name: Cache SonarCloud packages | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.sonar/cache | ||
| key: sonar-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} | ||
| restore-keys: sonar-${{ runner.os }}- | ||
|
|
||
| - name: SonarCloud Scan | ||
| if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.sonar == 'true' }} | ||
| uses: SonarSource/sonarqube-scan-action@v7 | ||
| 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.test.inclusions=**/*.spec.ts,**/*.test.ts | ||
| -Dsonar.exclusions=**/node_modules/**,**/dist/**,**/coverage/**,**/*.d.ts | ||
| -Dsonar.coverage.exclusions=**/*.spec.ts,**/*.test.ts,**/index.ts | ||
| -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info | ||
| -Dsonar.typescript.tsconfigPath=tsconfig.json | ||
| -Dsonar.qualitygate.wait=true | ||
| -Dsonar.qualitygate.timeout=300 | ||
|
Comment on lines
+111
to
+158
|
||
|
|
||
| - 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 }} | ||
| # ─── Job 5: Final status report (always runs) ────────────────────────────────── | ||
| report: | ||
| name: Report CI Status | ||
| runs-on: ubuntu-latest | ||
| needs: [quality, test, build, sonar] | ||
| # Run even if upstream jobs failed | ||
| if: always() | ||
| timeout-minutes: 5 | ||
|
|
||
| permissions: | ||
| contents: read | ||
| statuses: write | ||
|
|
||
| steps: | ||
| - name: Resolve overall result | ||
| id: result | ||
| run: | | ||
| results="${{ needs.quality.result }} ${{ needs.test.result }} ${{ needs.build.result }} ${{ needs.sonar.result }}" | ||
| if echo "$results" | grep -qE "failure|cancelled"; then | ||
| echo "state=failure" >> $GITHUB_OUTPUT | ||
| echo "desc=One or more CI checks failed" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "state=success" >> $GITHUB_OUTPUT | ||
| echo "desc=All CI checks passed" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Post commit status | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| await github.rest.repos.createCommitStatus({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| sha: context.sha, | ||
| state: '${{ steps.result.outputs.state }}', | ||
| context: 'CI / Release Check', | ||
| description: '${{ steps.result.outputs.desc }}', | ||
| target_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}` | ||
| }) | ||
|
Comment on lines
+160
to
+198
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,16 @@ | ||||||
| # @ciscode/audit-kit | ||||||
|
|
||||||
| ## 0.1.0 | ||||||
|
||||||
| ## 0.1.0 | |
| ## 0.0.1 |
Copilot
AI
Apr 6, 2026
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 changelog version header (0.1.0) doesn’t match package.json (0.0.1). This will confuse consumers and can break the publish workflow/tag expectations. Align the changelog entry version with the package version (or bump the package version accordingly).
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
sonarjob always runs onpull_requestevents but relies onsecrets.SONAR_TOKEN. For PRs from forks, secrets are not available, so this job will fail and block CI. Add a guard (e.g., only run whensecrets.SONAR_TOKENis present / whengithub.event.pull_request.head.repo.fork == false) or move Sonar topush/workflow_dispatchonly.