|
| 1 | +name: CI |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + branches: ['main'] |
| 5 | + paths: |
| 6 | + - 'github/**' |
| 7 | + - 'idl/**' |
| 8 | + - 'frontend/**' |
| 9 | + - 'common/**' |
| 10 | + - 'rush.json' |
| 11 | + # Allows you to run this workflow manually from the Actions tab |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +jobs: |
| 15 | + setup: |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + - NodeVersion: 22.16.0 |
| 20 | + NodeVersionDisplayName: 22 |
| 21 | + OS: ubuntu-latest |
| 22 | + name: Setup and Install Dependencies |
| 23 | + runs-on: ${{ matrix.OS }} |
| 24 | + outputs: |
| 25 | + cache_file: ${{ steps.process-files.outputs.cache_file }} |
| 26 | + matrix_node_version: ${{ matrix.NodeVersion }} |
| 27 | + matrix_os: ${{ matrix.OS }} |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v3 |
| 30 | + with: |
| 31 | + fetch-depth: 1 |
| 32 | + |
| 33 | + - name: Get changed files |
| 34 | + id: changed-files |
| 35 | + uses: tj-actions/changed-files@v45 |
| 36 | + |
| 37 | + - name: Process changed files |
| 38 | + id: process-files |
| 39 | + run: | |
| 40 | + # 获取所有变更文件 |
| 41 | + all_files="${{ steps.changed-files.outputs.all_changed_files }}" |
| 42 | +
|
| 43 | + # 过滤掉 common/changes 目录下的文件 |
| 44 | + filtered_files="" |
| 45 | + for file in $all_files; do |
| 46 | + if [[ ! "$file" =~ ^common/changes/.* ]]; then |
| 47 | + if [ -z "$filtered_files" ]; then |
| 48 | + filtered_files="$file" |
| 49 | + else |
| 50 | + filtered_files="$filtered_files $file" |
| 51 | + fi |
| 52 | + fi |
| 53 | + done |
| 54 | +
|
| 55 | + # 创建 JSON 格式的缓存文件 |
| 56 | + echo "[$( echo "$filtered_files" | sed 's/ /", "/g' | sed 's/^/"/' | sed 's/$/"/' )]" > changed-files-cache.json |
| 57 | +
|
| 58 | + # 输出缓存文件路径供后续步骤使用 |
| 59 | + echo "cache_file=changed-files-cache.json" >> $GITHUB_OUTPUT |
| 60 | +
|
| 61 | + echo "过滤前文件数量: $(echo $all_files | wc -w)" |
| 62 | + echo "过滤后文件数量: $(echo $filtered_files | wc -w)" |
| 63 | + echo "已生成缓存文件: changed-files-cache.json" |
| 64 | +
|
| 65 | + - name: Config Git User |
| 66 | + # should be turn to ci user |
| 67 | + run: | |
| 68 | + git config --local user.name "flow_bot" |
| 69 | + git config --local user.email "flow_bot@bytedance.com" |
| 70 | +
|
| 71 | + - uses: actions/setup-node@v3 |
| 72 | + with: |
| 73 | + node-version: ${{ matrix.NodeVersion }} |
| 74 | + |
| 75 | + - name: Upload changed files cache |
| 76 | + uses: actions/upload-artifact@v4 |
| 77 | + with: |
| 78 | + name: changed-files-cache |
| 79 | + path: changed-files-cache.json |
| 80 | + retention-days: 1 |
| 81 | + |
| 82 | + build: |
| 83 | + needs: setup |
| 84 | + runs-on: ${{ needs.setup.outputs.matrix_os }} |
| 85 | + name: Increment Build |
| 86 | + env: |
| 87 | + BUILD_BRANCH: ${{ github.head_ref || github.ref_name }} |
| 88 | + steps: |
| 89 | + - uses: actions/checkout@v3 |
| 90 | + with: |
| 91 | + fetch-depth: 1 |
| 92 | + |
| 93 | + - uses: actions/setup-node@v3 |
| 94 | + with: |
| 95 | + node-version: ${{ needs.setup.outputs.matrix_node_version }} |
| 96 | + |
| 97 | + - name: Cache |
| 98 | + uses: actions/cache@v4 |
| 99 | + with: |
| 100 | + path: | |
| 101 | + common/temp/pnpm-local |
| 102 | + common/temp/pnpm-store |
| 103 | + common/temp/install-run |
| 104 | + key: ${{ runner.os }}-rush-store-${{ hashFiles('common/config/subspaces/**/pnpm-lock.yaml') }} |
| 105 | + restore-keys: | |
| 106 | + ${{ runner.os }}-rush-store-main |
| 107 | + ${{ runner.os }}-rush-store |
| 108 | +
|
| 109 | + - name: Download changed files cache |
| 110 | + uses: actions/download-artifact@v4 |
| 111 | + with: |
| 112 | + name: changed-files-cache |
| 113 | + |
| 114 | + - name: Install Dependencies |
| 115 | + run: | |
| 116 | + sudo apt-get update |
| 117 | + sudo apt-get install -y libasound2-dev |
| 118 | + node common/scripts/install-run-rush.js install --to tag:core |
| 119 | + node common/scripts/install-run-rush.js update-autoinstaller --name plugins |
| 120 | + node common/scripts/install-run-rush.js increment --action install -p "${{ needs.setup.outputs.cache_file }}" |
| 121 | +
|
| 122 | + - name: Increment Build |
| 123 | + run: node common/scripts/install-run-rush.js increment --action build -p "${{ needs.setup.outputs.cache_file }}" |
| 124 | + |
| 125 | + test: |
| 126 | + needs: setup |
| 127 | + runs-on: ${{ needs.setup.outputs.matrix_os }} |
| 128 | + name: Increment Test Coverage |
| 129 | + steps: |
| 130 | + - uses: actions/checkout@v3 |
| 131 | + with: |
| 132 | + fetch-depth: 1 |
| 133 | + |
| 134 | + - uses: actions/setup-node@v3 |
| 135 | + with: |
| 136 | + node-version: ${{ needs.setup.outputs.matrix_node_version }} |
| 137 | + |
| 138 | + - name: Cache |
| 139 | + uses: actions/cache@v4 |
| 140 | + with: |
| 141 | + path: | |
| 142 | + common/temp/pnpm-local |
| 143 | + common/temp/pnpm-store |
| 144 | + common/temp/install-run |
| 145 | + key: ${{ runner.os }}-rush-store-${{ hashFiles('common/config/subspaces/**/pnpm-lock.yaml') }} |
| 146 | + restore-keys: | |
| 147 | + ${{ runner.os }}-rush-store-main |
| 148 | + ${{ runner.os }}-rush-store |
| 149 | +
|
| 150 | + - name: Download changed files cache |
| 151 | + uses: actions/download-artifact@v4 |
| 152 | + with: |
| 153 | + name: changed-files-cache |
| 154 | + |
| 155 | + - name: Install Dependencies |
| 156 | + run: | |
| 157 | + sudo apt-get update |
| 158 | + sudo apt-get install -y libasound2-dev |
| 159 | + node common/scripts/install-run-rush.js install --to tag:core |
| 160 | + node common/scripts/install-run-rush.js update-autoinstaller --name plugins |
| 161 | + node common/scripts/install-run-rush.js increment --action install -p "${{ needs.setup.outputs.cache_file }}" |
| 162 | +
|
| 163 | + - name: Increment Test:cov |
| 164 | + run: node common/scripts/install-run-rush.js increment --action test:cov -p "${{ needs.setup.outputs.cache_file }}" |
| 165 | + |
| 166 | + - name: Upload coverage reports |
| 167 | + uses: codecov/codecov-action@v4 |
| 168 | + with: |
| 169 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 170 | + fail_ci_if_error: true |
| 171 | + verbose: true |
| 172 | + |
| 173 | + lint: |
| 174 | + needs: setup |
| 175 | + runs-on: ${{ needs.setup.outputs.matrix_os }} |
| 176 | + name: Increment Lint |
| 177 | + steps: |
| 178 | + - uses: actions/checkout@v3 |
| 179 | + with: |
| 180 | + fetch-depth: 1 |
| 181 | + |
| 182 | + - uses: actions/setup-node@v3 |
| 183 | + with: |
| 184 | + node-version: ${{ needs.setup.outputs.matrix_node_version }} |
| 185 | + |
| 186 | + - name: Cache |
| 187 | + uses: actions/cache@v4 |
| 188 | + with: |
| 189 | + path: | |
| 190 | + common/temp/pnpm-local |
| 191 | + common/temp/pnpm-store |
| 192 | + common/temp/install-run |
| 193 | + key: ${{ runner.os }}-rush-store-${{ hashFiles('common/config/subspaces/**/pnpm-lock.yaml') }} |
| 194 | + restore-keys: | |
| 195 | + ${{ runner.os }}-rush-store-main |
| 196 | + ${{ runner.os }}-rush-store |
| 197 | +
|
| 198 | + - name: Download changed files cache |
| 199 | + uses: actions/download-artifact@v4 |
| 200 | + with: |
| 201 | + name: changed-files-cache |
| 202 | + |
| 203 | + - name: Install Dependencies |
| 204 | + run: | |
| 205 | + sudo apt-get update |
| 206 | + sudo apt-get install -y libasound2-dev |
| 207 | + node common/scripts/install-run-rush.js install --to tag:core |
| 208 | + node common/scripts/install-run-rush.js update-autoinstaller --name plugins |
| 209 | + node common/scripts/install-run-rush.js increment --action install -p "${{ needs.setup.outputs.cache_file }}" |
| 210 | +
|
| 211 | + - name: Increment Lint |
| 212 | + run: node common/scripts/install-run-rush.js increment --action lint -p "${{ needs.setup.outputs.cache_file }}" |
| 213 | + |
| 214 | + ts-check: |
| 215 | + needs: setup |
| 216 | + runs-on: ${{ needs.setup.outputs.matrix_os }} |
| 217 | + name: Increment TS Check |
| 218 | + steps: |
| 219 | + - uses: actions/checkout@v3 |
| 220 | + with: |
| 221 | + fetch-depth: 1 |
| 222 | + |
| 223 | + - uses: actions/setup-node@v3 |
| 224 | + with: |
| 225 | + node-version: ${{ needs.setup.outputs.matrix_node_version }} |
| 226 | + |
| 227 | + - name: Cache |
| 228 | + uses: actions/cache@v4 |
| 229 | + with: |
| 230 | + path: | |
| 231 | + common/temp/pnpm-local |
| 232 | + common/temp/pnpm-store |
| 233 | + common/temp/install-run |
| 234 | + key: ${{ runner.os }}-rush-store-${{ hashFiles('common/config/subspaces/**/pnpm-lock.yaml') }} |
| 235 | + restore-keys: | |
| 236 | + ${{ runner.os }}-rush-store-main |
| 237 | + ${{ runner.os }}-rush-store |
| 238 | +
|
| 239 | + - name: Download changed files cache |
| 240 | + uses: actions/download-artifact@v4 |
| 241 | + with: |
| 242 | + name: changed-files-cache |
| 243 | + |
| 244 | + - name: Install Dependencies |
| 245 | + run: | |
| 246 | + sudo apt-get update |
| 247 | + sudo apt-get install -y libasound2-dev |
| 248 | + node common/scripts/install-run-rush.js install --to tag:core |
| 249 | + node common/scripts/install-run-rush.js update-autoinstaller --name plugins |
| 250 | + node common/scripts/install-run-rush.js increment --action install -p "${{ needs.setup.outputs.cache_file }}" |
| 251 | +
|
| 252 | + - name: Increment TS Check |
| 253 | + run: node common/scripts/install-run-rush.js increment --action ts-check -p "${{ needs.setup.outputs.cache_file }}" |
| 254 | + |
| 255 | + package-audit: |
| 256 | + needs: setup |
| 257 | + runs-on: ${{ needs.setup.outputs.matrix_os }} |
| 258 | + name: Increment Package Audit |
| 259 | + steps: |
| 260 | + - uses: actions/checkout@v3 |
| 261 | + with: |
| 262 | + fetch-depth: 1 |
| 263 | + |
| 264 | + - uses: actions/setup-node@v3 |
| 265 | + with: |
| 266 | + node-version: ${{ needs.setup.outputs.matrix_node_version }} |
| 267 | + |
| 268 | + - name: Cache |
| 269 | + uses: actions/cache@v4 |
| 270 | + with: |
| 271 | + path: | |
| 272 | + common/temp/pnpm-local |
| 273 | + common/temp/pnpm-store |
| 274 | + common/temp/install-run |
| 275 | + key: ${{ runner.os }}-rush-store-${{ hashFiles('common/config/subspaces/**/pnpm-lock.yaml') }} |
| 276 | + restore-keys: | |
| 277 | + ${{ runner.os }}-rush-store-main |
| 278 | + ${{ runner.os }}-rush-store |
| 279 | +
|
| 280 | + - name: Download changed files cache |
| 281 | + uses: actions/download-artifact@v4 |
| 282 | + with: |
| 283 | + name: changed-files-cache |
| 284 | + |
| 285 | + - name: Install Dependencies |
| 286 | + run: | |
| 287 | + sudo apt-get update |
| 288 | + sudo apt-get install -y libasound2-dev |
| 289 | + node common/scripts/install-run-rush.js install --to tag:core |
| 290 | + node common/scripts/install-run-rush.js update-autoinstaller --name plugins |
| 291 | + node common/scripts/install-run-rush.js increment --action install -p "${{ needs.setup.outputs.cache_file }}" |
| 292 | +
|
| 293 | + - name: Increment Package Audit |
| 294 | + run: node common/scripts/install-run-rush.js increment --action package-audit -p "${{ needs.setup.outputs.cache_file }}" |
0 commit comments