@kabran-tecnologia/kabran-config 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kabran-tecnologia/kabran-config",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Shared quality configurations, enforcement scripts, and CI/CD tooling for Kabran projects",
5
5
  "author": "Kabran",
6
6
  "license": "MIT",
@@ -11,6 +11,7 @@
11
11
  *
12
12
  * Options:
13
13
  * --type=<node|react|base> Project type (default: node)
14
+ * --runner=<github|self-hosted> Runner type (default: github)
14
15
  * --skip-husky Don't copy husky hooks
15
16
  * --skip-workflows Don't copy workflow files
16
17
  * --sync-workflows Overwrite existing workflow files
@@ -74,6 +75,7 @@ export function logDry(message) {
74
75
  export function parseArgs(args) {
75
76
  const options = {
76
77
  type: 'node',
78
+ runner: 'github',
77
79
  skipHusky: false,
78
80
  skipWorkflows: false,
79
81
  skipQualityStandard: false,
@@ -112,6 +114,14 @@ export function parseArgs(args) {
112
114
  logError(`Invalid type: ${type}. Valid options: node, react, base`);
113
115
  process.exit(1);
114
116
  }
117
+ } else if (arg.startsWith('--runner=')) {
118
+ const runner = arg.split('=')[1];
119
+ if (['github', 'self-hosted'].includes(runner)) {
120
+ options.runner = runner;
121
+ } else {
122
+ logError(`Invalid runner: ${runner}. Valid options: github, self-hosted`);
123
+ process.exit(1);
124
+ }
115
125
  }
116
126
  }
117
127
 
@@ -130,6 +140,7 @@ ${colors.yellow}USAGE:${colors.reset}
130
140
 
131
141
  ${colors.yellow}OPTIONS:${colors.reset}
132
142
  --type=<type> Project type: node, react, base (default: node)
143
+ --runner=<runner> Runner type: github, self-hosted (default: github)
133
144
  --skip-husky Don't copy husky hooks
134
145
  --skip-workflows Don't copy GitHub workflow files
135
146
  --skip-quality-standard Don't create quality-standard.md
@@ -147,9 +158,15 @@ ${colors.yellow}EXAMPLES:${colors.reset}
147
158
  # Setup React project
148
159
  npx kabran-setup --type=react
149
160
 
161
+ # Setup with self-hosted runners (Kosmos CI)
162
+ npx kabran-setup --runner=self-hosted
163
+
150
164
  # Update workflows only
151
165
  npx kabran-setup --sync-workflows
152
166
 
167
+ # Update to self-hosted workflows
168
+ npx kabran-setup --sync-workflows --runner=self-hosted
169
+
153
170
  # Generate telemetry .env.example
154
171
  npx kabran-setup --telemetry-env
155
172
 
@@ -160,6 +177,10 @@ ${colors.yellow}UPDATE STRATEGY:${colors.reset}
160
177
  - Config files: Re-export from kabran-config (auto-update via npm update)
161
178
  - Workflows: Copied once, update with --sync-workflows
162
179
  - Husky hooks: Copied once, update with --sync-husky
180
+
181
+ ${colors.yellow}RUNNER TYPES:${colors.reset}
182
+ - github: Standard GitHub-hosted runners (ubuntu-latest)
183
+ - self-hosted: Kosmos self-hosted runners [self-hosted, linux, x64, docker]
163
184
  `);
164
185
  }
165
186
 
@@ -282,7 +303,7 @@ export function writeFile(dest, content, options = {}) {
282
303
  * @returns {object} Results
283
304
  */
284
305
  export function setupWorkflows(projectDir, templatesDir, options) {
285
- const {force = false, dryRun = false, syncWorkflows = false} = options;
306
+ const {force = false, dryRun = false, syncWorkflows = false, runner = 'github'} = options;
286
307
  const overwrite = force || syncWorkflows;
287
308
 
288
309
  const results = {
@@ -291,13 +312,22 @@ export function setupWorkflows(projectDir, templatesDir, options) {
291
312
  skipped: 0,
292
313
  };
293
314
 
294
- const workflowFiles = ['ci.yml', 'commitlint.yml', 'validate-pr-source.yml'];
315
+ // Determine CI workflow file based on runner type
316
+ const ciWorkflowSrc = runner === 'self-hosted' ? 'ci-self-hosted.yml' : 'ci.yml';
317
+
318
+ // Map of source file -> destination file
319
+ const workflowFiles = [
320
+ {src: ciWorkflowSrc, dest: 'ci.yml'},
321
+ {src: 'commitlint.yml', dest: 'commitlint.yml'},
322
+ {src: 'validate-pr-source.yml', dest: 'validate-pr-source.yml'},
323
+ ];
295
324
 
296
- logInfo('Setting up GitHub workflows...');
325
+ const runnerLabel = runner === 'self-hosted' ? 'self-hosted' : 'GitHub-hosted';
326
+ logInfo(`Setting up GitHub workflows (${runnerLabel} runners)...`);
297
327
 
298
328
  for (const file of workflowFiles) {
299
- const src = join(templatesDir, '.github', 'workflows', file);
300
- const dest = join(projectDir, '.github', 'workflows', file);
329
+ const src = join(templatesDir, '.github', 'workflows', file.src);
330
+ const dest = join(projectDir, '.github', 'workflows', file.dest);
301
331
 
302
332
  const status = copyFile(src, dest, {overwrite, dryRun});
303
333
 
@@ -648,6 +678,7 @@ export function runSetup(projectDir, options) {
648
678
  console.log('');
649
679
  logInfo(`Setting up project at: ${projectDir}`);
650
680
  logInfo(`Project type: ${options.type}`);
681
+ logInfo(`Runner type: ${options.runner}`);
651
682
  if (options.dryRun) {
652
683
  logWarn('DRY-RUN MODE - No files will be modified');
653
684
  }
@@ -0,0 +1,108 @@
1
+ # Kabran CI Quality Workflow (Self-Hosted Runners)
2
+ #
3
+ # This workflow runs the Kabran CI pipeline on self-hosted runners
4
+ # and posts quality reports to PRs.
5
+ #
6
+ # Runner Labels: [self-hosted, linux, x64, docker]
7
+ #
8
+ # For GitHub-hosted runners, use ci-quality.yml instead.
9
+ #
10
+ # Requirements:
11
+ # - scripts/ci-config.sh with PROJECT_NAME, PM, and ci_steps() defined
12
+ # - @kabran-tecnologia/kabran-config installed as dev dependency
13
+ # - Kosmos CI runners configured for this repository
14
+
15
+ name: CI Quality
16
+
17
+ on:
18
+ push:
19
+ branches: [main]
20
+ pull_request:
21
+ branches: [main]
22
+
23
+ concurrency:
24
+ group: ${{ github.workflow }}-${{ github.ref }}
25
+ cancel-in-progress: true
26
+
27
+ jobs:
28
+ ci:
29
+ name: CI Pipeline
30
+ runs-on: [self-hosted, linux, x64, docker]
31
+ timeout-minutes: 15
32
+
33
+ permissions:
34
+ contents: read
35
+ pull-requests: write
36
+
37
+ steps:
38
+ - name: Checkout
39
+ uses: actions/checkout@v4
40
+ with:
41
+ fetch-depth: 0
42
+
43
+ - name: Setup Node.js
44
+ uses: actions/setup-node@v4
45
+ with:
46
+ node-version: "20"
47
+ cache: "npm"
48
+
49
+ - name: Install dependencies
50
+ run: npm ci
51
+
52
+ - name: Run CI Pipeline
53
+ id: ci
54
+ env:
55
+ CI_USE_V2: "true"
56
+ CI_OUTPUT_FILE_V2: "docs/quality/ci-result.json"
57
+ run: |
58
+ npx kabran-ci || exit_code=$?
59
+
60
+ if [ -f "docs/quality/ci-result.json" ]; then
61
+ echo "ci_result_exists=true" >> $GITHUB_OUTPUT
62
+ else
63
+ echo "ci_result_exists=false" >> $GITHUB_OUTPUT
64
+ fi
65
+
66
+ exit ${exit_code:-0}
67
+
68
+ - name: Generate PR Comment
69
+ if: github.event_name == 'pull_request' && steps.ci.outputs.ci_result_exists == 'true'
70
+ id: comment
71
+ run: |
72
+ npx kabran-pr-comment \
73
+ --current docs/quality/ci-result.json \
74
+ --baseline-branch ${{ github.base_ref }} \
75
+ --output /tmp/pr-comment.md || true
76
+
77
+ if [ -f "/tmp/pr-comment.md" ]; then
78
+ echo "comment_exists=true" >> $GITHUB_OUTPUT
79
+ fi
80
+
81
+ - name: Post PR Comment
82
+ if: github.event_name == 'pull_request' && steps.comment.outputs.comment_exists == 'true'
83
+ uses: marocchino/sticky-pull-request-comment@v2
84
+ with:
85
+ header: kabran-quality
86
+ path: /tmp/pr-comment.md
87
+
88
+ - name: Upload CI Result
89
+ if: always() && steps.ci.outputs.ci_result_exists == 'true'
90
+ uses: actions/upload-artifact@v4
91
+ with:
92
+ name: ci-result
93
+ path: docs/quality/ci-result.json
94
+ retention-days: 30
95
+
96
+ - name: Commit CI Result (main only)
97
+ if: github.ref == 'refs/heads/main' && github.event_name == 'push' && steps.ci.outputs.ci_result_exists == 'true'
98
+ run: |
99
+ git config user.name "github-actions[bot]"
100
+ git config user.email "github-actions[bot]@users.noreply.github.com"
101
+
102
+ if git diff --quiet docs/quality/ci-result.json; then
103
+ echo "No changes to ci-result.json"
104
+ else
105
+ git add docs/quality/ci-result.json
106
+ git commit -m "chore(ci): update ci-result.json [skip ci]"
107
+ git push
108
+ fi
@@ -0,0 +1,53 @@
1
+ # Kabran CI Workflow (Self-Hosted Runners)
2
+ #
3
+ # This workflow runs CI on self-hosted runners with Docker support.
4
+ # Use this when you have Kosmos CI runners configured.
5
+ #
6
+ # Runner Labels: [self-hosted, linux, x64, docker]
7
+ #
8
+ # For GitHub-hosted runners, use ci.yml instead.
9
+
10
+ name: CI
11
+
12
+ on:
13
+ pull_request:
14
+ branches: [main, staging]
15
+ push:
16
+ branches: [main, staging]
17
+
18
+ concurrency:
19
+ group: ${{ github.workflow }}-${{ github.ref }}
20
+ cancel-in-progress: true
21
+
22
+ jobs:
23
+ ci:
24
+ name: CI Pipeline
25
+ runs-on: [self-hosted, linux, x64, docker]
26
+ timeout-minutes: 15
27
+
28
+ steps:
29
+ - name: Checkout
30
+ uses: actions/checkout@v4
31
+
32
+ - name: Setup Node.js
33
+ uses: actions/setup-node@v4
34
+ with:
35
+ node-version: "24"
36
+ cache: "npm"
37
+
38
+ - name: Install dependencies
39
+ run: npm ci
40
+
41
+ - name: Lint
42
+ run: npm run lint
43
+
44
+ - name: Type Check
45
+ run: npm run type-check
46
+
47
+ - name: Build
48
+ run: npm run build
49
+
50
+ - name: Test
51
+ run: npm test
52
+ env:
53
+ CI: true