@faros-fde-sandbox/cli 1.1.1 → 1.1.2
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/README.md +405 -114
- package/lib/commands/sync/ci-cd.d.ts.map +1 -1
- package/lib/commands/sync/ci-cd.js +4 -38
- package/lib/commands/sync/ci-cd.js.map +1 -1
- package/lib/commands/sync/index.js +3 -3
- package/lib/commands/sync/linear.d.ts.map +1 -1
- package/lib/commands/sync/linear.js +174 -254
- package/lib/commands/sync/linear.js.map +1 -1
- package/lib/commands/sync/tests.d.ts.map +1 -1
- package/lib/commands/sync/tests.js +129 -197
- package/lib/commands/sync/tests.js.map +1 -1
- package/lib/config/loader.d.ts +0 -1
- package/lib/config/loader.d.ts.map +1 -1
- package/lib/config/loader.js +0 -4
- package/lib/config/loader.js.map +1 -1
- package/lib/index.js +7 -18
- package/lib/index.js.map +1 -1
- package/lib/lib/logger.d.ts.map +1 -1
- package/lib/lib/logger.js.map +1 -1
- package/lib/types/config.d.ts +6 -9
- package/lib/types/config.d.ts.map +1 -1
- package/lib/types/config.js +1 -1
- package/lib/types/config.js.map +1 -1
- package/package.json +14 -7
- package/lib/commands/logs/index.d.ts +0 -3
- package/lib/commands/logs/index.d.ts.map +0 -1
- package/lib/commands/logs/index.js +0 -141
- package/lib/commands/logs/index.js.map +0 -1
- package/lib/commands/sources/index.d.ts +0 -3
- package/lib/commands/sources/index.d.ts.map +0 -1
- package/lib/commands/sources/index.js +0 -125
- package/lib/commands/sources/index.js.map +0 -1
- package/lib/lib/sources/s3.d.ts +0 -19
- package/lib/lib/sources/s3.d.ts.map +0 -1
- package/lib/lib/sources/s3.js +0 -139
- package/lib/lib/sources/s3.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,34 @@
|
|
|
1
1
|
# Faros CLI
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@faros-fde-sandbox/cli)
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
[](https://github.com/faros-fde/faros-cli/actions/workflows/test.yml)
|
|
5
|
+
|
|
6
|
+
CLI for Faros AI - sync test results, CI/CD events, and Linear data.
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [Quick Start](#quick-start)
|
|
12
|
+
- [Commands](#commands)
|
|
13
|
+
- [faros sync tests](#faros-sync-tests)
|
|
14
|
+
- [faros sync ci-cd](#faros-sync-ci-cd)
|
|
15
|
+
- [faros sync linear](#faros-sync-linear)
|
|
16
|
+
- [Configuration](#configuration)
|
|
17
|
+
- [Environment Variables](#environment-variables)
|
|
18
|
+
- [Configuration File](#configuration-file)
|
|
19
|
+
- [Configuration Priority](#configuration-priority)
|
|
20
|
+
- [CI/CD Environments](#cicd-environments)
|
|
21
|
+
- [Global Options](#global-options)
|
|
22
|
+
- [Validation](#validation)
|
|
23
|
+
- [CI/CD Integration](#cicd-integration)
|
|
24
|
+
- [GitHub Actions](#github-actions)
|
|
25
|
+
- [Jenkins](#jenkins)
|
|
26
|
+
- [GitLab CI](#gitlab-ci)
|
|
27
|
+
- [CircleCI](#circleci)
|
|
28
|
+
- [Bitbucket Pipelines](#bitbucket-pipelines)
|
|
29
|
+
- [URI Formats](#uri-formats)
|
|
30
|
+
- [Development](#development)
|
|
31
|
+
- [License](#license)
|
|
6
32
|
|
|
7
33
|
## Installation
|
|
8
34
|
|
|
@@ -24,20 +50,21 @@ faros sync ci-cd build \
|
|
|
24
50
|
--commit "GitHub://myorg/myrepo/abc123" \
|
|
25
51
|
--run "Jenkins://myorg/pipeline/456"
|
|
26
52
|
|
|
27
|
-
#
|
|
28
|
-
faros
|
|
53
|
+
# Report deployment status
|
|
54
|
+
faros sync ci-cd deploy \
|
|
55
|
+
--status Success \
|
|
56
|
+
--commit "GitHub://myorg/myrepo/abc123" \
|
|
57
|
+
--deploy "Kubernetes://myapp/Prod/deploy-789"
|
|
29
58
|
|
|
30
|
-
#
|
|
31
|
-
faros
|
|
59
|
+
# Sync Linear data
|
|
60
|
+
faros sync linear \
|
|
61
|
+
--linear-api-key lin_api_xxx \
|
|
62
|
+
--cutoff-days 30
|
|
32
63
|
```
|
|
33
64
|
|
|
34
65
|
## Commands
|
|
35
66
|
|
|
36
|
-
### `faros sync`
|
|
37
|
-
|
|
38
|
-
Sync data from various sources to Faros.
|
|
39
|
-
|
|
40
|
-
#### `faros sync tests`
|
|
67
|
+
### `faros sync tests`
|
|
41
68
|
|
|
42
69
|
Sync test results (JUnit, TestNG, xUnit, Cucumber, Mocha) to Faros.
|
|
43
70
|
|
|
@@ -56,7 +83,6 @@ faros sync tests <paths...> [options]
|
|
|
56
83
|
- `--concurrency <number>` - Concurrent uploads (default: 8)
|
|
57
84
|
- `--validate` - Validate only, don't send (fast, offline)
|
|
58
85
|
- `--preview` - Show sample records
|
|
59
|
-
- `--dry-run` - Sync to staging graph
|
|
60
86
|
|
|
61
87
|
**Examples:**
|
|
62
88
|
|
|
@@ -67,24 +93,11 @@ faros sync tests test-results/*.xml \
|
|
|
67
93
|
--commit "GitHub://myorg/myrepo/abc123"
|
|
68
94
|
```
|
|
69
95
|
|
|
70
|
-
From S3:
|
|
71
|
-
```bash
|
|
72
|
-
faros sync tests s3://bucket/junit/ \
|
|
73
|
-
--pattern ".*\\.xml$" \
|
|
74
|
-
--s3-region us-east-1 \
|
|
75
|
-
--source "Jenkins"
|
|
76
|
-
```
|
|
77
|
-
|
|
78
96
|
Validate before syncing:
|
|
79
97
|
```bash
|
|
80
98
|
faros sync tests *.xml --validate
|
|
81
99
|
```
|
|
82
100
|
|
|
83
|
-
Dry run to staging:
|
|
84
|
-
```bash
|
|
85
|
-
faros sync tests *.xml --dry-run
|
|
86
|
-
```
|
|
87
|
-
|
|
88
101
|
#### `faros sync ci-cd`
|
|
89
102
|
|
|
90
103
|
Sync CI/CD events (builds and deployments) to Faros.
|
|
@@ -114,88 +127,121 @@ faros sync ci-cd deploy \
|
|
|
114
127
|
--deploy-end-time "2024-01-15T11:03:00Z"
|
|
115
128
|
```
|
|
116
129
|
|
|
117
|
-
### `faros
|
|
130
|
+
### `faros sync linear`
|
|
131
|
+
|
|
132
|
+
Sync Linear issues, projects, teams, and users to Faros.
|
|
133
|
+
|
|
134
|
+
**Usage:**
|
|
135
|
+
```bash
|
|
136
|
+
faros sync linear --linear-api-key <key> [options]
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Options:**
|
|
140
|
+
- `--linear-api-key <key>` - Linear API key (or set `LINEAR_API_KEY` env var)
|
|
141
|
+
- `--cutoff-days <days>` - Fetch issues updated in the last N days (default: 90, or from config)
|
|
142
|
+
- `--page-size <size>` - Number of records per API call, 1-250 (default: 50)
|
|
143
|
+
- `--preview` - Show sync configuration without executing
|
|
118
144
|
|
|
119
|
-
|
|
145
|
+
**Configuration Priority:**
|
|
146
|
+
1. CLI options (`--linear-api-key`, `--cutoff-days`)
|
|
147
|
+
2. Environment variables (`LINEAR_API_KEY`, `FAROS_API_KEY`, `FAROS_GRAPH`)
|
|
148
|
+
3. Config file (`faros.config.yaml`)
|
|
149
|
+
4. Defaults
|
|
120
150
|
|
|
121
|
-
**
|
|
122
|
-
- `faros sources list` - List all configured sources
|
|
123
|
-
- `faros sources get <name>` - Get source details
|
|
151
|
+
**Examples:**
|
|
124
152
|
|
|
125
|
-
|
|
153
|
+
Using environment variables (recommended):
|
|
126
154
|
```bash
|
|
127
|
-
|
|
155
|
+
export LINEAR_API_KEY=lin_api_xxx
|
|
156
|
+
export FAROS_API_KEY=your_faros_key
|
|
157
|
+
export FAROS_GRAPH=default
|
|
128
158
|
|
|
129
|
-
|
|
159
|
+
faros sync linear
|
|
160
|
+
```
|
|
130
161
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
│ s3 │ S3 │ ⚠ │ Missing credentials│
|
|
137
|
-
└────────┴────────┴────────┴────────────────────┘
|
|
162
|
+
Using CLI options:
|
|
163
|
+
```bash
|
|
164
|
+
faros sync linear \
|
|
165
|
+
--linear-api-key lin_api_xxx \
|
|
166
|
+
--graph default
|
|
138
167
|
```
|
|
139
168
|
|
|
140
|
-
|
|
169
|
+
Using config file (`faros.config.yaml`):
|
|
170
|
+
```yaml
|
|
171
|
+
# Never put API keys here - use environment variables!
|
|
172
|
+
url: https://prod.api.faros.ai
|
|
173
|
+
graph: default
|
|
174
|
+
origin: my-company-ci
|
|
141
175
|
|
|
142
|
-
|
|
176
|
+
sources:
|
|
177
|
+
linear:
|
|
178
|
+
cutoffDays: 30 # Fetch last 30 days
|
|
179
|
+
pageSize: 100 # Larger page size
|
|
180
|
+
```
|
|
143
181
|
|
|
144
|
-
|
|
182
|
+
Then run:
|
|
145
183
|
```bash
|
|
146
|
-
|
|
184
|
+
export LINEAR_API_KEY=lin_api_xxx
|
|
185
|
+
faros sync linear
|
|
147
186
|
```
|
|
148
187
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
- `--out-file <path>` - Export logs to file
|
|
188
|
+
Sync only recent issues (override config):
|
|
189
|
+
```bash
|
|
190
|
+
faros sync linear --cutoff-days 7
|
|
191
|
+
```
|
|
154
192
|
|
|
155
|
-
|
|
193
|
+
Preview configuration before syncing:
|
|
156
194
|
```bash
|
|
157
|
-
|
|
158
|
-
|
|
195
|
+
faros sync linear --preview
|
|
196
|
+
```
|
|
159
197
|
|
|
160
|
-
|
|
161
|
-
|
|
198
|
+
**What gets synced:**
|
|
199
|
+
- **Teams** - All teams in your Linear workspace
|
|
200
|
+
- **Projects** - All projects including leads and team assignments
|
|
201
|
+
- **Issues** - Issues updated within the cutoff period (default: 90 days)
|
|
202
|
+
- **Users** - All users in your workspace
|
|
162
203
|
|
|
163
|
-
|
|
164
|
-
|
|
204
|
+
**Requirements:**
|
|
205
|
+
- Docker must be running
|
|
206
|
+
- Linear API key with read permissions
|
|
207
|
+
- Faros API key and graph configured
|
|
165
208
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
209
|
+
**Notes:**
|
|
210
|
+
- Issues are filtered by update date using the `--cutoff-days` parameter
|
|
211
|
+
- The connector uses pagination to handle large datasets
|
|
212
|
+
- All timestamps and relationships are preserved
|
|
169
213
|
|
|
170
214
|
## Configuration
|
|
171
215
|
|
|
172
216
|
The CLI uses a two-file configuration approach:
|
|
173
217
|
|
|
174
|
-
###
|
|
218
|
+
### Environment Variables
|
|
175
219
|
|
|
176
|
-
|
|
220
|
+
The CLI can be configured entirely through environment variables, which is ideal for CI/CD pipelines where `.env` files are not available.
|
|
177
221
|
|
|
178
|
-
|
|
179
|
-
# Required
|
|
180
|
-
FAROS_API_KEY=your_faros_api_key_here
|
|
222
|
+
#### Required Environment Variables
|
|
181
223
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
224
|
+
| Variable | Description | Example |
|
|
225
|
+
|----------|-------------|---------|
|
|
226
|
+
| `FAROS_API_KEY` | Faros API key (required for all operations) | `your_faros_api_key_here` |
|
|
227
|
+
| `LINEAR_API_KEY` | Linear API key (required for `faros sync linear`) | `lin_api_xxx` |
|
|
185
228
|
|
|
186
|
-
|
|
187
|
-
LINEAR_API_KEY=your_linear_api_key
|
|
188
|
-
GITHUB_TOKEN=your_github_token
|
|
229
|
+
#### Optional Faros Configuration
|
|
189
230
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
231
|
+
| Variable | Description | Default | Example |
|
|
232
|
+
|----------|-------------|---------|---------|
|
|
233
|
+
| `FAROS_URL` | Faros API URL | `https://prod.api.faros.ai` | `https://prod.api.faros.ai` |
|
|
234
|
+
| `FAROS_GRAPH` | Target graph name | `default` | `my-graph` |
|
|
235
|
+
| `FAROS_ORIGIN` | Origin identifier for synced data | - | `my-company-ci` |
|
|
236
|
+
|
|
237
|
+
#### Logging and Debug
|
|
195
238
|
|
|
196
|
-
|
|
239
|
+
| Variable | Description | Values | Default |
|
|
240
|
+
|----------|-------------|--------|---------|
|
|
241
|
+
| `FAROS_LOG_LEVEL` | Log level | `debug`, `info`, `warn`, `error` | `info` |
|
|
242
|
+
| `FAROS_DEBUG` | Enable debug mode | `true`, `false` | `false` |
|
|
197
243
|
|
|
198
|
-
###
|
|
244
|
+
### Configuration File
|
|
199
245
|
|
|
200
246
|
Store non-sensitive configuration in `faros.config.yaml`:
|
|
201
247
|
|
|
@@ -203,20 +249,8 @@ Store non-sensitive configuration in `faros.config.yaml`:
|
|
|
203
249
|
# Faros API configuration
|
|
204
250
|
url: https://prod.api.faros.ai
|
|
205
251
|
graph: default
|
|
206
|
-
stagingGraph: default-staging
|
|
207
252
|
origin: my-company-ci
|
|
208
253
|
|
|
209
|
-
# Data sources (credentials in .env)
|
|
210
|
-
sources:
|
|
211
|
-
linear:
|
|
212
|
-
type: Linear
|
|
213
|
-
syncInterval: 1h
|
|
214
|
-
streams:
|
|
215
|
-
- issues
|
|
216
|
-
- projects
|
|
217
|
-
- teams
|
|
218
|
-
- users
|
|
219
|
-
|
|
220
254
|
# Default values for commands
|
|
221
255
|
defaults:
|
|
222
256
|
testSource: Jenkins
|
|
@@ -237,6 +271,76 @@ Configuration is loaded in this order (highest priority first):
|
|
|
237
271
|
|
|
238
272
|
**Config file search order**: `faros.config.yaml` → `faros.config.yml` → `faros.config.json` → `.farosrc.*`
|
|
239
273
|
|
|
274
|
+
### CI/CD Environments
|
|
275
|
+
|
|
276
|
+
In CI/CD pipelines where `.env` files cannot be used, configure the CLI entirely through environment variables stored as secrets in your CI/CD platform.
|
|
277
|
+
|
|
278
|
+
#### Setting Up Environment Variables
|
|
279
|
+
|
|
280
|
+
**GitHub Actions:**
|
|
281
|
+
1. Go to repository Settings → Secrets and variables → Actions
|
|
282
|
+
2. Add `FAROS_API_KEY` as a repository secret
|
|
283
|
+
3. Reference in workflows using `${{ secrets.FAROS_API_KEY }}`
|
|
284
|
+
|
|
285
|
+
**GitLab CI:**
|
|
286
|
+
1. Go to Settings → CI/CD → Variables
|
|
287
|
+
2. Add `FAROS_API_KEY` as a masked and protected variable
|
|
288
|
+
3. Variables are automatically available in pipeline jobs
|
|
289
|
+
|
|
290
|
+
**Jenkins:**
|
|
291
|
+
1. Go to Credentials → System → Global credentials
|
|
292
|
+
2. Add secret text with ID `faros-api-key`
|
|
293
|
+
3. Reference using `credentials('faros-api-key')`
|
|
294
|
+
|
|
295
|
+
**CircleCI:**
|
|
296
|
+
1. Go to Project Settings → Environment Variables
|
|
297
|
+
2. Add `FAROS_API_KEY`
|
|
298
|
+
3. Variables are automatically available in jobs
|
|
299
|
+
|
|
300
|
+
**Bitbucket Pipelines:**
|
|
301
|
+
1. Go to Repository settings → Pipelines → Repository variables
|
|
302
|
+
2. Add `FAROS_API_KEY` as a secured variable
|
|
303
|
+
3. Variables are automatically available in pipeline steps
|
|
304
|
+
|
|
305
|
+
#### Example: Minimal CI/CD Configuration
|
|
306
|
+
|
|
307
|
+
For most CI/CD use cases, only `FAROS_API_KEY` is required:
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
# Set this as a secret in your CI/CD platform
|
|
311
|
+
FAROS_API_KEY=your_api_key_here
|
|
312
|
+
|
|
313
|
+
# Optional: Override defaults
|
|
314
|
+
FAROS_GRAPH=production
|
|
315
|
+
FAROS_URL=https://prod.api.faros.ai
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
Then in your pipeline:
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
# Environment variables are automatically picked up
|
|
322
|
+
faros sync tests test-results/*.xml \
|
|
323
|
+
--source "Jenkins" \
|
|
324
|
+
--commit "GitHub://myorg/myrepo/$COMMIT_SHA"
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
#### Example: Full Configuration via Environment Variables
|
|
328
|
+
|
|
329
|
+
For advanced setups, all configuration can be provided via environment variables:
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
# Required
|
|
333
|
+
FAROS_API_KEY=your_api_key_here
|
|
334
|
+
|
|
335
|
+
# Faros configuration
|
|
336
|
+
FAROS_URL=https://prod.api.faros.ai
|
|
337
|
+
FAROS_GRAPH=production
|
|
338
|
+
FAROS_ORIGIN=github-actions
|
|
339
|
+
|
|
340
|
+
# Logging
|
|
341
|
+
FAROS_LOG_LEVEL=info
|
|
342
|
+
```
|
|
343
|
+
|
|
240
344
|
## Global Options
|
|
241
345
|
|
|
242
346
|
All commands support these global options:
|
|
@@ -249,9 +353,9 @@ All commands support these global options:
|
|
|
249
353
|
- `--json` - Output JSON (for scripting)
|
|
250
354
|
- `--no-color` - Disable colors
|
|
251
355
|
|
|
252
|
-
##
|
|
356
|
+
## Validation
|
|
253
357
|
|
|
254
|
-
The CLI supports
|
|
358
|
+
The CLI supports two verification modes before syncing to production:
|
|
255
359
|
|
|
256
360
|
### 1. `--validate` (Fast, Offline)
|
|
257
361
|
|
|
@@ -273,28 +377,7 @@ Would create:
|
|
|
273
377
|
Run without --validate to sync to Faros
|
|
274
378
|
```
|
|
275
379
|
|
|
276
|
-
### 2. `--
|
|
277
|
-
|
|
278
|
-
Sync to a staging graph for full verification:
|
|
279
|
-
|
|
280
|
-
```bash
|
|
281
|
-
faros sync tests *.xml --dry-run
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
**Output:**
|
|
285
|
-
```
|
|
286
|
-
⚠ Dry-run mode: syncing to staging graph 'default-staging'
|
|
287
|
-
|
|
288
|
-
Uploading |████████████████████| 100% | 24/24 suites
|
|
289
|
-
|
|
290
|
-
✓ Synced 24 test suites to staging graph
|
|
291
|
-
Graph: default-staging
|
|
292
|
-
View in Faros: https://app.faros.ai/default-staging/qa
|
|
293
|
-
|
|
294
|
-
To sync to production, run without --dry-run
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
### 3. `--preview` (Sample Preview)
|
|
380
|
+
### 2. `--preview` (Sample Preview)
|
|
298
381
|
|
|
299
382
|
Show sample records that would be created:
|
|
300
383
|
|
|
@@ -316,11 +399,25 @@ qa_TestExecution:
|
|
|
316
399
|
"stats": { "passed": 45, "failed": 0 }
|
|
317
400
|
}
|
|
318
401
|
|
|
319
|
-
Run
|
|
402
|
+
Run without --preview to sync to Faros
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
**Testing with Different Environments:**
|
|
406
|
+
|
|
407
|
+
To sync to different environments or graphs, use the `FAROS_GRAPH` environment variable or the `-g/--graph` flag:
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
# Sync to staging graph
|
|
411
|
+
FAROS_GRAPH=staging faros sync tests *.xml
|
|
412
|
+
|
|
413
|
+
# Or use the flag
|
|
414
|
+
faros sync tests *.xml --graph staging
|
|
320
415
|
```
|
|
321
416
|
|
|
322
417
|
## CI/CD Integration
|
|
323
418
|
|
|
419
|
+
The Faros CLI integrates seamlessly with CI/CD platforms using environment variables. Store `FAROS_API_KEY` as a secret in your CI/CD platform and reference it in your pipeline configuration.
|
|
420
|
+
|
|
324
421
|
### GitHub Actions
|
|
325
422
|
|
|
326
423
|
```yaml
|
|
@@ -350,6 +447,12 @@ environment {
|
|
|
350
447
|
FAROS_API_KEY = credentials('faros-api-key')
|
|
351
448
|
}
|
|
352
449
|
|
|
450
|
+
stage('Test') {
|
|
451
|
+
steps {
|
|
452
|
+
sh 'npm test'
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
353
456
|
stage('Sync Results') {
|
|
354
457
|
steps {
|
|
355
458
|
sh '''
|
|
@@ -359,6 +462,123 @@ stage('Sync Results') {
|
|
|
359
462
|
'''
|
|
360
463
|
}
|
|
361
464
|
}
|
|
465
|
+
|
|
466
|
+
stage('Report Build Status') {
|
|
467
|
+
steps {
|
|
468
|
+
sh '''
|
|
469
|
+
faros sync ci-cd build \
|
|
470
|
+
--status Success \
|
|
471
|
+
--commit "GitHub://org/repo/${GIT_COMMIT}" \
|
|
472
|
+
--run "Jenkins://org/pipeline/${BUILD_ID}"
|
|
473
|
+
'''
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
### GitLab CI
|
|
479
|
+
|
|
480
|
+
```yaml
|
|
481
|
+
test:
|
|
482
|
+
stage: test
|
|
483
|
+
script:
|
|
484
|
+
- npm test
|
|
485
|
+
artifacts:
|
|
486
|
+
reports:
|
|
487
|
+
junit: test-results/*.xml
|
|
488
|
+
|
|
489
|
+
sync_results:
|
|
490
|
+
stage: deploy
|
|
491
|
+
script:
|
|
492
|
+
- npm install -g @faros-fde-sandbox/cli
|
|
493
|
+
- |
|
|
494
|
+
faros sync tests test-results/*.xml \
|
|
495
|
+
--source "GitLab-CI" \
|
|
496
|
+
--commit "GitLab://${CI_PROJECT_PATH}/${CI_COMMIT_SHA}"
|
|
497
|
+
variables:
|
|
498
|
+
FAROS_API_KEY: $FAROS_API_KEY
|
|
499
|
+
when: always
|
|
500
|
+
|
|
501
|
+
report_build:
|
|
502
|
+
stage: deploy
|
|
503
|
+
script:
|
|
504
|
+
- |
|
|
505
|
+
faros sync ci-cd build \
|
|
506
|
+
--status Success \
|
|
507
|
+
--commit "GitLab://${CI_PROJECT_PATH}/${CI_COMMIT_SHA}" \
|
|
508
|
+
--run "GitLab-CI://${CI_PROJECT_PATH}/${CI_PIPELINE_ID}"
|
|
509
|
+
variables:
|
|
510
|
+
FAROS_API_KEY: $FAROS_API_KEY
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### CircleCI
|
|
514
|
+
|
|
515
|
+
```yaml
|
|
516
|
+
version: 2.1
|
|
517
|
+
|
|
518
|
+
jobs:
|
|
519
|
+
test:
|
|
520
|
+
docker:
|
|
521
|
+
- image: cimg/node:18.0
|
|
522
|
+
steps:
|
|
523
|
+
- checkout
|
|
524
|
+
- run:
|
|
525
|
+
name: Run Tests
|
|
526
|
+
command: npm test
|
|
527
|
+
- store_test_results:
|
|
528
|
+
path: test-results
|
|
529
|
+
- run:
|
|
530
|
+
name: Sync Test Results to Faros
|
|
531
|
+
when: always
|
|
532
|
+
command: |
|
|
533
|
+
npx @faros-fde-sandbox/cli sync tests test-results/*.xml \
|
|
534
|
+
--source "CircleCI" \
|
|
535
|
+
--commit "GitHub://${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/${CIRCLE_SHA1}"
|
|
536
|
+
environment:
|
|
537
|
+
FAROS_API_KEY: ${FAROS_API_KEY}
|
|
538
|
+
- run:
|
|
539
|
+
name: Report Build Status
|
|
540
|
+
command: |
|
|
541
|
+
npx @faros-fde-sandbox/cli sync ci-cd build \
|
|
542
|
+
--status Success \
|
|
543
|
+
--commit "GitHub://${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/${CIRCLE_SHA1}" \
|
|
544
|
+
--run "CircleCI://${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/${CIRCLE_BUILD_NUM}"
|
|
545
|
+
environment:
|
|
546
|
+
FAROS_API_KEY: ${FAROS_API_KEY}
|
|
547
|
+
|
|
548
|
+
workflows:
|
|
549
|
+
test-and-sync:
|
|
550
|
+
jobs:
|
|
551
|
+
- test
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
### Bitbucket Pipelines
|
|
555
|
+
|
|
556
|
+
```yaml
|
|
557
|
+
pipelines:
|
|
558
|
+
default:
|
|
559
|
+
- step:
|
|
560
|
+
name: Test
|
|
561
|
+
script:
|
|
562
|
+
- npm test
|
|
563
|
+
artifacts:
|
|
564
|
+
- test-results/**
|
|
565
|
+
- step:
|
|
566
|
+
name: Sync Results to Faros
|
|
567
|
+
script:
|
|
568
|
+
- npm install -g @faros-fde-sandbox/cli
|
|
569
|
+
- |
|
|
570
|
+
faros sync tests test-results/*.xml \
|
|
571
|
+
--source "Bitbucket-Pipelines" \
|
|
572
|
+
--commit "Bitbucket://${BITBUCKET_REPO_FULL_NAME}/${BITBUCKET_COMMIT}"
|
|
573
|
+
- |
|
|
574
|
+
faros sync ci-cd build \
|
|
575
|
+
--status Success \
|
|
576
|
+
--commit "Bitbucket://${BITBUCKET_REPO_FULL_NAME}/${BITBUCKET_COMMIT}" \
|
|
577
|
+
--run "Bitbucket-Pipelines://${BITBUCKET_REPO_FULL_NAME}/${BITBUCKET_BUILD_NUMBER}"
|
|
578
|
+
condition:
|
|
579
|
+
changesets:
|
|
580
|
+
includePaths:
|
|
581
|
+
- "**"
|
|
362
582
|
```
|
|
363
583
|
|
|
364
584
|
## URI Formats
|
|
@@ -413,6 +633,77 @@ npm test
|
|
|
413
633
|
npm run lint
|
|
414
634
|
```
|
|
415
635
|
|
|
636
|
+
### Testing
|
|
637
|
+
|
|
638
|
+
The CLI has comprehensive test coverage to ensure reliability:
|
|
639
|
+
|
|
640
|
+
```bash
|
|
641
|
+
# Run all tests
|
|
642
|
+
npm test
|
|
643
|
+
|
|
644
|
+
# Run tests in watch mode
|
|
645
|
+
npm run test:watch
|
|
646
|
+
|
|
647
|
+
# Run tests with coverage report
|
|
648
|
+
npm run test:coverage
|
|
649
|
+
|
|
650
|
+
# Run tests with UI
|
|
651
|
+
npm run test:ui
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
**Test Structure:**
|
|
655
|
+
- `src/**/*.test.ts` - Unit and integration tests alongside source files
|
|
656
|
+
- `test/fixtures/` - Sample test result files for various formats
|
|
657
|
+
- `test/utils/` - Test utilities and helpers
|
|
658
|
+
|
|
659
|
+
**Coverage Thresholds:**
|
|
660
|
+
- Core modules (config, API client, logger): >80% coverage
|
|
661
|
+
- Critical paths enforce per-file thresholds
|
|
662
|
+
- Overall project: >25% (command handlers require E2E testing)
|
|
663
|
+
|
|
664
|
+
**What's Tested:**
|
|
665
|
+
- ✅ Configuration loading and priority (CLI > env > file > defaults)
|
|
666
|
+
- ✅ API client with retry logic and error handling
|
|
667
|
+
- ✅ Logger with redaction of sensitive data
|
|
668
|
+
- ✅ Test result parsing (JUnit, TestNG, xUnit, Cucumber, Mocha)
|
|
669
|
+
- ✅ CI/CD event creation and validation
|
|
670
|
+
- ✅ URI format validation
|
|
671
|
+
- ✅ Validation and preview modes
|
|
672
|
+
|
|
673
|
+
**Continuous Integration:**
|
|
674
|
+
Tests run automatically on every push and pull request via GitHub Actions. Coverage reports are uploaded to Codecov.
|
|
675
|
+
|
|
676
|
+
**Test Result Syncing:**
|
|
677
|
+
Test results are automatically synced to Faros AI after every test run on the `main` branch. This provides observability into test health, trends, and failures over time. Results are synced using the CLI itself:
|
|
678
|
+
|
|
679
|
+
```bash
|
|
680
|
+
faros sync tests test-results/junit.xml \
|
|
681
|
+
--source "GitHub-Actions" \
|
|
682
|
+
--type "Unit" \
|
|
683
|
+
--commit "GitHub://faros-fde/faros-cli/$COMMIT_SHA"
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
View synced test results in the Faros UI under the `qa_TestExecution` model.
|
|
687
|
+
|
|
688
|
+
### End-to-End Testing
|
|
689
|
+
|
|
690
|
+
E2E tests validate the full CLI workflow by actually syncing test results to Faros AI.
|
|
691
|
+
|
|
692
|
+
**Run E2E tests:**
|
|
693
|
+
|
|
694
|
+
```bash
|
|
695
|
+
# Run E2E tests
|
|
696
|
+
FAROS_API_KEY=xxx ./scripts/e2e-test-sync.sh
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
**What's tested:**
|
|
700
|
+
- ✅ Parsing test result files (JUnit, TestNG, Mocha)
|
|
701
|
+
- ✅ Data validation and transformation
|
|
702
|
+
- ✅ API communication with Faros
|
|
703
|
+
- ✅ Error handling and reporting
|
|
704
|
+
|
|
705
|
+
**See the full guide:** [docs/e2e-testing.md](docs/e2e-testing.md)
|
|
706
|
+
|
|
416
707
|
### Publishing
|
|
417
708
|
|
|
418
709
|
See [PUBLISHING.md](PUBLISHING.md) for instructions on publishing new versions to npm.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ci-cd.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/ci-cd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"ci-cd.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/ci-cd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgHpC,wBAAgB,eAAe,IAAI,OAAO,CAmDzC"}
|