x-fidelity 3.0.4 → 3.1.1

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.
Files changed (56) hide show
  1. package/.github/workflows/documentation.yml +34 -0
  2. package/CHANGELOG.md +39 -0
  3. package/README.md +1 -0
  4. package/dist/plugins/xfiPluginSimpleExample/facts/customFact.d.ts +4 -0
  5. package/dist/plugins/xfiPluginSimpleExample/facts/customFact.js +14 -2
  6. package/dist/plugins/xfiPluginSimpleExample/operators/customOperator.d.ts +4 -0
  7. package/dist/plugins/xfiPluginSimpleExample/operators/customOperator.js +23 -1
  8. package/eslint.config.js +1 -1
  9. package/package.json +1 -1
  10. package/src/plugins/xfiPluginSimpleExample/facts/customFact.ts +13 -2
  11. package/src/plugins/xfiPluginSimpleExample/operators/customOperator.ts +25 -1
  12. package/website/babel.config.js +3 -0
  13. package/website/docs/archetypes.md +150 -0
  14. package/website/docs/ci-cd/github-actions.md +156 -0
  15. package/website/docs/ci-cd/gitlab-ci.md +132 -0
  16. package/website/docs/ci-cd/jenkins.md +157 -0
  17. package/website/docs/ci-cd/overview.md +98 -0
  18. package/website/docs/config-server.md +134 -0
  19. package/website/docs/contributing.md +88 -0
  20. package/website/docs/docker-deployment.md +221 -0
  21. package/website/docs/environment-variables.md +101 -0
  22. package/website/docs/exemptions.md +136 -0
  23. package/website/docs/facts.md +169 -0
  24. package/website/docs/getting-started.md +91 -0
  25. package/website/docs/github-webhook-endpoints.md +74 -0
  26. package/website/docs/github-webhooks.md +84 -0
  27. package/website/docs/intro.md +85 -0
  28. package/website/docs/key-concepts.md +156 -0
  29. package/website/docs/local-config.md +152 -0
  30. package/website/docs/local-configuration.md +127 -0
  31. package/website/docs/openai-integration.md +202 -0
  32. package/website/docs/operators.md +196 -0
  33. package/website/docs/plugins/best-practices.md +239 -0
  34. package/website/docs/plugins/creating-plugins.md +211 -0
  35. package/website/docs/plugins/overview.md +113 -0
  36. package/website/docs/plugins/plugin-examples.md +194 -0
  37. package/website/docs/remote-config.md +121 -0
  38. package/website/docs/remote-configuration.md +120 -0
  39. package/website/docs/rules.md +183 -0
  40. package/website/docs/security.md +125 -0
  41. package/website/docs/telemetry.md +111 -0
  42. package/website/docs/xfi-config.md +129 -0
  43. package/website/docusaurus.config.js +74 -0
  44. package/website/img/favicon.ico +0 -0
  45. package/website/img/logo.svg +652 -0
  46. package/website/package.json +49 -0
  47. package/website/sidebars.js +63 -0
  48. package/website/src/components/HomepageFeatures/index.tsx +90 -0
  49. package/website/src/components/HomepageFeatures/styles.module.css +11 -0
  50. package/website/src/css/custom.css +30 -0
  51. package/website/src/pages/index.module.css +32 -0
  52. package/website/src/pages/index.tsx +60 -0
  53. package/website/static/img/favicon.ico +0 -0
  54. package/website/static/img/x-fi.png +0 -0
  55. package/website/tsconfig.json +8 -0
  56. package/website/yarn.lock +9953 -0
