-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (125 loc) · 4.39 KB
/
ci.yml
File metadata and controls
151 lines (125 loc) · 4.39 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
name: CI
on:
push:
branches:
- main
- develop
- "*-[0-9]+.x"
pull_request:
branches:
- main
- develop
- "*-[0-9]+.x"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Test & Build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20, 22, 24]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Validate packages
run: pnpm validate
- name: Test CLI functionality
run: |
cd packages/swarm
node ./bin/cli --help
node ./bin/cli generate --help
- name: Test MCP server functionality
run: |
cd packages/swarm
# Test that MCP server can start and respond to basic commands
timeout 5s node ./bin/mcp start || [ $? -eq 124 ]
generate-changesets:
name: Generate Changesets
needs: test
runs-on: ubuntu-latest
# Run on main and package maintenance branches (*-N.x)
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || endsWith(github.ref, '.x'))
permissions:
contents: write
env:
RELEASE_COMMIT_MESSAGE: "chore: version packages"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Set Git user name and email
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Check if latest commit is a pre-release commit
id: check_release_commit
env:
RELEASE_COMMIT_MESSAGE: ${{ env.RELEASE_COMMIT_MESSAGE }}
run: |
LATEST_COMMIT=$(git log -1 --pretty=%B)
BRANCH_NAME="${{ github.ref_name }}"
# Check if latest commit is a merge commit (has 2 parents)
PARENT_COUNT=$(git log -1 --format=%P | wc -w | tr -d ' ')
if [[ "$PARENT_COUNT" -eq "2" ]]; then
# It's a merge commit, check if it merged from changeset-release branch
# GitHub merge commits contain the branch name in the message
if [[ "$LATEST_COMMIT" == *"changeset-release/"* ]]; then
echo "is_release_commit=true" >> $GITHUB_OUTPUT
echo "Latest commit is a release PR merge, skipping changeset generation"
exit 0
fi
fi
# Also check if the commit message itself is a release commit
if [[ "$LATEST_COMMIT" == "$RELEASE_COMMIT_MESSAGE"* ]]; then
echo "is_release_commit=true" >> $GITHUB_OUTPUT
echo "Latest commit is a release commit, skipping changeset generation"
else
echo "is_release_commit=false" >> $GITHUB_OUTPUT
echo "Latest commit is not a release commit, will generate changesets"
fi
- name: Generate Changesets from commit messages
if: steps.check_release_commit.outputs.is_release_commit != 'true'
run: pnpm changeset:auto
- name: Commit generated changesets
if: steps.check_release_commit.outputs.is_release_commit != 'true'
run: |
git add .changeset
if ! git diff --cached --quiet; then
git commit -m "chore: add changesets for release [skip ci]"
git push
else
echo "No changesets to commit"
fi