@el-j/magic-helix-core 4.0.0-beta.1 → 4.0.0-beta.3

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 (160) hide show
  1. package/dist/index-B88j4AyE.js +13 -0
  2. package/dist/index-B88j4AyE.js.map +1 -0
  3. package/dist/index-CY-pQbuu.cjs +2 -0
  4. package/dist/index-CY-pQbuu.cjs.map +1 -0
  5. package/dist/index.cjs +75 -1
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.ts +0 -1
  8. package/dist/index.mjs +2234 -51
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/pattern-combiner.d.ts +1 -1
  11. package/dist/plugin-loader.d.ts +7 -1
  12. package/package.json +4 -4
  13. package/dist/BasePlugin-6wv0hYJ9.js +0 -98
  14. package/dist/BasePlugin-6wv0hYJ9.js.map +0 -1
  15. package/dist/BasePlugin-odQJAKA-.cjs +0 -2
  16. package/dist/BasePlugin-odQJAKA-.cjs.map +0 -1
  17. package/dist/builtin-plugins/base/BasePlugin.d.ts +0 -69
  18. package/dist/builtin-plugins/csharp/index.d.ts +0 -20
  19. package/dist/builtin-plugins/go/index.d.ts +0 -23
  20. package/dist/builtin-plugins/index.d.ts +0 -15
  21. package/dist/builtin-plugins/java/index.d.ts +0 -22
  22. package/dist/builtin-plugins/nodejs/index.d.ts +0 -44
  23. package/dist/builtin-plugins/php/index.d.ts +0 -20
  24. package/dist/builtin-plugins/python/index.d.ts +0 -27
  25. package/dist/builtin-plugins/ruby/index.d.ts +0 -20
  26. package/dist/builtin-plugins/rust/index.d.ts +0 -53
  27. package/dist/builtin-plugins/swift/index.d.ts +0 -22
  28. package/dist/default_templates/angular/angular-core.md +0 -19
  29. package/dist/default_templates/architecture/codeowners.md +0 -123
  30. package/dist/default_templates/architecture/monorepo.md +0 -146
  31. package/dist/default_templates/architecture/nx.md +0 -122
  32. package/dist/default_templates/architecture/turborepo.md +0 -114
  33. package/dist/default_templates/ci/github-actions.md +0 -268
  34. package/dist/default_templates/ci/gitlab-ci.md +0 -330
  35. package/dist/default_templates/containers/docker-multistage.md +0 -120
  36. package/dist/default_templates/containers/kubernetes-deploy.md +0 -210
  37. package/dist/default_templates/devops/docker-compose.md +0 -111
  38. package/dist/default_templates/devops/docker-dockerfile.md +0 -94
  39. package/dist/default_templates/devops/github-actions.md +0 -160
  40. package/dist/default_templates/devops/gitlab-ci.md +0 -210
  41. package/dist/default_templates/dotnet/framework-aspnetcore.md +0 -205
  42. package/dist/default_templates/dotnet/framework-blazor.md +0 -271
  43. package/dist/default_templates/dotnet/lang-csharp.md +0 -162
  44. package/dist/default_templates/generic/lang-typescript.md +0 -11
  45. package/dist/default_templates/generic/state-redux.md +0 -21
  46. package/dist/default_templates/generic/state-rxjs.md +0 -6
  47. package/dist/default_templates/generic/style-mui.md +0 -23
  48. package/dist/default_templates/generic/style-tailwind.md +0 -6
  49. package/dist/default_templates/generic/test-cypress.md +0 -21
  50. package/dist/default_templates/generic/test-jest.md +0 -20
  51. package/dist/default_templates/generic/test-playwright.md +0 -21
  52. package/dist/default_templates/generic/test-vitest.md +0 -6
  53. package/dist/default_templates/go/lang-go.md +0 -571
  54. package/dist/default_templates/java/build-gradle.md +0 -102
  55. package/dist/default_templates/java/build-maven.md +0 -86
  56. package/dist/default_templates/java/framework-spring-boot.md +0 -179
  57. package/dist/default_templates/java/lang-java.md +0 -78
  58. package/dist/default_templates/java/lang-kotlin.md +0 -88
  59. package/dist/default_templates/meta/magic-helix-meta.md +0 -213
  60. package/dist/default_templates/meta/meta-debug.md +0 -459
  61. package/dist/default_templates/meta/meta-implement.md +0 -450
  62. package/dist/default_templates/meta/meta-roadmap.md +0 -265
  63. package/dist/default_templates/nestjs/nestjs-core.md +0 -7
  64. package/dist/default_templates/patterns/architecture/clean-architecture.md +0 -469
  65. package/dist/default_templates/patterns/architecture/dependency-injection.md +0 -517
  66. package/dist/default_templates/patterns/architecture/domain-driven-design.md +0 -621
  67. package/dist/default_templates/patterns/architecture/layered-architecture.md +0 -382
  68. package/dist/default_templates/patterns/architecture/repository-pattern.md +0 -408
  69. package/dist/default_templates/patterns/domain-expertise/nextjs-rules.md +0 -115
  70. package/dist/default_templates/patterns/domain-expertise/react-patterns.md +0 -181
  71. package/dist/default_templates/patterns/domain-expertise/server-components.md +0 -212
  72. package/dist/default_templates/patterns/domain-expertise/shadcn-ui.md +0 -52
  73. package/dist/default_templates/patterns/domain-expertise/tailwind-patterns.md +0 -52
  74. package/dist/default_templates/patterns/environment/container-awareness.md +0 -17
  75. package/dist/default_templates/patterns/environment/ide-features.md +0 -17
  76. package/dist/default_templates/patterns/environment/os-commands.md +0 -17
  77. package/dist/default_templates/patterns/organization/heading-hierarchy.md +0 -103
  78. package/dist/default_templates/patterns/organization/sequential-workflows.md +0 -102
  79. package/dist/default_templates/patterns/organization/xml-rule-groups.md +0 -64
  80. package/dist/default_templates/patterns/reasoning/agent-loop.md +0 -151
  81. package/dist/default_templates/patterns/reasoning/confirmation-gates.md +0 -141
  82. package/dist/default_templates/patterns/reasoning/dependency-analysis.md +0 -132
  83. package/dist/default_templates/patterns/reasoning/one-tool-per-iteration.md +0 -152
  84. package/dist/default_templates/patterns/reasoning/preview-before-action.md +0 -194
  85. package/dist/default_templates/patterns/reasoning/reflection-checkpoints.md +0 -166
  86. package/dist/default_templates/patterns/reasoning/result-verification.md +0 -157
  87. package/dist/default_templates/patterns/reasoning/subtask-breakdown.md +0 -131
  88. package/dist/default_templates/patterns/reasoning/thinking-tags.md +0 -100
  89. package/dist/default_templates/patterns/role-definition/capability-declarations.md +0 -72
  90. package/dist/default_templates/patterns/role-definition/expert-identity.md +0 -45
  91. package/dist/default_templates/patterns/role-definition/scope-boundaries.md +0 -61
  92. package/dist/default_templates/patterns/safety/code-safety-rules.md +0 -17
  93. package/dist/default_templates/patterns/safety/credential-handling.md +0 -17
  94. package/dist/default_templates/patterns/safety/destructive-warnings.md +0 -17
  95. package/dist/default_templates/patterns/safety/refusal-messages.md +0 -17
  96. package/dist/default_templates/patterns/tone/adaptive-tone.md +0 -17
  97. package/dist/default_templates/patterns/tone/concise-communication.md +0 -17
  98. package/dist/default_templates/patterns/tone/forbidden-phrases.md +0 -17
  99. package/dist/default_templates/patterns/tool-guidelines/function-schemas.md +0 -143
  100. package/dist/default_templates/patterns/tool-guidelines/parameter-examples.md +0 -137
  101. package/dist/default_templates/patterns/tool-guidelines/usage-policies.md +0 -105
  102. package/dist/default_templates/php/framework-laravel.md +0 -112
  103. package/dist/default_templates/php/lang-php.md +0 -94
  104. package/dist/default_templates/python/lang-python.md +0 -508
  105. package/dist/default_templates/react/react-core.md +0 -677
  106. package/dist/default_templates/react/react-zustand.md +0 -7
  107. package/dist/default_templates/ruby/framework-rails.md +0 -309
  108. package/dist/default_templates/ruby/framework-sinatra.md +0 -227
  109. package/dist/default_templates/ruby/lang-ruby.md +0 -216
  110. package/dist/default_templates/rust/lang-rust.md +0 -89
  111. package/dist/default_templates/swift/framework-vapor.md +0 -352
  112. package/dist/default_templates/swift/lang-swift.md +0 -291
  113. package/dist/default_templates/vue/style-primevue.md +0 -6
  114. package/dist/default_templates/vue/style-quasar.md +0 -22
  115. package/dist/default_templates/vue/vue-core.md +0 -28
  116. package/dist/default_templates/vue/vue-pinia.md +0 -5
  117. package/dist/index-AkVwRl-r.js +0 -92
  118. package/dist/index-AkVwRl-r.js.map +0 -1
  119. package/dist/index-B6BeG1yT.cjs +0 -68
  120. package/dist/index-B6BeG1yT.cjs.map +0 -1
  121. package/dist/index-B8pyjKdF.js +0 -94
  122. package/dist/index-B8pyjKdF.js.map +0 -1
  123. package/dist/index-B_6W_RnJ.cjs +0 -76
  124. package/dist/index-B_6W_RnJ.cjs.map +0 -1
  125. package/dist/index-Bg8DD8ku.js +0 -216
  126. package/dist/index-Bg8DD8ku.js.map +0 -1
  127. package/dist/index-BkJhe5Af.js +0 -1748
  128. package/dist/index-BkJhe5Af.js.map +0 -1
  129. package/dist/index-Bv4Q1Pr7.cjs +0 -33
  130. package/dist/index-Bv4Q1Pr7.cjs.map +0 -1
  131. package/dist/index-CN8J45Nc.cjs +0 -24
  132. package/dist/index-CN8J45Nc.cjs.map +0 -1
  133. package/dist/index-CPbv2Od1.js +0 -62
  134. package/dist/index-CPbv2Od1.js.map +0 -1
  135. package/dist/index-Cf-MC6Al.js +0 -63
  136. package/dist/index-Cf-MC6Al.js.map +0 -1
  137. package/dist/index-DDPXXXDy.cjs +0 -19
  138. package/dist/index-DDPXXXDy.cjs.map +0 -1
  139. package/dist/index-DO30AzDe.cjs +0 -19
  140. package/dist/index-DO30AzDe.cjs.map +0 -1
  141. package/dist/index-Dm37u5ut.js +0 -2128
  142. package/dist/index-Dm37u5ut.js.map +0 -1
  143. package/dist/index-DqHvgoXJ.cjs +0 -19
  144. package/dist/index-DqHvgoXJ.cjs.map +0 -1
  145. package/dist/index-J1qAfsnO.cjs +0 -2
  146. package/dist/index-J1qAfsnO.cjs.map +0 -1
  147. package/dist/index-Jz0HYZ7B.js +0 -13
  148. package/dist/index-Jz0HYZ7B.js.map +0 -1
  149. package/dist/index-K39pdw94.cjs +0 -31
  150. package/dist/index-K39pdw94.cjs.map +0 -1
  151. package/dist/index-L3IVvhd1.cjs +0 -89
  152. package/dist/index-L3IVvhd1.cjs.map +0 -1
  153. package/dist/index-OT2XAJkc.js +0 -117
  154. package/dist/index-OT2XAJkc.js.map +0 -1
  155. package/dist/index-TPAX4XKg.cjs +0 -30
  156. package/dist/index-TPAX4XKg.cjs.map +0 -1
  157. package/dist/index-WmVSB57y.js +0 -107
  158. package/dist/index-WmVSB57y.js.map +0 -1
  159. package/dist/index-mYXvc3Fs.js +0 -68
  160. package/dist/index-mYXvc3Fs.js.map +0 -1
