-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
209 lines (184 loc) · 4.59 KB
/
.gitlab-ci.yml
File metadata and controls
209 lines (184 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# GitLab CI/CD Pipeline for Preference Injector
# RSR-Compliant Multi-Stage Pipeline
variables:
DENO_VERSION: "1.x"
DENO_DIR: ".deno"
stages:
- validate
- test
- build
- security
- deploy
# Templates
.deno_template: &deno_template
image: denoland/deno:alpine
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .deno/
- node_modules/
before_script:
- deno --version
# ============================================================================
# VALIDATION STAGE
# ============================================================================
rsr:compliance:
<<: *deno_template
stage: validate
script:
- echo "🔍 Checking RSR Compliance..."
- deno run --allow-read scripts/rsr-score.ts
allow_failure: false
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
format:check:
<<: *deno_template
stage: validate
script:
- deno fmt --check
allow_failure: false
lint:check:
<<: *deno_template
stage: validate
script:
- deno lint
allow_failure: false
type:check:
<<: *deno_template
stage: validate
script:
- deno check src/**/*.ts
allow_failure: false
# ============================================================================
# TEST STAGE
# ============================================================================
test:unit:
<<: *deno_template
stage: test
script:
- deno test --allow-all --coverage=coverage/
coverage: '/All files\s+\|\s+([\d\.]+)/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage/cobertura.xml
paths:
- coverage/
expire_in: 30 days
test:integration:
<<: *deno_template
stage: test
script:
- deno test --allow-all tests/**/*.integration.test.ts
allow_failure: true # May not exist yet
# ============================================================================
# BUILD STAGE
# ============================================================================
build:typescript:
<<: *deno_template
stage: build
script:
- deno run --allow-all build.ts
artifacts:
paths:
- dist/
expire_in: 7 days
build:rescript:
image: node:20-alpine
stage: build
script:
- npm install -g rescript
- rescript build
artifacts:
paths:
- src/**/*.bs.js
expire_in: 7 days
allow_failure: true # Optional
# ============================================================================
# SECURITY STAGE
# ============================================================================
security:audit:
<<: *deno_template
stage: security
script:
- echo "🔒 Security Audit"
- deno info --json src/deps.ts > sbom.json
artifacts:
paths:
- sbom.json
expire_in: 30 days
allow_failure: true
security:secrets:
image: zricethezav/gitleaks:latest
stage: security
script:
- gitleaks detect --verbose --no-git
allow_failure: true
security:sast:
stage: security
image: returntocorp/semgrep
script:
- semgrep --config=auto --json --output=sast-report.json .
artifacts:
reports:
sast: sast-report.json
expire_in: 30 days
allow_failure: true
# ============================================================================
# DEPLOY STAGE
# ============================================================================
deploy:staging:
<<: *deno_template
stage: deploy
script:
- echo "🚀 Deploying to staging..."
- deno run --allow-all deploy/staging.ts
environment:
name: staging
url: https://staging.example.com
only:
- develop
when: manual
deploy:production:
<<: *deno_template
stage: deploy
script:
- echo "🚀 Deploying to production..."
- deno run --allow-all deploy/production.ts
environment:
name: production
url: https://example.com
only:
- main
- tags
when: manual
# ============================================================================
# PAGES (Documentation)
# ============================================================================
pages:
image: node:20-alpine
stage: deploy
script:
- npm install -g typedoc
- typedoc
- mv docs/api public
artifacts:
paths:
- public
only:
- main
# ============================================================================
# RELEASE
# ============================================================================
release:
image: registry.gitlab.com/gitlab-org/release-cli:latest
stage: deploy
script:
- echo "Creating release $CI_COMMIT_TAG"
release:
tag_name: '$CI_COMMIT_TAG'
description: 'Release $CI_COMMIT_TAG'
only:
- tags