@neyugn/agent-kits 0.1.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/LICENSE +21 -0
- package/README.md +514 -0
- package/README.vi.md +410 -0
- package/README.zh.md +410 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +422 -0
- package/kits/coder/ARCHITECTURE.md +289 -0
- package/kits/coder/agents/ai-engineer.md +344 -0
- package/kits/coder/agents/backend-specialist.md +270 -0
- package/kits/coder/agents/cloud-architect.md +363 -0
- package/kits/coder/agents/code-reviewer.md +284 -0
- package/kits/coder/agents/data-engineer.md +401 -0
- package/kits/coder/agents/database-specialist.md +251 -0
- package/kits/coder/agents/debugger.md +209 -0
- package/kits/coder/agents/devops-engineer.md +281 -0
- package/kits/coder/agents/documentation-writer.md +296 -0
- package/kits/coder/agents/frontend-specialist.md +298 -0
- package/kits/coder/agents/i18n-specialist.md +348 -0
- package/kits/coder/agents/integration-specialist.md +314 -0
- package/kits/coder/agents/mobile-developer.md +271 -0
- package/kits/coder/agents/multi-tenant-architect.md +281 -0
- package/kits/coder/agents/orchestrator.md +263 -0
- package/kits/coder/agents/performance-analyst.md +327 -0
- package/kits/coder/agents/project-planner.md +277 -0
- package/kits/coder/agents/queue-specialist.md +282 -0
- package/kits/coder/agents/realtime-specialist.md +267 -0
- package/kits/coder/agents/security-auditor.md +253 -0
- package/kits/coder/agents/test-engineer.md +315 -0
- package/kits/coder/agents/ux-researcher.md +388 -0
- package/kits/coder/rules/.cursorrules +287 -0
- package/kits/coder/rules/CLAUDE.md +287 -0
- package/kits/coder/rules/CODEX.md +287 -0
- package/kits/coder/rules/GEMINI.md +287 -0
- package/kits/coder/scripts/checklist.py +318 -0
- package/kits/coder/scripts/kit_status.py +292 -0
- package/kits/coder/scripts/skills_manager.py +243 -0
- package/kits/coder/scripts/verify_all.py +391 -0
- package/kits/coder/skills/accessibility-patterns/SKILL.md +372 -0
- package/kits/coder/skills/accessibility-patterns/scripts/a11y_checker.py +211 -0
- package/kits/coder/skills/ai-rag-patterns/SKILL.md +444 -0
- package/kits/coder/skills/api-patterns/SKILL.md +316 -0
- package/kits/coder/skills/api-patterns/assets/.gitkeep +1 -0
- package/kits/coder/skills/api-patterns/references/deep-dive.md +21 -0
- package/kits/coder/skills/api-patterns/scripts/api_validator.py +253 -0
- package/kits/coder/skills/api-patterns/scripts/validate.py +56 -0
- package/kits/coder/skills/auth-patterns/SKILL.md +267 -0
- package/kits/coder/skills/aws-patterns/SKILL.md +576 -0
- package/kits/coder/skills/brainstorming/SKILL.md +370 -0
- package/kits/coder/skills/brainstorming/assets/.gitkeep +1 -0
- package/kits/coder/skills/brainstorming/references/deep-dive.md +21 -0
- package/kits/coder/skills/brainstorming/scripts/validate.py +56 -0
- package/kits/coder/skills/clean-code/SKILL.md +240 -0
- package/kits/coder/skills/clean-code/assets/.gitkeep +1 -0
- package/kits/coder/skills/clean-code/references/deep-dive.md +21 -0
- package/kits/coder/skills/clean-code/scripts/lint_runner.py +186 -0
- package/kits/coder/skills/clean-code/scripts/validate.py +56 -0
- package/kits/coder/skills/database-design/SKILL.md +255 -0
- package/kits/coder/skills/database-design/assets/.gitkeep +1 -0
- package/kits/coder/skills/database-design/references/deep-dive.md +21 -0
- package/kits/coder/skills/database-design/scripts/schema_validator.py +272 -0
- package/kits/coder/skills/database-design/scripts/validate.py +56 -0
- package/kits/coder/skills/docker-patterns/SKILL.md +240 -0
- package/kits/coder/skills/documentation-templates/SKILL.md +441 -0
- package/kits/coder/skills/e2e-testing/SKILL.md +457 -0
- package/kits/coder/skills/flutter-patterns/SKILL.md +330 -0
- package/kits/coder/skills/frontend-design/SKILL.md +127 -0
- package/kits/coder/skills/github-actions/SKILL.md +349 -0
- package/kits/coder/skills/gitlab-ci-patterns/SKILL.md +466 -0
- package/kits/coder/skills/graphql-patterns/SKILL.md +558 -0
- package/kits/coder/skills/i18n-localization/SKILL.md +345 -0
- package/kits/coder/skills/i18n-localization/scripts/i18n_checker.py +267 -0
- package/kits/coder/skills/kubernetes-patterns/SKILL.md +357 -0
- package/kits/coder/skills/mermaid-diagrams/SKILL.md +351 -0
- package/kits/coder/skills/mobile-design/SKILL.md +305 -0
- package/kits/coder/skills/monitoring-observability/SKILL.md +458 -0
- package/kits/coder/skills/multi-tenancy/SKILL.md +317 -0
- package/kits/coder/skills/multi-tenancy/assets/.gitkeep +1 -0
- package/kits/coder/skills/multi-tenancy/references/deep-dive.md +21 -0
- package/kits/coder/skills/multi-tenancy/scripts/validate.py +56 -0
- package/kits/coder/skills/nodejs-best-practices/SKILL.md +220 -0
- package/kits/coder/skills/performance-profiling/SKILL.md +333 -0
- package/kits/coder/skills/performance-profiling/assets/.gitkeep +1 -0
- package/kits/coder/skills/performance-profiling/references/deep-dive.md +21 -0
- package/kits/coder/skills/performance-profiling/scripts/validate.py +56 -0
- package/kits/coder/skills/plan-writing/SKILL.md +360 -0
- package/kits/coder/skills/plan-writing/assets/.gitkeep +1 -0
- package/kits/coder/skills/plan-writing/references/deep-dive.md +21 -0
- package/kits/coder/skills/plan-writing/scripts/validate.py +56 -0
- package/kits/coder/skills/postgres-patterns/SKILL.md +361 -0
- package/kits/coder/skills/prompt-engineering/SKILL.md +277 -0
- package/kits/coder/skills/queue-patterns/SKILL.md +359 -0
- package/kits/coder/skills/queue-patterns/assets/.gitkeep +1 -0
- package/kits/coder/skills/queue-patterns/references/deep-dive.md +21 -0
- package/kits/coder/skills/queue-patterns/scripts/validate.py +56 -0
- package/kits/coder/skills/react-native-patterns/SKILL.md +393 -0
- package/kits/coder/skills/react-patterns/SKILL.md +319 -0
- package/kits/coder/skills/realtime-patterns/SKILL.md +506 -0
- package/kits/coder/skills/realtime-patterns/assets/.gitkeep +1 -0
- package/kits/coder/skills/realtime-patterns/references/deep-dive.md +21 -0
- package/kits/coder/skills/realtime-patterns/scripts/validate.py +56 -0
- package/kits/coder/skills/redis-patterns/SKILL.md +484 -0
- package/kits/coder/skills/security-fundamentals/SKILL.md +363 -0
- package/kits/coder/skills/security-fundamentals/assets/.gitkeep +1 -0
- package/kits/coder/skills/security-fundamentals/references/deep-dive.md +21 -0
- package/kits/coder/skills/security-fundamentals/scripts/security_scan.py +326 -0
- package/kits/coder/skills/security-fundamentals/scripts/validate.py +56 -0
- package/kits/coder/skills/seo-patterns/SKILL.md +262 -0
- package/kits/coder/skills/seo-patterns/scripts/seo_checker.py +211 -0
- package/kits/coder/skills/systematic-debugging/SKILL.md +478 -0
- package/kits/coder/skills/systematic-debugging/assets/.gitkeep +1 -0
- package/kits/coder/skills/systematic-debugging/references/deep-dive.md +21 -0
- package/kits/coder/skills/systematic-debugging/scripts/validate.py +56 -0
- package/kits/coder/skills/tailwind-patterns/SKILL.md +395 -0
- package/kits/coder/skills/terraform-patterns/SKILL.md +470 -0
- package/kits/coder/skills/testing-patterns/SKILL.md +285 -0
- package/kits/coder/skills/testing-patterns/assets/.gitkeep +1 -0
- package/kits/coder/skills/testing-patterns/references/deep-dive.md +21 -0
- package/kits/coder/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/kits/coder/skills/testing-patterns/scripts/validate.py +56 -0
- package/kits/coder/skills/typescript-patterns/SKILL.md +417 -0
- package/kits/coder/skills/ui-ux-pro-max/SKILL.md +364 -0
- package/kits/coder/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/kits/coder/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/kits/coder/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/kits/coder/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/kits/coder/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/kits/coder/skills/ui-ux-pro-max/data/prompts.csv +24 -0
- package/kits/coder/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/kits/coder/skills/ui-ux-pro-max/data/styles.csv +59 -0
- package/kits/coder/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/kits/coder/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/kits/coder/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/kits/coder/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-314.pyc +0 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-314.pyc +0 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/core.py +257 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/design_system.py +488 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/search.py +76 -0
- package/kits/coder/workflows/.gitkeep +20 -0
- package/kits/coder/workflows/create.md +152 -0
- package/kits/coder/workflows/debug.md +223 -0
- package/kits/coder/workflows/deploy.md +283 -0
- package/kits/coder/workflows/orchestrate.md +243 -0
- package/kits/coder/workflows/plan.md +134 -0
- package/kits/coder/workflows/test.md +237 -0
- package/kits/coder/workflows/ui-ux-pro-max.md +109 -0
- package/package.json +49 -0
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gitlab-ci-patterns
|
|
3
|
+
description: GitLab CI/CD principles and pipeline patterns. Use when setting up GitLab CI, designing multi-stage pipelines, configuring GitLab Runners, or implementing GitOps with GitLab. Covers caching, artifacts, security scanning, and deployment strategies.
|
|
4
|
+
allowed-tools: Read, Write, Edit
|
|
5
|
+
version: 1.0
|
|
6
|
+
priority: HIGH
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# GitLab CI - CI/CD Automation
|
|
10
|
+
|
|
11
|
+
> **Philosophy:** Pipelines should be **fast, reliable, and reproducible**. Every merge request should trigger automated validation. Every deployment should be traceable and reversible.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Core Principles
|
|
16
|
+
|
|
17
|
+
| Principle | Rule |
|
|
18
|
+
| ----------------- | ---------------------------------------------------- |
|
|
19
|
+
| **DRY** | Use templates, includes, and extends to avoid repeat |
|
|
20
|
+
| **Fast Feedback** | Tests should run in minutes, not hours |
|
|
21
|
+
| **Stage Order** | Build → Test → Security → Deploy |
|
|
22
|
+
| **Fail Fast** | Stop pipeline on first failure, save resources |
|
|
23
|
+
| **Cache Smart** | Cache dependencies, not build outputs |
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Pipeline Triggers
|
|
28
|
+
|
|
29
|
+
| Trigger | Use Case | Syntax |
|
|
30
|
+
| ----------------- | -------------------- | --------------------------- |
|
|
31
|
+
| **push** | Every push to branch | `only: [branches]` |
|
|
32
|
+
| **merge_request** | MR validation | `only: [merge_requests]` |
|
|
33
|
+
| **schedule** | Cron jobs | Project → CI/CD → Schedules |
|
|
34
|
+
| **tag** | Release builds | `only: [tags]` |
|
|
35
|
+
| **manual** | Human approval | `when: manual` |
|
|
36
|
+
| **api/trigger** | External trigger | Pipeline trigger tokens |
|
|
37
|
+
|
|
38
|
+
### Common Rules Patterns
|
|
39
|
+
|
|
40
|
+
```yaml
|
|
41
|
+
.default-rules:
|
|
42
|
+
rules:
|
|
43
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
44
|
+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
45
|
+
- if: $CI_COMMIT_TAG
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Essential Pipeline Patterns
|
|
51
|
+
|
|
52
|
+
### 1. Standard Node.js Pipeline
|
|
53
|
+
|
|
54
|
+
```yaml
|
|
55
|
+
stages:
|
|
56
|
+
- build
|
|
57
|
+
- test
|
|
58
|
+
- deploy
|
|
59
|
+
|
|
60
|
+
variables:
|
|
61
|
+
NODE_VERSION: "20"
|
|
62
|
+
PNPM_VERSION: "9"
|
|
63
|
+
|
|
64
|
+
default:
|
|
65
|
+
image: node:${NODE_VERSION}
|
|
66
|
+
before_script:
|
|
67
|
+
- corepack enable
|
|
68
|
+
- corepack prepare pnpm@${PNPM_VERSION} --activate
|
|
69
|
+
- pnpm install --frozen-lockfile
|
|
70
|
+
|
|
71
|
+
build:
|
|
72
|
+
stage: build
|
|
73
|
+
script:
|
|
74
|
+
- pnpm build
|
|
75
|
+
artifacts:
|
|
76
|
+
paths:
|
|
77
|
+
- dist/
|
|
78
|
+
expire_in: 1 hour
|
|
79
|
+
cache:
|
|
80
|
+
key: ${CI_COMMIT_REF_SLUG}
|
|
81
|
+
paths:
|
|
82
|
+
- node_modules/
|
|
83
|
+
- .pnpm-store/
|
|
84
|
+
policy: pull-push
|
|
85
|
+
|
|
86
|
+
test:
|
|
87
|
+
stage: test
|
|
88
|
+
script:
|
|
89
|
+
- pnpm lint
|
|
90
|
+
- pnpm test --coverage
|
|
91
|
+
coverage: '/Lines\s*:\s*(\d+\.\d+)%/'
|
|
92
|
+
artifacts:
|
|
93
|
+
reports:
|
|
94
|
+
coverage_report:
|
|
95
|
+
coverage_format: cobertura
|
|
96
|
+
path: coverage/cobertura-coverage.xml
|
|
97
|
+
cache:
|
|
98
|
+
key: ${CI_COMMIT_REF_SLUG}
|
|
99
|
+
paths:
|
|
100
|
+
- node_modules/
|
|
101
|
+
policy: pull
|
|
102
|
+
|
|
103
|
+
deploy:
|
|
104
|
+
stage: deploy
|
|
105
|
+
script:
|
|
106
|
+
- echo "Deploying $CI_COMMIT_SHA"
|
|
107
|
+
only:
|
|
108
|
+
- main
|
|
109
|
+
environment:
|
|
110
|
+
name: production
|
|
111
|
+
url: https://app.example.com
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 2. Docker Build & Push
|
|
115
|
+
|
|
116
|
+
```yaml
|
|
117
|
+
build-docker:
|
|
118
|
+
stage: build
|
|
119
|
+
image: docker:24
|
|
120
|
+
services:
|
|
121
|
+
- docker:24-dind
|
|
122
|
+
variables:
|
|
123
|
+
DOCKER_HOST: tcp://docker:2376
|
|
124
|
+
DOCKER_TLS_CERTDIR: "/certs"
|
|
125
|
+
DOCKER_DRIVER: overlay2
|
|
126
|
+
before_script:
|
|
127
|
+
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
|
128
|
+
script:
|
|
129
|
+
- docker build
|
|
130
|
+
--cache-from $CI_REGISTRY_IMAGE:latest
|
|
131
|
+
--tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
|
132
|
+
--tag $CI_REGISTRY_IMAGE:latest .
|
|
133
|
+
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
|
134
|
+
- docker push $CI_REGISTRY_IMAGE:latest
|
|
135
|
+
only:
|
|
136
|
+
- main
|
|
137
|
+
- tags
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 3. Multi-Environment Deployment
|
|
141
|
+
|
|
142
|
+
```yaml
|
|
143
|
+
.deploy_template: &deploy_template
|
|
144
|
+
image: bitnami/kubectl:latest
|
|
145
|
+
before_script:
|
|
146
|
+
- kubectl config set-cluster k8s --server="$KUBE_URL" --insecure-skip-tls-verify=true
|
|
147
|
+
- kubectl config set-credentials admin --token="$KUBE_TOKEN"
|
|
148
|
+
- kubectl config set-context default --cluster=k8s --user=admin
|
|
149
|
+
- kubectl config use-context default
|
|
150
|
+
|
|
151
|
+
deploy:staging:
|
|
152
|
+
<<: *deploy_template
|
|
153
|
+
stage: deploy
|
|
154
|
+
script:
|
|
155
|
+
- kubectl apply -f k8s/ -n staging
|
|
156
|
+
- kubectl rollout status deployment/app -n staging
|
|
157
|
+
environment:
|
|
158
|
+
name: staging
|
|
159
|
+
url: https://staging.example.com
|
|
160
|
+
only:
|
|
161
|
+
- develop
|
|
162
|
+
|
|
163
|
+
deploy:production:
|
|
164
|
+
<<: *deploy_template
|
|
165
|
+
stage: deploy
|
|
166
|
+
script:
|
|
167
|
+
- kubectl apply -f k8s/ -n production
|
|
168
|
+
- kubectl rollout status deployment/app -n production
|
|
169
|
+
environment:
|
|
170
|
+
name: production
|
|
171
|
+
url: https://app.example.com
|
|
172
|
+
when: manual
|
|
173
|
+
only:
|
|
174
|
+
- main
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Caching Strategies
|
|
180
|
+
|
|
181
|
+
| Strategy | Cache Key | Use Case |
|
|
182
|
+
| ------------------- | -------------------------------------------------- | -------------------------- |
|
|
183
|
+
| **Per-branch** | `${CI_COMMIT_REF_SLUG}` | Feature branch isolation |
|
|
184
|
+
| **Per-job** | `${CI_JOB_NAME}` | Job-specific cache |
|
|
185
|
+
| **Global** | `global-cache` | Shared across all branches |
|
|
186
|
+
| **Lock-file based** | `$CI_COMMIT_REF_SLUG-$CI_JOB_NAME-$CI_PIPELINE_ID` | Exact deps match |
|
|
187
|
+
|
|
188
|
+
### Cache Best Practices
|
|
189
|
+
|
|
190
|
+
```yaml
|
|
191
|
+
# Pull-push: Job that updates cache
|
|
192
|
+
build:
|
|
193
|
+
cache:
|
|
194
|
+
key: ${CI_COMMIT_REF_SLUG}
|
|
195
|
+
paths:
|
|
196
|
+
- node_modules/
|
|
197
|
+
- .pnpm-store/
|
|
198
|
+
policy: pull-push # Updates cache after job
|
|
199
|
+
|
|
200
|
+
# Pull-only: Jobs that only read cache
|
|
201
|
+
test:
|
|
202
|
+
cache:
|
|
203
|
+
key: ${CI_COMMIT_REF_SLUG}
|
|
204
|
+
paths:
|
|
205
|
+
- node_modules/
|
|
206
|
+
policy: pull # Never updates cache
|
|
207
|
+
|
|
208
|
+
# Fallback keys for cache miss
|
|
209
|
+
cache:
|
|
210
|
+
key: ${CI_COMMIT_REF_SLUG}
|
|
211
|
+
paths:
|
|
212
|
+
- node_modules/
|
|
213
|
+
fallback_keys:
|
|
214
|
+
- main # Fall back to main branch cache
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Artifacts vs Cache
|
|
220
|
+
|
|
221
|
+
| Aspect | Cache | Artifacts |
|
|
222
|
+
| -------------- | ------------------------ | ------------------------------ |
|
|
223
|
+
| **Purpose** | Speed up pipelines | Pass data between jobs/stages |
|
|
224
|
+
| **Visibility** | Not in UI | Downloadable from UI |
|
|
225
|
+
| **Lifetime** | LRU eviction | Configurable `expire_in` |
|
|
226
|
+
| **Use case** | `node_modules`, `.cache` | `dist/`, reports, test results |
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Security Scanning (Built-in Templates)
|
|
231
|
+
|
|
232
|
+
```yaml
|
|
233
|
+
include:
|
|
234
|
+
- template: Security/SAST.gitlab-ci.yml
|
|
235
|
+
- template: Security/Dependency-Scanning.gitlab-ci.yml
|
|
236
|
+
- template: Security/Container-Scanning.gitlab-ci.yml
|
|
237
|
+
- template: Security/Secret-Detection.gitlab-ci.yml
|
|
238
|
+
|
|
239
|
+
# Custom Trivy scan (more control)
|
|
240
|
+
trivy-scan:
|
|
241
|
+
stage: test
|
|
242
|
+
image: aquasec/trivy:latest
|
|
243
|
+
script:
|
|
244
|
+
- trivy image
|
|
245
|
+
--exit-code 1
|
|
246
|
+
--severity HIGH,CRITICAL
|
|
247
|
+
$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
|
248
|
+
allow_failure: true
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Variables & Secrets
|
|
254
|
+
|
|
255
|
+
### Variable Scopes
|
|
256
|
+
|
|
257
|
+
| Type | Scope | How to Set |
|
|
258
|
+
| -------------- | ------------------ | ----------------------------- |
|
|
259
|
+
| **Predefined** | Automatic | `CI_COMMIT_SHA`, `CI_JOB_ID` |
|
|
260
|
+
| **Project** | All pipelines | Settings → CI/CD → Variables |
|
|
261
|
+
| **Group** | All group projects | Group Settings → CI/CD |
|
|
262
|
+
| **Protected** | Protected branches | Variable → Protected checkbox |
|
|
263
|
+
| **Masked** | Hidden in logs | Variable → Masked checkbox |
|
|
264
|
+
| **File** | Write to temp file | Variable → Type: File |
|
|
265
|
+
|
|
266
|
+
### Secure Secrets Pattern
|
|
267
|
+
|
|
268
|
+
```yaml
|
|
269
|
+
deploy:
|
|
270
|
+
script:
|
|
271
|
+
- echo "Deploying..."
|
|
272
|
+
variables:
|
|
273
|
+
# Reference variables, never hardcode
|
|
274
|
+
API_KEY: $PRODUCTION_API_KEY # From CI/CD settings
|
|
275
|
+
rules:
|
|
276
|
+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
277
|
+
variables:
|
|
278
|
+
DEPLOY_ENV: production
|
|
279
|
+
- if: $CI_COMMIT_BRANCH == "develop"
|
|
280
|
+
variables:
|
|
281
|
+
DEPLOY_ENV: staging
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## Pipeline Optimization
|
|
287
|
+
|
|
288
|
+
### Parallel Jobs (Matrix)
|
|
289
|
+
|
|
290
|
+
```yaml
|
|
291
|
+
test:
|
|
292
|
+
stage: test
|
|
293
|
+
parallel:
|
|
294
|
+
matrix:
|
|
295
|
+
- NODE_VERSION: ["18", "20", "22"]
|
|
296
|
+
OS: ["debian", "alpine"]
|
|
297
|
+
image: node:${NODE_VERSION}-${OS}
|
|
298
|
+
script:
|
|
299
|
+
- npm test
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### DAG (Directed Acyclic Graph)
|
|
303
|
+
|
|
304
|
+
```yaml
|
|
305
|
+
# Define explicit dependencies (faster than stage-based)
|
|
306
|
+
build:frontend:
|
|
307
|
+
stage: build
|
|
308
|
+
script: npm run build:frontend
|
|
309
|
+
|
|
310
|
+
build:backend:
|
|
311
|
+
stage: build
|
|
312
|
+
script: npm run build:backend
|
|
313
|
+
|
|
314
|
+
test:frontend:
|
|
315
|
+
stage: test
|
|
316
|
+
needs: [build:frontend] # Only waits for frontend build
|
|
317
|
+
script: npm run test:frontend
|
|
318
|
+
|
|
319
|
+
test:backend:
|
|
320
|
+
stage: test
|
|
321
|
+
needs: [build:backend] # Only waits for backend build
|
|
322
|
+
script: npm run test:backend
|
|
323
|
+
|
|
324
|
+
deploy:
|
|
325
|
+
stage: deploy
|
|
326
|
+
needs: [test:frontend, test:backend]
|
|
327
|
+
script: echo "Deploy"
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Interruptible Pipelines
|
|
331
|
+
|
|
332
|
+
```yaml
|
|
333
|
+
# Cancel running pipelines when new commit pushed
|
|
334
|
+
default:
|
|
335
|
+
interruptible: true
|
|
336
|
+
|
|
337
|
+
# Never interrupt critical jobs
|
|
338
|
+
prod-deploy:
|
|
339
|
+
interruptible: false
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## GitLab Runner Configuration
|
|
345
|
+
|
|
346
|
+
### Runner Selection
|
|
347
|
+
|
|
348
|
+
```yaml
|
|
349
|
+
# Use specific runner by tag
|
|
350
|
+
build:
|
|
351
|
+
tags:
|
|
352
|
+
- docker
|
|
353
|
+
- linux
|
|
354
|
+
|
|
355
|
+
# High-performance jobs
|
|
356
|
+
heavy-test:
|
|
357
|
+
tags:
|
|
358
|
+
- gpu
|
|
359
|
+
- high-memory
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### Resource Limits (Kubernetes Runner)
|
|
363
|
+
|
|
364
|
+
```yaml
|
|
365
|
+
variables:
|
|
366
|
+
KUBERNETES_CPU_REQUEST: "500m"
|
|
367
|
+
KUBERNETES_CPU_LIMIT: "2"
|
|
368
|
+
KUBERNETES_MEMORY_REQUEST: "1Gi"
|
|
369
|
+
KUBERNETES_MEMORY_LIMIT: "4Gi"
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## Decision Trees
|
|
375
|
+
|
|
376
|
+
### Which Cache Policy?
|
|
377
|
+
|
|
378
|
+
```
|
|
379
|
+
Does this job UPDATE dependencies?
|
|
380
|
+
├── Yes → policy: pull-push
|
|
381
|
+
└── No → policy: pull
|
|
382
|
+
└── Is cache critical for job?
|
|
383
|
+
├── Yes → Add fallback_keys
|
|
384
|
+
└── No → policy: pull
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### When to Use `needs` vs Stages?
|
|
388
|
+
|
|
389
|
+
```
|
|
390
|
+
Are jobs independent within a stage?
|
|
391
|
+
├── Yes → Use needs (DAG) for parallelism
|
|
392
|
+
└── No → Traditional stages are fine
|
|
393
|
+
└── Complex dependencies?
|
|
394
|
+
└── Yes → DAG with explicit needs
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
## Anti-Patterns (DON'T)
|
|
400
|
+
|
|
401
|
+
| ❌ Anti-Pattern | ✅ Correct Approach |
|
|
402
|
+
| ---------------------------------- | ----------------------------------- |
|
|
403
|
+
| `image: node:latest` | Pin version: `node:20-alpine` |
|
|
404
|
+
| No caching | Cache `node_modules`, `.cache` dirs |
|
|
405
|
+
| Secrets in `.gitlab-ci.yml` | Use CI/CD variables (masked) |
|
|
406
|
+
| Single job does everything | Split into stages |
|
|
407
|
+
| No `expire_in` for artifacts | Set expiration to save storage |
|
|
408
|
+
| `allow_failure: true` everywhere | Only for non-critical jobs |
|
|
409
|
+
| Hardcoded URLs/versions | Use variables |
|
|
410
|
+
| `only` without `except` or `rules` | Prefer `rules:` for clarity |
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
## Common Issues & Fixes
|
|
415
|
+
|
|
416
|
+
| Issue | Cause | Fix |
|
|
417
|
+
| -------------------------- | --------------------------------- | ---------------------------------------- |
|
|
418
|
+
| **Cache miss every time** | Wrong cache key | Use `${CI_COMMIT_REF_SLUG}` |
|
|
419
|
+
| **Artifacts not found** | Job not in `needs`/`dependencies` | Add explicit dependency |
|
|
420
|
+
| **Slow Docker builds** | No layer caching | Use `--cache-from` previous image |
|
|
421
|
+
| **Runner timeout** | Job exceeds limit | Increase timeout or optimize job |
|
|
422
|
+
| **Protected variable N/A** | Not on protected branch | Unprotect variable or use correct branch |
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
## 🔴 Self-Check Before Completing
|
|
427
|
+
|
|
428
|
+
| Check | Question |
|
|
429
|
+
| ------------------------ | ---------------------------------------- |
|
|
430
|
+
| ✅ **Images pinned?** | Using specific versions, not `:latest`? |
|
|
431
|
+
| ✅ **Cache configured?** | Dependencies cached with correct policy? |
|
|
432
|
+
| ✅ **Secrets secure?** | Using CI/CD variables, not hardcoded? |
|
|
433
|
+
| ✅ **Artifacts expire?** | `expire_in` set to reasonable duration? |
|
|
434
|
+
| ✅ **Security scans?** | SAST/Dependency scanning enabled? |
|
|
435
|
+
| ✅ **Rules clear?** | Using `rules:` instead of `only/except`? |
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
439
|
+
## Related Skills
|
|
440
|
+
|
|
441
|
+
| Need | Skill |
|
|
442
|
+
| ----------------- | ----------------------- |
|
|
443
|
+
| GitHub Actions | `github-actions` |
|
|
444
|
+
| Docker builds | `docker-patterns` |
|
|
445
|
+
| Kubernetes deploy | `kubernetes-patterns` |
|
|
446
|
+
| Security scanning | `security-fundamentals` |
|
|
447
|
+
| Terraform in CI | `terraform-patterns` |
|
|
448
|
+
|
|
449
|
+
---
|
|
450
|
+
|
|
451
|
+
## GitLab vs GitHub Actions
|
|
452
|
+
|
|
453
|
+
| Feature | GitLab CI | GitHub Actions |
|
|
454
|
+
| --------------- | ---------------------------- | ---------------------------- |
|
|
455
|
+
| **Config file** | `.gitlab-ci.yml` | `.github/workflows/*.yml` |
|
|
456
|
+
| **Trigger** | `rules:`, `only:`, `except:` | `on:` events |
|
|
457
|
+
| **Caching** | Built-in `cache:` keyword | `actions/cache@v4` |
|
|
458
|
+
| **Artifacts** | `artifacts:` keyword | `actions/upload-artifact` |
|
|
459
|
+
| **Secrets** | CI/CD Variables | Repository Secrets |
|
|
460
|
+
| **Templates** | `include:` templates | Reusable workflows |
|
|
461
|
+
| **Runners** | Shared or self-hosted | GitHub-hosted or self-hosted |
|
|
462
|
+
| **DAG** | `needs:` keyword | `needs:` in jobs |
|
|
463
|
+
|
|
464
|
+
---
|
|
465
|
+
|
|
466
|
+
> **Remember:** A well-designed GitLab CI pipeline is invisible to developers - it just works. Push code, get feedback, ship with confidence. The best pipeline is the one you never have to debug.
|