Files
discordeno/.github/workflows/lib-check.yml
T

247 lines
7.3 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: Set codecov flag type to unit
run: echo "CODECOV_FLAG_TYPE=unit" >> "$GITHUB_ENV"
# https://docs.github.com/en/actions/reference/workflows-and-actions/reusing-workflow-configurations#yaml-anchors-and-aliases
# We use anchors to avoid duplicating the codecov download and upload run code
- &codecov-download-cli
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
- &codecov-upload
name: Upload coverage report to codecov
shell: bash
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
GH_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
GH_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
GH_REPO: ${{ github.repository }}
GH_HEAD_LABEL: ${{ github.event.pull_request.head.label }}
GH_PR_NUMBER: ${{ github.event.number }}
run: |
CC_BASE_FLAGS="--disable-search --git-service github"
if [ -n "$GH_HEAD_SHA" ]; then
CC_BASE_FLAGS+=" --sha $GH_HEAD_SHA"
fi
if [ -n "$GH_HEAD_REPO" ] && [ "$GH_HEAD_REPO" != "$GH_REPO" ];
then
echo "Fork detected"
CC_BASE_FLAGS+=" --branch $GH_HEAD_LABEL --pr $GH_PR_NUMBER"
fi
CC_TOKEN=""
CC_LOG_TOKEN=""
if [ -n "$CODECOV_TOKEN" ]; then
echo "CODECOV_TOKEN is set, adding to codecov upload-process command"
CC_TOKEN+=" --token $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="$CC_BASE_FLAGS --file packages/$package/coverage/lcov.info --flag $package-$CODECOV_FLAG_TYPE --flag $package"
echo "Uploading $package converage/lcov.info file"
echo "Running \"./codecov upload-process $CC_LOG_TOKEN $CC_FLAGS\""
# shellcheck disable=SC2086
./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: Set codecov flag type to integration
run: echo "CODECOV_FLAG_TYPE=integration" >> "$GITHUB_ENV"
- *codecov-download-cli
- *codecov-upload
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: Set codecov flag type to e2e
run: echo "CODECOV_FLAG_TYPE=e2e" >> "$GITHUB_ENV"
- *codecov-download-cli
- *codecov-upload