@@ -0,0 +1,34 @@
1
+ name: Documentation
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ deploy:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v3
13
+ - uses: actions/setup-node@v3
14
+ with:
15
+ node-version: 18
16
+ cache: yarn
17
+
18
+ - name: Install dependencies
19
+ run: |
20
+ cd website
21
+ yarn install --frozen-lockfile
22
+
23
+ - name: Build website
24
+ run: |
25
+ cd website
26
+ yarn build
27
+
28
+ - name: Deploy to GitHub Pages
29
+ uses: peaceiris/actions-gh-pages@v3
30
+ with:
31
+ github_token: ${{ secrets.GITHUB_TOKEN }}
32
+ publish_dir: ./website/build
33
+ user_name: github-actions[bot]
34
+ user_email: 41898282+github-actions[bot]@users.noreply.github.com
package/CHANGELOG.md CHANGED
@@ -1,3 +1,42 @@
1
+ ## [3.1.1](https://github.com/zotoio/x-fidelity/compare/v3.1.0...v3.1.1) (2025-02-20)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add getting-started link to navbar with correct path ([48300a7](https://github.com/zotoio/x-fidelity/commit/48300a7e78f454fdc24d6d9013eff0bd22d9fc86))
7
+ * docgen fix ([6e657fb](https://github.com/zotoio/x-fidelity/commit/6e657fbbb8b98013c1ce479c365ed7d205a88d57))
8
+ * update broken documentation links and sidebar structure ([e8a83ae](https://github.com/zotoio/x-fidelity/commit/e8a83ae12ee17fa74533df254dcb6908c462c52b))
9
+ * update navbar link to point to intro page instead of getting-started ([a0b997e](https://github.com/zotoio/x-fidelity/commit/a0b997ecce49d66a57860a9f081dd65d9bc91bfb))
10
+
11
+ # [3.1.0](https://github.com/zotoio/x-fidelity/compare/v3.0.4...v3.1.0) (2025-02-20)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * add missing typedoc dependency for documentation generation ([1152c4d](https://github.com/zotoio/x-fidelity/commit/1152c4d71829ea642dd68d671102433bc9e0ce03))
17
+ * correct broken documentation links ([b48b474](https://github.com/zotoio/x-fidelity/commit/b48b47406fac82ac5f6f0775927b1b99cbdd5d5f))
18
+ * correct broken documentation links in website files ([ed17172](https://github.com/zotoio/x-fidelity/commit/ed171720020e610e2c27b0a953adabcc43037511))
19
+ * correct docId path in navbar configuration ([00985cc](https://github.com/zotoio/x-fidelity/commit/00985cc10cc42e0e016d4459ef3bf54931e10959))
20
+ * **docs and minor fixes:** docusaurus site beta ([935dd1f](https://github.com/zotoio/x-fidelity/commit/935dd1f2a9125ef6c9e1bda86a6401a20e87d020))
21
+ * handle null and undefined equality in customOperator ([9ed96e4](https://github.com/zotoio/x-fidelity/commit/9ed96e4ae46899943c9515e36622627f00aac32d))
22
+ * update broken documentation links and references ([8de8ecc](https://github.com/zotoio/x-fidelity/commit/8de8ecc8aea5b5e5412a34daf72c281e5f9340b4))
23
+ * update favicon path to use x-fi.png logo ([161c8f7](https://github.com/zotoio/x-fidelity/commit/161c8f786fd8139628f37165f96b7cff6b021db7))
24
+ * update prism theme import syntax for compatibility ([e6b6380](https://github.com/zotoio/x-fidelity/commit/e6b638053d55272613f6f715d4c2e87dac535b62))
25
+ * update relative paths in documentation links ([f3eca1f](https://github.com/zotoio/x-fidelity/commit/f3eca1fc1be53caeb5e506a4c8f42b372f81e1b2))
26
+ * update TypeDoc plugin configuration and dependencies ([078a799](https://github.com/zotoio/x-fidelity/commit/078a799fe283666a4c6384199f8a1b2420621604))
27
+
28
+
29
+ ### Features
30
+
31
+ * add homepage features component and styles ([8a7a601](https://github.com/zotoio/x-fidelity/commit/8a7a6017834c78f52079bd0f7d471047080c0f28))
32
+ * add initial Docusaurus documentation setup ([3c553e1](https://github.com/zotoio/x-fidelity/commit/3c553e1f0b55601b5f1568bd707a621f509b9d41))
33
+ * add initial Docusaurus website configuration files ([b6c8e02](https://github.com/zotoio/x-fidelity/commit/b6c8e02cac1465cb988f67e2bb2eba3e0cb04fb0))
34
+ * add landing page with features overview and API reference link ([af8c760](https://github.com/zotoio/x-fidelity/commit/af8c760c7b04e454310cc3f43524c3987d3713b6))
35
+ * add landing page with project description and API reference link ([08c6232](https://github.com/zotoio/x-fidelity/commit/08c6232a3a45448d9fe22aabb5f23764e81b53bd))
36
+ * add Mermaid diagram support to documentation ([3894a43](https://github.com/zotoio/x-fidelity/commit/3894a438446d73d55b5d7efee2744d4452020f17))
37
+ * enhance TypeDoc plugin configuration for complete API docs ([124b845](https://github.com/zotoio/x-fidelity/commit/124b84539dc31cb5c9a8ca9d12795434d98de8d2))
38
+ * update logo display in navbar and homepage ([f880c1f](https://github.com/zotoio/x-fidelity/commit/f880c1fc3463221aa7670f110447a7391fd39a70))
39
+
1
40
  ## [3.0.4](https://github.com/zotoio/x-fidelity/compare/v3.0.3...v3.0.4) (2025-02-19)
2
41
 
3
42
 
package/README.md CHANGED
@@ -436,6 +436,7 @@ Options:
436
436
  -l, --localConfigPath [path] Path to local archetype config and rules
437
437
  -j, --jsonTTL [minutes] Set the server JSON cache TTL in minutes (default: "10")
438
438
  -e, --extensions <modules...> Space-separated list of npm module names to load as external plugin extensions
439
+ -x, --examine Validate archetype config only
439
440
  -v, --version Output the version number of xfidelity
440
441
  -h, --help Display help for command
441
442
  ```
@@ -1,2 +1,6 @@
1
1
  import { FactDefn } from '../../../types/typeDefs';
2
+ /**
3
+ * Example custom fact that returns a simple data object
4
+ * Demonstrates basic fact implementation pattern
5
+ */
2
6
  export declare const customFact: FactDefn;
@@ -10,9 +10,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.customFact = void 0;
13
+ const logger_1 = require("../../../utils/logger");
14
+ /**
15
+ * Example custom fact that returns a simple data object
16
+ * Demonstrates basic fact implementation pattern
17
+ */
13
18
  exports.customFact = {
14
19
  name: 'customFact',
15
- fn: () => __awaiter(void 0, void 0, void 0, function* () {
16
- return { result: 'custom fact data' };
20
+ fn: (params) => __awaiter(void 0, void 0, void 0, function* () {
21
+ try {
22
+ logger_1.logger.debug('Executing customFact');
23
+ return { result: 'custom fact data' };
24
+ }
25
+ catch (error) {
26
+ logger_1.logger.error(`Error in customFact: ${error}`);
27
+ throw error;
28
+ }
17
29
  })
18
30
  };
@@ -1,2 +1,6 @@
1
1
  import { OperatorDefn } from '../../../types/typeDefs';
2
+ /**
3
+ * Example custom operator that performs simple equality comparison
4
+ * Demonstrates basic operator implementation pattern
5
+ */
2
6
  export declare const customOperator: OperatorDefn;
@@ -1,9 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.customOperator = void 0;
4
+ const logger_1 = require("../../../utils/logger");
5
+ /**
6
+ * Example custom operator that performs simple equality comparison
7
+ * Demonstrates basic operator implementation pattern
8
+ */
4
9
  exports.customOperator = {
5
10
  name: 'customOperator',
6
11
  fn: (factValue, expectedValue) => {
7
- return factValue === expectedValue;
12
+ try {
13
+ logger_1.logger.debug('Executing customOperator', { factValue, expectedValue });
14
+ // Special case: if both values are null or both are undefined, they're equal
15
+ if ((factValue === null && expectedValue === null) ||
16
+ (factValue === undefined && expectedValue === undefined)) {
17
+ return true;
18
+ }
19
+ // If only one value is null/undefined but not both, they're not equal
20
+ if (factValue === undefined || factValue === null) {
21
+ logger_1.logger.warn('customOperator received undefined/null factValue');
22
+ return false;
23
+ }
24
+ return factValue === expectedValue;
25
+ }
26
+ catch (error) {
27
+ logger_1.logger.error(`Error in customOperator: ${error}`);
28
+ return false;
29
+ }
8
30
  }
9
31
  };
package/eslint.config.js CHANGED
@@ -26,6 +26,6 @@ module.exports = [
26
26
  }
27
27
  },
28
28
  {
29
- ignores: ["node_modules/", "dist/", "build/", "coverage/"],
29
+ ignores: ["node_modules/", "dist/", "build/", "coverage/", "website/"],
30
30
  }
31
31
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-fidelity",
3
- "version": "3.0.4",
3
+ "version": "3.1.1",
4
4
  "description": "cli for opinionated framework adherence checks",
5
5
  "main": "dist/index",
6
6
  "types": "dist/index.d.ts",
@@ -1,8 +1,19 @@
1
1
  import { FactDefn } from '../../../types/typeDefs';
2
+ import { logger } from '../../../utils/logger';
2
3
 
4
+ /**
5
+ * Example custom fact that returns a simple data object
6
+ * Demonstrates basic fact implementation pattern
7
+ */
3
8
  export const customFact: FactDefn = {
4
9
  name: 'customFact',
5
- fn: async () => {
6
- return { result: 'custom fact data' };
10
+ fn: async (params) => {
11
+ try {
12
+ logger.debug('Executing customFact');
13
+ return { result: 'custom fact data' };
14
+ } catch (error) {
15
+ logger.error(`Error in customFact: ${error}`);
16
+ throw error;
17
+ }
7
18
  }
8
19
  };
@@ -1,8 +1,32 @@
1
1
  import { OperatorDefn } from '../../../types/typeDefs';
2
+ import { logger } from '../../../utils/logger';
2
3
 
4
+ /**
5
+ * Example custom operator that performs simple equality comparison
6
+ * Demonstrates basic operator implementation pattern
7
+ */
3
8
  export const customOperator: OperatorDefn = {
4
9
  name: 'customOperator',
5
10
  fn: (factValue: any, expectedValue: any) => {
6
- return factValue === expectedValue;
11
+ try {
12
+ logger.debug('Executing customOperator', { factValue, expectedValue });
13
+
14
+ // Special case: if both values are null or both are undefined, they're equal
15
+ if ((factValue === null && expectedValue === null) ||
16
+ (factValue === undefined && expectedValue === undefined)) {
17
+ return true;
18
+ }
19
+
20
+ // If only one value is null/undefined but not both, they're not equal
21
+ if (factValue === undefined || factValue === null) {
22
+ logger.warn('customOperator received undefined/null factValue');
23
+ return false;
24
+ }
25
+
26
+ return factValue === expectedValue;
27
+ } catch (error) {
28
+ logger.error(`Error in customOperator: ${error}`);
29
+ return false;
30
+ }
7
31
  }
8
32
  };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
3
+ };
@@ -0,0 +1,150 @@
1
+ ---
2
+ sidebar_position: 4
3
+ ---
4
+
5
+ # Archetypes
6
+
7
+ Archetypes are predefined configuration templates that define how x-fidelity should analyze different types of projects.
8
+
9
+ ## What is an Archetype?
10
+
11
+ An archetype defines:
12
+ - Rules to apply
13
+ - Required directory structure
14
+ - Minimum dependency versions
15
+ - File patterns to analyze
16
+ - Custom operators and facts to use
17
+
18
+ ## Archetype Structure
19
+
20
+ ```json
21
+ {
22
+ "name": "node-fullstack",
23
+ "rules": [
24
+ "sensitiveLogging-iterative",
25
+ "outdatedFramework-global",
26
+ "noDatabases-iterative"
27
+ ],
28
+ "operators": [
29
+ "fileContains",
30
+ "outdatedFramework",
31
+ "nonStandardDirectoryStructure"
32
+ ],
33
+ "facts": [
34
+ "repoFilesystemFacts",
35
+ "repoDependencyFacts"
36
+ ],
37
+ "config": {
38
+ "minimumDependencyVersions": {
39
+ "react": ">=17.0.0",
40
+ "typescript": "^4.0.0"
41
+ },
42
+ "standardStructure": {
43
+ "src": {
44
+ "components": null,
45
+ "utils": null
46
+ }
47
+ },
48
+ "blacklistPatterns": [
49
+ ".*\\/\\..*",
50
+ ".*\\.(log|lock)$",
51
+ ".*\\/(dist|build|node_modules)(\\/.*|$)"
52
+ ],
53
+ "whitelistPatterns": [
54
+ ".*\\.(ts|tsx|js|jsx)$"
55
+ ]
56
+ }
57
+ }
58
+ ```
59
+
60
+ ## Configuration Options
61
+
62
+ ### Rules
63
+
64
+ The `rules` array lists all rules that should be applied to projects using this archetype. Rules can be:
65
+ - **Global**: Applied once per repository (suffix `-global`)
66
+ - **Iterative**: Applied to each matching file (suffix `-iterative`)
67
+
68
+ ### Operators
69
+
70
+ The `operators` array defines which operators are available for use in rules. Common operators include:
71
+ - `fileContains`: Check file contents for patterns
72
+ - `outdatedFramework`: Check dependency versions
73
+ - `nonStandardDirectoryStructure`: Validate directory structure
74
+
75
+ ### Facts
76
+
77
+ The `facts` array specifies which fact providers to use. Built-in facts include:
78
+ - `repoFilesystemFacts`: File system information
79
+ - `repoDependencyFacts`: Dependency version data
80
+ - `openaiAnalysisFacts`: AI-powered analysis results
81
+
82
+ ### Config Section
83
+
84
+ #### minimumDependencyVersions
85
+
86
+ Defines minimum required versions for dependencies using semver ranges:
87
+ ```json
88
+ "minimumDependencyVersions": {
89
+ "react": ">=17.0.0",
90
+ "typescript": "^4.0.0"
91
+ }
92
+ ```
93
+
94
+ #### standardStructure
95
+
96
+ Defines the expected directory structure:
97
+ ```json
98
+ "standardStructure": {
99
+ "src": {
100
+ "components": null,
101
+ "utils": null
102
+ }
103
+ }
104
+ ```
105
+ - Use `null` for leaf directories
106
+ - Nested objects for subdirectories
107
+
108
+ #### blacklistPatterns
109
+
110
+ Array of regex patterns for files to exclude:
111
+ ```json
112
+ "blacklistPatterns": [
113
+ ".*\\/\\..*", // Hidden files
114
+ ".*\\.(log|lock)$", // Log and lock files
115
+ ".*\\/(dist|build|node_modules)(\\/.*|$)" // Build directories
116
+ ]
117
+ ```
118
+
119
+ #### whitelistPatterns
120
+
121
+ Array of regex patterns for files to include:
122
+ ```json
123
+ "whitelistPatterns": [
124
+ ".*\\.(ts|tsx|js|jsx)$" // TypeScript and JavaScript files
125
+ ]
126
+ ```
127
+
128
+ ## Creating Custom Archetypes
129
+
130
+ 1. Create a new JSON file named `your-archetype.json`
131
+ 2. Define required sections: name, rules, operators, facts, and config
132
+ 3. Place in your local config directory or on your config server
133
+ 4. Use with the `-a` or `--archetype` option:
134
+ ```bash
135
+ xfidelity . -a your-archetype
136
+ ```
137
+
138
+ ## Best Practices
139
+
140
+ 1. **Naming Convention**: Use descriptive names like `node-fullstack` or `java-microservice`
141
+ 2. **Rule Selection**: Include both global and iterative rules for comprehensive checks
142
+ 3. **Dependency Management**: Keep minimum versions up to date with security patches
143
+ 4. **File Patterns**: Be specific with whitelist/blacklist patterns
144
+ 5. **Directory Structure**: Define structures that match your organization's standards
145
+
146
+ ## Next Steps
147
+
148
+ - Learn about [Rules](rules)
149
+ - Explore [Operators](operators)
150
+ - Understand [Facts](facts)
@@ -0,0 +1,156 @@
1
+ ---
2
+ sidebar_position: 2
3
+ ---
4
+
5
+ # GitHub Actions Integration
6
+
7
+ This guide shows how to integrate x-fidelity into your GitHub Actions workflows.
8
+
9
+ ## Basic Workflow
10
+
11
+ Create `.github/workflows/x-fidelity.yml`:
12
+
13
+ ```yaml
14
+ name: x-fidelity
15
+
16
+ on:
17
+ push:
18
+ branches: [ main ]
19
+ pull_request:
20
+ branches: [ main ]
21
+
22
+ jobs:
23
+ check:
24
+ runs-on: ubuntu-latest
25
+
26
+ steps:
27
+ - uses: actions/checkout@v3
28
+
29
+ - name: Setup Node.js
30
+ uses: actions/setup-node@v3
31
+ with:
32
+ node-version: '18'
33
+ cache: 'yarn'
34
+
35
+ - name: Install x-fidelity
36
+ run: |
37
+ yarn global add x-fidelity
38
+ echo "$(yarn global bin)" >> $GITHUB_PATH
39
+
40
+ - name: Run x-fidelity
41
+ env:
42
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
43
+ XFI_SHARED_SECRET: ${{ secrets.XFI_SHARED_SECRET }}
44
+ run: xfidelity . --configServer https://config-server.example.com
45
+ ```
46
+
47
+ ## Advanced Configuration
48
+
49
+ ### With OpenAI Integration
50
+
51
+ ```yaml
52
+ - name: Run x-fidelity with OpenAI
53
+ env:
54
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
55
+ OPENAI_MODEL: 'gpt-4'
56
+ run: xfidelity . -o true
57
+ ```
58
+
59
+ ### With Local Config
60
+
61
+ ```yaml
62
+ - name: Run x-fidelity with local config
63
+ run: xfidelity . --localConfigPath ./config
64
+ ```
65
+
66
+ ### With Custom Archetype
67
+
68
+ ```yaml
69
+ - name: Run x-fidelity with custom archetype
70
+ run: xfidelity . --archetype java-microservice
71
+ ```
72
+
73
+ ## GitHub Actions Specific Features
74
+
75
+ ### Caching Dependencies
76
+
77
+ ```yaml
78
+ - uses: actions/cache@v3
79
+ with:
80
+ path: |
81
+ **/node_modules
82
+ $(yarn cache dir)
83
+ key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
84
+ restore-keys: |
85
+ ${{ runner.os }}-yarn-
86
+ ```
87
+
88
+ ### Matrix Testing
89
+
90
+ ```yaml
91
+ jobs:
92
+ check:
93
+ strategy:
94
+ matrix:
95
+ archetype: [node-fullstack, java-microservice]
96
+
97
+ steps:
98
+ - name: Run x-fidelity
99
+ run: xfidelity . --archetype ${{ matrix.archetype }}
100
+ ```
101
+
102
+ ### Pull Request Comments
103
+
104
+ ```yaml
105
+ - name: Comment PR
106
+ if: github.event_name == 'pull_request'
107
+ uses: actions/github-script@v6
108
+ with:
109
+ script: |
110
+ const fs = require('fs');
111
+ const results = JSON.parse(fs.readFileSync('results.json', 'utf8'));
112
+ github.rest.issues.createComment({
113
+ issue_number: context.issue.number,
114
+ owner: context.repo.owner,
115
+ repo: context.repo.repo,
116
+ body: `x-fidelity results:\n\`\`\`\n${JSON.stringify(results, null, 2)}\n\`\`\``
117
+ });
118
+ ```
119
+
120
+ ## Environment Variables
121
+
122
+ Set these in your repository secrets:
123
+
124
+ - `OPENAI_API_KEY`: For OpenAI integration
125
+ - `XFI_SHARED_SECRET`: For config server authentication
126
+ - `CONFIG_SERVER_URL`: Your config server URL
127
+
128
+ ## Best Practices
129
+
130
+ 1. **Secrets Management**: Use GitHub Secrets for sensitive data
131
+ 2. **Caching**: Implement proper caching strategy
132
+ 3. **Versioning**: Pin action and dependency versions
133
+ 4. **Error Handling**: Add proper error handling
134
+ 5. **Notifications**: Configure notifications for failures
135
+
136
+ ## Example Projects
137
+
138
+ Check out these example repositories:
139
+ - [x-fidelity-node-example](https://github.com/example/x-fidelity-node)
140
+ - [x-fidelity-java-example](https://github.com/example/x-fidelity-java)
141
+
142
+ ## Troubleshooting
143
+
144
+ Common issues and solutions:
145
+
146
+ 1. **Authentication Failures**:
147
+ - Check secret configuration
148
+ - Verify environment variables
149
+
150
+ 2. **Timeout Issues**:
151
+ - Increase GitHub Actions timeout
152
+ - Optimize analysis scope
153
+
154
+ 3. **Cache Problems**:
155
+ - Clear cache
156
+ - Update cache key
@@ -0,0 +1,132 @@
1
+ ---
2
+ sidebar_position: 3
3
+ ---
4
+
5
+ # GitLab CI Integration
6
+
7
+ This guide shows how to integrate x-fidelity into your GitLab CI/CD pipelines.
8
+
9
+ ## Basic Pipeline Configuration
10
+
11
+ Create `.gitlab-ci.yml` in your repository:
12
+
13
+ ```yaml
14
+ image: node:18
15
+
16
+ stages:
17
+ - test
18
+
19
+ x-fidelity:
20
+ stage: test
21
+ before_script:
22
+ - yarn global add x-fidelity
23
+ - export PATH="$PATH:$(yarn global bin)"
24
+ script:
25
+ - xfidelity . --configServer https://config-server.example.com
26
+ variables:
27
+ OPENAI_API_KEY: $OPENAI_API_KEY
28
+ XFI_SHARED_SECRET: $XFI_SHARED_SECRET
29
+ ```
30
+
31
+ ## Advanced Configuration
32
+
33
+ ### With OpenAI Integration
34
+
35
+ ```yaml
36
+ x-fidelity:
37
+ script:
38
+ - xfidelity . -o true
39
+ variables:
40
+ OPENAI_API_KEY: $OPENAI_API_KEY
41
+ OPENAI_MODEL: 'gpt-4'
42
+ ```
43
+
44
+ ### With Local Config
45
+
46
+ ```yaml
47
+ x-fidelity:
48
+ script:
49
+ - xfidelity . --localConfigPath ./config
50
+ ```
51
+
52
+ ### With Custom Archetype
53
+
54
+ ```yaml
55
+ x-fidelity:
56
+ script:
57
+ - xfidelity . --archetype java-microservice
58
+ ```
59
+
60
+ ## GitLab CI Specific Features
61
+
62
+ ### Caching Dependencies
63
+
64
+ ```yaml
65
+ x-fidelity:
66
+ cache:
67
+ key: ${CI_COMMIT_REF_SLUG}
68
+ paths:
69
+ - node_modules/
70
+ - .yarn
71
+ ```
72
+
73
+ ### Matrix Testing
74
+
75
+ ```yaml
76
+ x-fidelity:
77
+ parallel:
78
+ matrix:
79
+ - ARCHETYPE: [node-fullstack, java-microservice]
80
+ script:
81
+ - xfidelity . --archetype $ARCHETYPE
82
+ ```
83
+
84
+ ### Pipeline Artifacts
85
+
86
+ ```yaml
87
+ x-fidelity:
88
+ artifacts:
89
+ reports:
90
+ junit: results.xml
91
+ paths:
92
+ - results.json
93
+ expire_in: 1 week
94
+ ```
95
+
96
+ ## Environment Variables
97
+
98
+ Set these in your GitLab CI/CD variables:
99
+
100
+ - `OPENAI_API_KEY`: For OpenAI integration
101
+ - `XFI_SHARED_SECRET`: For config server authentication
102
+ - `CONFIG_SERVER_URL`: Your config server URL
103
+
104
+ ## Best Practices
105
+
106
+ 1. **Secrets Management**: Use GitLab CI/CD variables for sensitive data
107
+ 2. **Caching**: Implement proper caching strategy
108
+ 3. **Versioning**: Pin dependency versions
109
+ 4. **Error Handling**: Add proper error handling
110
+ 5. **Notifications**: Configure notifications for failures
111
+
112
+ ## Example Projects
113
+
114
+ Check out these example repositories:
115
+ - [x-fidelity-node-example](https://gitlab.com/example/x-fidelity-node)
116
+ - [x-fidelity-java-example](https://gitlab.com/example/x-fidelity-java)
117
+
118
+ ## Troubleshooting
119
+
120
+ Common issues and solutions:
121
+
122
+ 1. **Authentication Failures**:
123
+ - Check variable configuration
124
+ - Verify environment variables
125
+
126
+ 2. **Timeout Issues**:
127
+ - Increase job timeout
128
+ - Optimize analysis scope
129
+
130
+ 3. **Cache Problems**:
131
+ - Clear cache
132
+ - Update cache key