Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 chore(ci): support tokenless codecov upload for fork PRs (#11354)

YuTengjing98d477b22b37
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 5920327f48d..82dbff80a0f 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -61,26 +61,41 @@ jobs:
- name: Upload coverage to Codecov
if: always()
+ env:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
curl -Os https://cli.codecov.io/latest/linux/codecov
chmod +x codecov
- TOKEN="${{ secrets.CODECOV_TOKEN }}"
+
+ # Build common args
+ COMMON_ARGS="--git-service github"
+
+ # PR args setup
+ if [ "${{ github.event_name }}" == "pull_request" ]; then
+ COMMON_ARGS="$COMMON_ARGS --pr ${{ github.event.pull_request.number }}"
+ COMMON_ARGS="$COMMON_ARGS --sha ${{ github.event.pull_request.head.sha }}"
+ # Fork PR needs username:branch format for tokenless upload
+ if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
+ COMMON_ARGS="$COMMON_ARGS --branch ${{ github.event.pull_request.head.label }}"
+ else
+ COMMON_ARGS="$COMMON_ARGS --branch ${{ github.event.pull_request.head.ref }}"
+ fi
+ fi
+
+ # Token (if available)
+ if [ -n "$CODECOV_TOKEN" ]; then
+ COMMON_ARGS="$COMMON_ARGS -t $CODECOV_TOKEN"
+ fi
+
for package in $PACKAGES; do
dir="${package#@lobechat/}"
if [ -f "./packages/$dir/coverage/lcov.info" ]; then
echo "Uploading coverage for $dir..."
- if [ -n "$TOKEN" ]; then
- ./codecov upload-process \
- -t "$TOKEN" \
- -f ./packages/$dir/coverage/lcov.info \
- -F packages/$dir \
- --disable-search
- else
- ./codecov upload-process \
- -f ./packages/$dir/coverage/lcov.info \
- -F packages/$dir \
- --disable-search
- fi
+ ./codecov upload-coverage \
+ $COMMON_ARGS \
+ --file ./packages/$dir/coverage/lcov.info \
+ --flag packages/$dir \
+ --disable-search
fi
done
@@ -111,7 +126,7 @@ jobs:
run: bun i
- name: Run tests
- run: bunx vitest --coverage --silent='passed-only' --shard=${{ matrix.shard }}/2
+ run: bunx vitest --coverage --silent='passed-only' --reporter=default --reporter=blob --shard=${{ matrix.shard }}/2
- name: Upload blob report
if: ${{ !cancelled() }}
diff --git a/vitest.config.mts b/vitest.config.mts
index aa092fbae71..982be40b4e4 100644
--- a/vitest.config.mts
+++ b/vitest.config.mts
@@ -92,7 +92,6 @@ export default defineConfig({
'**/e2e/**',
],
globals: true,
- reporters: ['default', 'blob'],
server: {
deps: {
inline: ['vitest-canvas-mock', '@lobehub/ui', '@lobehub/fluent-emoji'],