-
Notifications
You must be signed in to change notification settings - Fork 13
148 lines (127 loc) · 4.02 KB
/
Copy pathci.yml
File metadata and controls
148 lines (127 loc) · 4.02 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
name: CI
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint-and-test:
name: Lint & Test (Node ${{ matrix.node-version }} on ${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
node-version: [20, 22]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Type check
run: npx tsc --noEmit
- name: Unit tests with coverage
run: npx vitest run --coverage
- name: Upload coverage
if: matrix.os == 'ubuntu-latest' && matrix.node-version == 20
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage/
build:
name: Build
needs: lint-and-test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Build
run: npm run build
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
e2e:
name: E2E (GitHub provider, full surface)
needs: build
runs-on: ubuntu-latest
# E2E shares one fixture repo. Serialize across all branches/PRs so
# concurrent runs don't trample each other's state. Don't cancel
# in-progress jobs — let them finish to leave the fixture clean.
concurrency:
group: e2e-fixture-repo
cancel-in-progress: false
# Skip e2e when secrets aren't configured (e.g. PRs from forks).
if: ${{ vars.TEAMAI_TEST_REPO_URL != '' }}
env:
TEAMAI_TEST_PROVIDER: github
TEAMAI_TEST_REPO_URL: ${{ vars.TEAMAI_TEST_REPO_URL }}
TEAMAI_TEST_TOKEN: ${{ secrets.TEAMAI_TEST_TOKEN }}
# The CLI's GitHub provider auto-picks up GITHUB_TOKEN for auth.
GITHUB_TOKEN: ${{ secrets.TEAMAI_TEST_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Build
run: npm run build
- name: Configure git identity (CI commits)
run: |
git config --global user.email "ci@teamai.test"
git config --global user.name "TeamAI CI"
- name: Prepare teamai config (user scope)
run: |
set -e
mkdir -p "$HOME/.teamai"
REPO_LOCAL="$HOME/.teamai/team-repo"
case "$TEAMAI_TEST_REPO_URL" in
http://*|https://*) CLONE_URL="$TEAMAI_TEST_REPO_URL" ;;
*) CLONE_URL="https://github.com/${TEAMAI_TEST_REPO_URL}.git" ;;
esac
AUTH_URL="${CLONE_URL/https:\/\//https:\/\/x-access-token:${TEAMAI_TEST_TOKEN}@}"
git clone "$AUTH_URL" "$REPO_LOCAL"
cat > "$HOME/.teamai/config.yaml" <<EOF
repo:
localPath: "$REPO_LOCAL"
remote: "$TEAMAI_TEST_REPO_URL"
username: ci
updatePolicy: auto
EOF
- name: Run E2E (full surface)
run: npx vitest run --config vitest.e2e.config.ts --reporter=verbose
- name: Cleanup fixture repo state on failure
if: failure()
run: |
# Leave the fixture branch clean for the next CI run.
REPO_LOCAL="$HOME/.teamai/team-repo"
if [ -d "$REPO_LOCAL/.git" ]; then
cd "$REPO_LOCAL"
git reset --hard HEAD || true
git clean -fdx || true
fi