-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
158 lines (143 loc) · 4.27 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
158 lines (143 loc) · 4.27 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
# =============================================================================
# Zara Agent — GitLab CI/CD Pipeline
#
# MR: lint + test (fast feedback)
# Main: lint + test + release (bump version, changelog, tag) + mirror to GitHub
# =============================================================================
workflow:
rules:
- if: $CI_PIPELINE_DISABLED == "true"
when: never
- if: $CI_COMMIT_TAG
when: never
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
stages:
- lint
- test
- release
variables:
GIT_DEPTH: 0
CI_PIPELINE_DISABLED: "true"
GIT_STRATEGY: clone
BUMP_SCRIPT: scripts/bump-version.sh
NODE_IMAGE: node:22-slim
# =============================================================================
# Lint stage — fast, cheap checks first
# =============================================================================
lint:json:
stage: lint
image: python:3.12-alpine
script:
- python3 -m json.tool version.json
- python3 -m json.tool opencode.json
- python3 -m json.tool package.json
lint:syntax:
stage: lint
image: $NODE_IMAGE
script:
- |
echo "Checking .mjs syntax..."
ERRORS=0
for f in $(find tools .opencode/plugin -name '*.mjs' -type f); do
if ! node --check "$f" 2>/dev/null; then
echo "FAIL: $f"
ERRORS=$((ERRORS + 1))
fi
done
echo "Checked $(find tools .opencode/plugin -name '*.mjs' -type f | wc -l) files"
if [ "$ERRORS" -gt 0 ]; then
echo "$ERRORS file(s) failed syntax check"
exit 1
fi
echo "All syntax OK"
lint:script:
stage: lint
image: bash:5
script:
- bash -n "$BUMP_SCRIPT"
- echo "Syntax OK"
rules:
- changes:
- scripts/bump-version.sh
# =============================================================================
# Test stage — unit tests, structural validation
# =============================================================================
test:unit:
stage: test
image: $NODE_IMAGE
before_script:
- npm ci --ignore-scripts 2>/dev/null || npm install --ignore-scripts
script:
- node --test --test-concurrency=1 tests/*.test.mjs
test:behavioral-eval:
stage: test
image: $NODE_IMAGE
before_script:
- npm ci --ignore-scripts 2>/dev/null || npm install --ignore-scripts
script:
- node --test tests/behavioral-eval.test.mjs
test:structure:
stage: test
image: bash:5
before_script:
- apk add --no-cache git bash
- git clone --depth 1 https://github.com/bats-core/bats-core.git /tmp/bats
- /tmp/bats/install.sh /usr/local
script:
- bats tests/test_structure.bats tests/test_prompts.bats
# =============================================================================
# Release stage — only on main, after all checks pass
# =============================================================================
bump-version:
stage: release
image: bash:5
needs:
- lint:json
- lint:syntax
- test:unit
- test:structure
before_script:
- apk add --no-cache git python3
- git config user.name "zara-bot"
- git config user.email "zara@zara-agent-opc"
- git checkout "$CI_COMMIT_SHA"
script:
- |
bash "$BUMP_SCRIPT" \
--token "${RELEASE_TOKEN}" \
--remote "origin" \
--branch "${CI_DEFAULT_BRANCH}"
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
verify-tag:
stage: release
image: bash:5
needs:
- bump-version
script:
- apk add --no-cache git
- git fetch --tags origin
- |
LATEST_TAG=$(git tag --sort=-v:refname | head -1)
echo "Latest tag: $LATEST_TAG"
if [ -z "$LATEST_TAG" ]; then
echo "No tag created — check bump-version output"
exit 1
fi
echo "Release verified: $LATEST_TAG"
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
mirror-github:
stage: release
image: bash:5
needs:
- bump-version
script:
- apk add --no-cache git
- git fetch --tags origin
- git remote add github "https://x-access-token:${GITHUB_TOKEN}@github.com/aldok10/zara-agent-opc.git"
- git push github "HEAD:refs/heads/$CI_DEFAULT_BRANCH" --follow-tags --force
- echo "Mirrored to GitHub with tags"
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH