Files
discordeno/.github/workflows/lib-check.yml
T
Fleny 22ab1b20de ci: fix codecov upload for forks (#5240)
* ci: fix codecov upload for forks

* Remove 'fail-on-error' flag from CC_FLAGS
2026-07-26 22:13:54 +05:30

315 lines
10 KiB
YAML

name: Library Checks
permissions:
contents: read
on:
pull_request:
push:
branches:
- main
merge_group:
jobs:
build-type-and-test:
name: Build Type and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
cache: yarn
- run: yarn install --immutable
- name: Cache for Turbo
uses: rharkor/caching-for-turbo@v2.5.1
with:
cache-prefix: turbo-cache-
- name: Build Types
run: yarn build:type
build-dist:
name: Build Dist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
cache: yarn
- run: yarn install --immutable
- name: Cache for Turbo
uses: rharkor/caching-for-turbo@v2.5.1
with:
cache-prefix: turbo-cache-
- name: Build Dist
run: yarn build
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
cache: yarn
- run: yarn install --immutable
- name: Cache for Turbo
uses: rharkor/caching-for-turbo@v2.5.1
with:
cache-prefix: turbo-cache-
- name: Build Types
run: yarn build:type
- name: Check Formatting
run: yarn biome ci --reporter=github
test-type-unit-and-integration-test:
name: Typecheck Tests
runs-on: ubuntu-latest
needs: build-type-and-test
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
cache: yarn
- run: yarn install --immutable
- name: Cache for Turbo
uses: rharkor/caching-for-turbo@v2.5.1
with:
cache-prefix: turbo-cache-
- name: Test Type Test
run: yarn test:test-type
unit-tests:
name: Unit Tests
needs: [build-dist]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
cache: yarn
- run: yarn install --immutable
- name: Cache for Turbo
uses: rharkor/caching-for-turbo@v2.5.1
with:
cache-prefix: turbo-cache-
- run: yarn test:unit
- name: Download and verify codecov cli
run: |
curl https://keybase.io/codecovsecops/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
curl -Os https://cli.codecov.io/latest/linux/codecov
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM.sig
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
shasum -a 256 -c codecov.SHA256SUM
sudo chmod +x codecov
- name: Upload coverage report to codecov
shell: bash
run: |
CC_FLAGS="--disable-search --git-service github"
if [ -n "${{ github.event.pull_request.head.sha }}" ]; then
CC_FLAGS+=" --sha ${{ github.event.pull_request.head.sha }}"
fi
if [ -n "${{ github.event.pull_request.head.repo.full_name }}" ] && [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ];
then
echo "Fork detected"
CC_FLAGS+=" --branch ${{ github.event.pull_request.head.label }} --pr ${{ github.event.number }}"
fi
CC_TOKEN=""
CC_LOG_TOKEN=""
if [ -n "${{ secrets.CODECOV_TOKEN }}" ]; then
echo "CODECOV_TOKEN is set, adding to codecov upload-process command"
CC_TOKEN+=" --token ${{ secrets.CODECOV_TOKEN }}"
CC_LOG_TOKEN+=" --token ***"
fi
find packages/ -name "lcov.info" -type f | awk -F'/' '{ print $2 }' | while read -r package; do
sed -i "s|SF:src|SF:packages/${package}/src|g" "packages/$package/coverage/lcov.info"
CC_FLAGS+=" --file packages/$package/coverage/lcov.info --flag $package-unit --flag $package"
echo "Uploading $package converage/lcov.info file"
echo "Running \"./codecov upload-process $CC_LOG_TOKEN $CC_FLAGS\""
./codecov upload-process $CC_TOKEN $CC_FLAGS
done
unit-tests-deno:
name: Deno Unit Tests
needs: [build-dist, unit-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
cache: yarn
- uses: denoland/setup-deno@v2
with:
deno-version: 'v2.9.x'
- run: yarn install --immutable
- name: Cache for Turbo
uses: rharkor/caching-for-turbo@v2.5.1
with:
cache-prefix: turbo-cache-
- run: yarn test:deno-unit
unit-tests-bun:
name: Bun Unit Tests
needs: [build-dist, unit-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
cache: yarn
- uses: oven-sh/setup-bun@v2
with:
bun-version: '1.3.14'
- run: yarn install --immutable
- name: Cache for Turbo
uses: rharkor/caching-for-turbo@v2.5.1
with:
cache-prefix: turbo-cache-
- run: yarn test:bun-unit
integration-tests:
name: Integration Tests
needs: [build-dist]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
cache: yarn
- run: yarn install --immutable
- name: Cache for Turbo
uses: rharkor/caching-for-turbo@v2.5.1
with:
cache-prefix: turbo-cache-
- run: yarn test:integration
- name: Download and verify codecov cli
run: |
curl https://keybase.io/codecovsecops/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
curl -Os https://cli.codecov.io/latest/linux/codecov
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM.sig
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
shasum -a 256 -c codecov.SHA256SUM
sudo chmod +x codecov
- name: Upload coverage report to codecov
shell: bash
run: |
CC_FLAGS="--disable-search --git-service github"
if [ -n "${{ github.event.pull_request.head.sha }}" ]; then
CC_FLAGS+=" --sha ${{ github.event.pull_request.head.sha }}"
fi
if [ -n "${{ github.event.pull_request.head.repo.full_name }}" ] && [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ];
then
echo "Fork detected"
CC_FLAGS+=" --branch ${{ github.event.pull_request.head.label }} --pr ${{ github.event.number }}"
fi
CC_TOKEN=""
CC_LOG_TOKEN=""
if [ -n "${{ secrets.CODECOV_TOKEN }}" ]; then
echo "CODECOV_TOKEN is set, adding to codecov upload-process command"
CC_TOKEN+=" --token ${{ secrets.CODECOV_TOKEN }}"
CC_LOG_TOKEN+=" --token ***"
fi
find packages/ -name "lcov.info" -type f | awk -F'/' '{ print $2 }' | while read -r package; do
sed -i "s|SF:src|SF:packages/${package}/src|g" "packages/$package/coverage/lcov.info"
CC_FLAGS+=" --file packages/$package/coverage/lcov.info --flag $package-integration --flag $package"
echo "Uploading $package converage/lcov.info file"
echo "Running \"./codecov upload-process $CC_LOG_TOKEN $CC_FLAGS\""
./codecov upload-process $CC_TOKEN $CC_FLAGS
done
e2e-tests:
name: E2E Tests
needs: [build-dist]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
concurrency:
group: e2e-tests
queue: max
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
cache: yarn
- run: yarn install --immutable
- name: Cache for Turbo
uses: rharkor/caching-for-turbo@v2.5.1
with:
cache-prefix: turbo-cache-
- run: yarn test:e2e
env:
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
E2E_TEST_GUILD_ID: ${{ secrets.UNIT_TEST_GUILD_ID }}
- name: Download and verify codecov cli
run: |
curl https://keybase.io/codecovsecops/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
curl -Os https://cli.codecov.io/latest/linux/codecov
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM
curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM.sig
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
shasum -a 256 -c codecov.SHA256SUM
sudo chmod +x codecov
- name: Upload coverage report to codecov
shell: bash
run: |
CC_FLAGS="--disable-search --git-service github"
if [ -n "${{ github.event.pull_request.head.sha }}" ]; then
CC_FLAGS+=" --sha ${{ github.event.pull_request.head.sha }}"
fi
if [ -n "${{ github.event.pull_request.head.repo.full_name }}" ] && [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ];
then
echo "Fork detected"
CC_FLAGS+=" --branch ${{ github.event.pull_request.head.label }} --pr ${{ github.event.number }}"
fi
CC_TOKEN=""
CC_LOG_TOKEN=""
if [ -n "${{ secrets.CODECOV_TOKEN }}" ]; then
echo "CODECOV_TOKEN is set, adding to codecov upload-process command"
CC_TOKEN+=" --token ${{ secrets.CODECOV_TOKEN }}"
CC_LOG_TOKEN+=" --token ***"
fi
find packages/ -name "lcov.info" -type f | awk -F'/' '{ print $2 }' | while read -r package; do
sed -i "s|SF:src|SF:packages/${package}/src|g" "packages/$package/coverage/lcov.info"
CC_FLAGS+=" --file packages/$package/coverage/lcov.info --flag $package-e2e --flag $package"
echo "Uploading $package converage/lcov.info file"
echo "Running \"./codecov upload-process $CC_LOG_TOKEN $CC_FLAGS\""
./codecov upload-process $CC_TOKEN $CC_FLAGS
done