@@ -1,146 +0,0 @@
1
- # Monorepo Development Guidelines
2
-
3
- ## Overview
4
- This project uses a monorepo structure to manage multiple packages/applications in a single repository.
5
-
6
- ## Structure
7
- ```
8
- project-root/
9
- ├── packages/
10
- │ ├── package-a/
11
- │ ├── package-b/
12
- │ └── shared/
13
- ├── apps/
14
- │ ├── web/
15
- │ └── mobile/
16
- ├── package.json (workspace root)
17
- └── turbo.json or nx.json
18
- ```
19
-
20
- ## Workspace Commands
21
- - Install all dependencies: `npm install` (at root)
22
- - Run script in workspace: `npm run <script> --workspace=<package-name>`
23
- - Run script in all workspaces: `npm run <script> --workspaces`
24
- - Add dependency to workspace: `npm install <pkg> --workspace=<name>`
25
-
26
- ## Benefits
27
- - Code sharing between packages
28
- - Atomic changes across multiple packages
29
- - Unified versioning and releases
30
- - Shared tooling and configuration
31
- - Single source of truth
32
-
33
- ## Package Dependencies
34
- - Reference workspace packages: `"package-a": "*"` or `"workspace:*"`
35
- - Changes in dependencies trigger downstream rebuilds
36
- - Use semver for external dependencies
37
-
38
- ## Build Orchestration
39
- - Define build order based on dependencies
40
- - Use `turbo` or `nx` for caching and parallelization
41
- - Run only affected packages on changes
42
-
43
- ## Common Tools
44
-
45
- ### Turborepo
46
- ```json
47
- {
48
- "pipeline": {
49
- "build": {
50
- "dependsOn": ["^build"],
51
- "outputs": ["dist/**"]
52
- },
53
- "test": {
54
- "dependsOn": ["build"]
55
- }
56
- }
57
- }
58
- ```
59
-
60
- ### Nx
61
- ```json
62
- {
63
- "tasksRunnerOptions": {
64
- "default": {
65
- "runner": "@nrwl/workspace/tasks-runners/default",
66
- "options": {
67
- "cacheableOperations": ["build", "test"]
68
- }
69
- }
70
- }
71
- }
72
- ```
73
-
74
- ## Best Practices
75
- - Keep packages focused and small
76
- - Use consistent naming conventions
77
- - Share common configuration files
78
- - Version packages independently or together
79
- - Document package purposes in README
80
- - Use path mappings for imports
81
- - Hoist dependencies when possible
82
-
83
- ## Scripts Management
84
- - Define common scripts at root
85
- - Delegate to workspace-specific scripts
86
- - Use parallel execution for independent tasks
87
- - Run affected packages only
88
-
89
- ## Testing
90
- - Run tests from root: `npm test --workspaces`
91
- - Run tests for specific package: `npm test --workspace=<name>`
92
- - Use shared test configuration
93
- - Test cross-package integration
94
-
95
- ## Versioning
96
- - **Independent**: Each package has own version
97
- - **Fixed**: All packages share same version
98
- - Use changesets for version management
99
- - Document breaking changes
100
-
101
- ## Publishing
102
- - Publish packages independently
103
- - Use automated versioning tools
104
- - Test before publishing
105
- - Update changelogs
106
-
107
- ## TypeScript Configuration
108
- ```json
109
- {
110
- "references": [
111
- { "path": "./packages/package-a" },
112
- { "path": "./packages/package-b" }
113
- ]
114
- }
115
- ```
116
-
117
- ## Import Paths
118
- - Use path aliases: `@company/package-name`
119
- - Configure in `tsconfig.json` paths
120
- - Set up module resolution
121
-
122
- ## Challenges & Solutions
123
- - **Problem**: Dependency hell
124
- - **Solution**: Use workspaces, hoist dependencies
125
- - **Problem**: Slow builds
126
- - **Solution**: Use caching (turbo/nx), build affected only
127
- - **Problem**: Complex tooling
128
- - **Solution**: Share configs, document setup
129
-
130
- ## CI/CD
131
- - Build only affected packages
132
- - Cache build outputs
133
- - Run tasks in parallel
134
- - Use matrix builds for packages
135
-
136
- ## Performance
137
- - Enable caching for build outputs
138
- - Use incremental builds
139
- - Parallelize independent tasks
140
- - Skip unchanged packages
141
-
142
- ## Documentation
143
- - Maintain root-level README
144
- - Document each package purpose
145
- - Explain workspace structure
146
- - Provide contribution guidelines
@@ -1,122 +0,0 @@
1
- # Nx Monorepo Guidelines
2
-
3
- ## Overview
4
- This monorepo uses Nx for build orchestration, code generation, and project management.
5
-
6
- ## Commands
7
- - Run target: `nx run <project>:<target>`
8
- - Run for all projects: `nx run-many --target=build --all`
9
- - Run affected: `nx affected --target=build`
10
- - Show dependency graph: `nx graph`
11
- - Generate code: `nx generate @nx/react:component`
12
-
13
- ## Project Configuration
14
- ```json
15
- {
16
- "name": "my-app",
17
- "targets": {
18
- "build": {
19
- "executor": "@nx/webpack:webpack",
20
- "outputs": ["{workspaceRoot}/dist/apps/my-app"],
21
- "options": {
22
- "outputPath": "dist/apps/my-app"
23
- }
24
- }
25
- }
26
- }
27
- ```
28
-
29
- ## Affected Commands
30
- - Build affected: `nx affected:build`
31
- - Test affected: `nx affected:test`
32
- - Lint affected: `nx affected:lint`
33
- - Based on git diff from base branch
34
-
35
- ## Caching
36
- - Nx caches task outputs automatically
37
- - Cache key based on inputs
38
- - Restore from cache for unchanged code
39
- - Configure cacheable operations
40
-
41
- ## Generators
42
- - Generate applications: `nx g @nx/react:app`
43
- - Generate libraries: `nx g @nx/js:lib`
44
- - Custom generators for consistency
45
- - Automated code scaffolding
46
-
47
- ## Project Graph
48
- - Visualize dependencies: `nx graph`
49
- - See affected projects
50
- - Understand project relationships
51
- - Detect circular dependencies
52
-
53
- ## Configuration Files
54
- - `nx.json`: Nx configuration
55
- - `workspace.json` or `project.json`: Project config
56
- - `.nxignore`: Files to ignore
57
-
58
- ## Task Pipeline
59
- ```json
60
- {
61
- "targetDefaults": {
62
- "build": {
63
- "dependsOn": ["^build"]
64
- }
65
- }
66
- }
67
- ```
68
-
69
- ## Plugins
70
- - Framework-specific plugins: React, Angular, Next.js
71
- - Tool-specific plugins: Jest, Cypress, ESLint
72
- - Custom plugins for specific needs
73
-
74
- ## Workspace Libraries
75
- - Organize code into libraries
76
- - Enforce module boundaries
77
- - Share code between apps
78
- - Use tags for constraints
79
-
80
- ## Best Practices
81
- - Use affected commands in CI
82
- - Organize libs by scope and type
83
- - Set up import restrictions
84
- - Use generators for consistency
85
- - Enable computation caching
86
- - Configure remote caching for teams
87
-
88
- ## CI/CD Integration
89
- ```yaml
90
- - name: Nx Cache
91
- uses: actions/cache@v4
92
- with:
93
- path: node_modules/.cache/nx
94
- key: nx-${{ github.sha }}
95
- restore-keys: nx-
96
-
97
- - name: Build affected
98
- run: nx affected --target=build --base=origin/main
99
- ```
100
-
101
- ## Performance
102
- - Parallel execution of independent tasks
103
- - Computation caching
104
- - Remote caching with Nx Cloud
105
- - Affected-only builds in CI
106
-
107
- ## Module Boundaries
108
- ```json
109
- {
110
- "@nx/enforce-module-boundaries": [
111
- "error",
112
- {
113
- "depConstraints": [
114
- {
115
- "sourceTag": "scope:shared",
116
- "onlyDependOnLibsWithTags": ["scope:shared"]
117
- }
118
- ]
119
- }
120
- ]
121
- }
122
- ```
@@ -1,114 +0,0 @@
1
- # Turborepo Guidelines
2
-
3
- ## Overview
4
- This monorepo uses Turborepo for build orchestration and caching.
5
-
6
- ## Configuration
7
- ```json
8
- {
9
- "$schema": "https://turbo.build/schema.json",
10
- "pipeline": {
11
- "build": {
12
- "dependsOn": ["^build"],
13
- "outputs": ["dist/**", ".next/**"]
14
- },
15
- "test": {
16
- "dependsOn": ["build"],
17
- "outputs": []
18
- },
19
- "lint": {
20
- "outputs": []
21
- },
22
- "dev": {
23
- "cache": false
24
- }
25
- }
26
- }
27
- ```
28
-
29
- ## Commands
30
- - Run task across all workspaces: `turbo run build`
31
- - Run task in specific workspace: `turbo run build --filter=package-name`
32
- - Run with no cache: `turbo run build --force`
33
- - Clear cache: `turbo run build --no-cache`
34
- - Dry run: `turbo run build --dry-run`
35
-
36
- ## Pipeline Configuration
37
- - `dependsOn`: Task dependencies
38
- - `^dependsOn`: Dependencies from workspace dependencies
39
- - `outputs`: Files to cache
40
- - `cache`: Enable/disable caching
41
- - `inputs`: Files that affect cache validity
42
-
43
- ## Caching
44
- - Turborepo caches task outputs
45
- - Cache key based on inputs (files, env vars)
46
- - Shared cache across team (remote caching)
47
- - Restore from cache for unchanged code
48
-
49
- ## Filtering
50
- - By package: `--filter=package-name`
51
- - By directory: `--filter=./apps/*`
52
- - By dependency: `--filter=...package-name`
53
- - By changed files: `--filter=[HEAD^1]`
54
-
55
- ## Remote Caching
56
- ```bash
57
- # Enable remote cache
58
- turbo login
59
- turbo link
60
-
61
- # Or use Vercel
62
- vercel link
63
- ```
64
-
65
- ## Environment Variables
66
- - Automatically included in cache key
67
- - Prefix with `TURBO_` for Turbo-specific vars
68
- - Use `.env` files for local development
69
-
70
- ## Performance
71
- - Tasks run in parallel when possible
72
- - Skips cached tasks
73
- - Shows cache hit ratio
74
- - Optimizes based on dependencies
75
-
76
- ## Best Practices
77
- - Define clear task dependencies
78
- - Specify all outputs for caching
79
- - Use `^` for workspace dependencies
80
- - Enable remote caching for teams
81
- - Run affected tasks only in CI
82
- - Keep pipeline config simple
83
-
84
- ## Monorepo Commands
85
- ```json
86
- {
87
- "scripts": {
88
- "build": "turbo run build",
89
- "dev": "turbo run dev --parallel",
90
- "test": "turbo run test",
91
- "lint": "turbo run lint"
92
- }
93
- }
94
- ```
95
-
96
- ## CI/CD Integration
97
- ```yaml
98
- # GitHub Actions
99
- - name: Setup Turborepo cache
100
- uses: actions/cache@v4
101
- with:
102
- path: .turbo
103
- key: turbo-${{ github.sha }}
104
- restore-keys: turbo-
105
-
106
- - name: Build
107
- run: turbo run build
108
- ```
109
-
110
- ## Debugging
111
- - Use `--dry-run` to see execution plan
112
- - Check `.turbo/runs/*.json` for logs
113
- - Enable verbose output: `--verbose`
114
- - View graph: `turbo run build --graph`
@@ -1,268 +0,0 @@
1
- # GitHub Actions CI/CD Templates
2
-
3
- ## Node.js/TypeScript Pipeline
4
- ```yaml
5
- name: Node.js CI/CD
6
-
7
- on:
8
- push:
9
- branches: [main, develop]
10
- pull_request:
11
- branches: [main]
12
-
13
- jobs:
14
- test:
15
- runs-on: ubuntu-latest
16
- strategy:
17
- matrix:
18
- node-version: [18.x, 20.x]
19
- steps:
20
- - uses: actions/checkout@v4
21
- - name: Use Node.js ${{ matrix.node-version }}
22
- uses: actions/setup-node@v4
23
- with:
24
- node-version: ${{ matrix.node-version }}
25
- cache: 'npm'
26
- - run: npm ci
27
- - run: npm run build
28
- - run: npm test
29
- - run: npm run lint
30
- - name: Upload coverage
31
- uses: codecov/codecov-action@v4
32
- if: matrix.node-version == '20.x'
33
- with:
34
- token: ${{ secrets.CODECOV_TOKEN }}
35
-
36
- docker:
37
- needs: test
38
- runs-on: ubuntu-latest
39
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
40
- steps:
41
- - uses: actions/checkout@v4
42
- - name: Set up Docker Buildx
43
- uses: docker/setup-buildx-action@v3
44
- - name: Login to DockerHub
45
- uses: docker/login-action@v3
46
- with:
47
- username: ${{ secrets.DOCKER_USERNAME }}
48
- password: ${{ secrets.DOCKER_PASSWORD }}
49
- - name: Build and push
50
- uses: docker/build-push-action@v5
51
- with:
52
- context: .
53
- push: true
54
- tags: user/app:latest,user/app:${{ github.sha }}
55
- cache-from: type=registry,ref=user/app:buildcache
56
- cache-to: type=registry,ref=user/app:buildcache,mode=max
57
- ```
58
-
59
- ## Python Pipeline
60
- ```yaml
61
- name: Python CI/CD
62
-
63
- on: [push, pull_request]
64
-
65
- jobs:
66
- test:
67
- runs-on: ubuntu-latest
68
- strategy:
69
- matrix:
70
- python-version: ['3.10', '3.11', '3.12']
71
- steps:
72
- - uses: actions/checkout@v4
73
- - name: Set up Python ${{ matrix.python-version }}
74
- uses: actions/setup-python@v5
75
- with:
76
- python-version: ${{ matrix.python-version }}
77
- - name: Install Poetry
78
- uses: snok/install-poetry@v1
79
- with:
80
- virtualenvs-create: true
81
- virtualenvs-in-project: true
82
- - name: Load cached venv
83
- uses: actions/cache@v4
84
- with:
85
- path: .venv
86
- key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
87
- - name: Install dependencies
88
- run: poetry install --no-interaction
89
- - name: Run tests
90
- run: poetry run pytest --cov --cov-report=xml
91
- - name: Run linters
92
- run: |
93
- poetry run ruff check .
94
- poetry run mypy .
95
- ```
96
-
97
- ## Go Pipeline
98
- ```yaml
99
- name: Go CI/CD
100
-
101
- on: [push, pull_request]
102
-
103
- jobs:
104
- test:
105
- runs-on: ubuntu-latest
106
- steps:
107
- - uses: actions/checkout@v4
108
- - name: Set up Go
109
- uses: actions/setup-go@v5
110
- with:
111
- go-version: '1.21'
112
- cache: true
113
- - name: Verify dependencies
114
- run: go mod verify
115
- - name: Build
116
- run: go build -v ./...
117
- - name: Run tests
118
- run: go test -v -race -coverprofile=coverage.txt ./...
119
- - name: Lint
120
- uses: golangci/golangci-lint-action@v4
121
- with:
122
- version: latest
123
- ```
124
-
125
- ## Rust Pipeline
126
- ```yaml
127
- name: Rust CI/CD
128
-
129
- on: [push, pull_request]
130
-
131
- jobs:
132
- test:
133
- runs-on: ubuntu-latest
134
- steps:
135
- - uses: actions/checkout@v4
136
- - name: Install Rust
137
- uses: dtolnay/rust-toolchain@stable
138
- with:
139
- components: rustfmt, clippy
140
- - name: Cache cargo registry
141
- uses: actions/cache@v4
142
- with:
143
- path: ~/.cargo/registry
144
- key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
145
- - name: Cache cargo index
146
- uses: actions/cache@v4
147
- with:
148
- path: ~/.cargo/git
149
- key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
150
- - name: Cache target
151
- uses: actions/cache@v4
152
- with:
153
- path: target
154
- key: ${{ runner.os }}-target-${{ hashFiles('**/Cargo.lock') }}
155
- - name: Check formatting
156
- run: cargo fmt -- --check
157
- - name: Run clippy
158
- run: cargo clippy -- -D warnings
159
- - name: Run tests
160
- run: cargo test --verbose
161
- - name: Build release
162
- run: cargo build --release --verbose
163
- ```
164
-
165
- ## Java/Maven Pipeline
166
- ```yaml
167
- name: Java CI/CD
168
-
169
- on: [push, pull_request]
170
-
171
- jobs:
172
- build:
173
- runs-on: ubuntu-latest
174
- steps:
175
- - uses: actions/checkout@v4
176
- - name: Set up JDK 21
177
- uses: actions/setup-java@v4
178
- with:
179
- java-version: '21'
180
- distribution: 'temurin'
181
- cache: 'maven'
182
- - name: Build with Maven
183
- run: mvn -B package --file pom.xml
184
- - name: Run tests
185
- run: mvn test
186
- - name: Generate coverage report
187
- run: mvn jacoco:report
188
- ```
189
-
190
- ## Multi-Platform Docker Build
191
- ```yaml
192
- name: Docker Multi-Arch
193
-
194
- on:
195
- push:
196
- tags: ['v*']
197
-
198
- jobs:
199
- build:
200
- runs-on: ubuntu-latest
201
- steps:
202
- - uses: actions/checkout@v4
203
- - name: Set up QEMU
204
- uses: docker/setup-qemu-action@v3
205
- - name: Set up Docker Buildx
206
- uses: docker/setup-buildx-action@v3
207
- - name: Login to GHCR
208
- uses: docker/login-action@v3
209
- with:
210
- registry: ghcr.io
211
- username: ${{ github.actor }}
212
- password: ${{ secrets.GITHUB_TOKEN }}
213
- - name: Extract metadata
214
- id: meta
215
- uses: docker/metadata-action@v5
216
- with:
217
- images: ghcr.io/${{ github.repository }}
218
- tags: |
219
- type=ref,event=branch
220
- type=semver,pattern={{version}}
221
- type=semver,pattern={{major}}.{{minor}}
222
- - name: Build and push
223
- uses: docker/build-push-action@v5
224
- with:
225
- context: .
226
- platforms: linux/amd64,linux/arm64
227
- push: true
228
- tags: ${{ steps.meta.outputs.tags }}
229
- labels: ${{ steps.meta.outputs.labels }}
230
- ```
231
-
232
- ## Security Scanning
233
- ```yaml
234
- name: Security Scan
235
-
236
- on:
237
- push:
238
- branches: [main]
239
- schedule:
240
- - cron: '0 0 * * 0' # Weekly
241
-
242
- jobs:
243
- scan:
244
- runs-on: ubuntu-latest
245
- steps:
246
- - uses: actions/checkout@v4
247
- - name: Run Trivy vulnerability scanner
248
- uses: aquasecurity/trivy-action@master
249
- with:
250
- scan-type: 'fs'
251
- scan-ref: '.'
252
- format: 'sarif'
253
- output: 'trivy-results.sarif'
254
- - name: Upload results to GitHub Security
255
- uses: github/codeql-action/upload-sarif@v3
256
- with:
257
- sarif_file: 'trivy-results.sarif'
258
- ```
259
-
260
- ## Best Practices
261
- 1. **Caching**: Use `actions/cache` for dependencies (npm, pip, cargo, maven)
262
- 2. **Matrix Builds**: Test against multiple language versions
263
- 3. **Secrets**: Store credentials in GitHub Secrets, never in code
264
- 4. **Branch Protection**: Require CI to pass before merging
265
- 5. **Parallel Jobs**: Use `needs` to orchestrate job dependencies
266
- 6. **Docker Layer Caching**: Use registry cache or buildx cache backends
267
- 7. **Security Scanning**: Integrate Trivy, Snyk, or CodeQL
268
- 8. **Artifact Storage**: Upload test reports and binaries with `actions/upload-artifact`