126 lines
3.7 KiB
YAML
126 lines
3.7 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
paths-ignore:
|
|
- '*.md' # ignore changes to readmes
|
|
pull_request:
|
|
branches: [ master ]
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
if: github.actor != 'mtcute-bot' # do not run after release
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: ./.github/actions/init
|
|
- name: 'TypeScript'
|
|
run: pnpm run lint:tsc:ci
|
|
- name: 'ESLint'
|
|
run: pnpm run lint:ci
|
|
- name: 'Circular dependencies'
|
|
run: pnpm run lint:dpdm
|
|
|
|
test-node:
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
node-version: [18.x, 20.x]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: ./.github/actions/init
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
- name: 'Run tests'
|
|
run: pnpm run test:ci
|
|
- name: Upload coverage reports to Codecov
|
|
uses: codecov/codecov-action@v3
|
|
if: ${{ matrix.node-version == '18.x' }} # to avoid uploading twice
|
|
env:
|
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
with:
|
|
files: ./coverage/coverage-final.json
|
|
|
|
test-bun:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: ./.github/actions/init
|
|
- uses: oven-sh/setup-bun@v1
|
|
with:
|
|
bun-version: '1.1.4'
|
|
- name: 'Build tests'
|
|
run: pnpm exec vite build -c .config/vite.bun.mts
|
|
- name: 'Run tests'
|
|
run: cd dist/tests && bun test
|
|
|
|
test-deno:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: ./.github/actions/init
|
|
- uses: denoland/setup-deno@v1
|
|
with:
|
|
deno-version: 2f5a6a8514ad8eadce1a0a9f1a7a419692e337ef
|
|
- name: 'Build tests'
|
|
run: pnpm exec vite build -c .config/vite.deno.mts
|
|
- name: 'Run tests'
|
|
run: cd dist/tests && deno test
|
|
|
|
test-web:
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
browser: [chromium, firefox]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: 'Build Docker image'
|
|
run: docker build . -f .github/Dockerfile.test-web --build-arg BROWSER=${{ matrix.browser }} -t mtcute/test-web
|
|
- name: 'Run tests'
|
|
# i wish we didn't have to do this, but vitest in browser is very flaky
|
|
# see: https://github.com/vitest-dev/vitest/issues/4173
|
|
uses: nick-fields/retry@v2
|
|
with:
|
|
max_attempts: 3
|
|
timeout_minutes: 30
|
|
command: docker run -e CI=1 mtcute/test-web
|
|
|
|
e2e:
|
|
runs-on: ubuntu-latest
|
|
needs: [lint, test-node, test-web, test-bun, test-deno]
|
|
permissions:
|
|
contents: read
|
|
actions: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Run end-to-end tests
|
|
env:
|
|
API_ID: ${{ secrets.TELEGRAM_API_ID }}
|
|
API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: cd e2e/node && ./cli.sh ci
|
|
- name: Publish to canary NPM
|
|
if: github.repository == 'mtcute/mtcute' # do not run on forks
|
|
continue-on-error: true
|
|
env:
|
|
NPM_TOKEN: ${{ secrets.CANARY_NPM_TOKEN }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
REGISTRY: 'https://npm.tei.su'
|
|
run: cd e2e/node && ./cli.sh ci-publish
|
|
e2e-deno:
|
|
runs-on: ubuntu-latest
|
|
needs: [lint, test-node, test-web, test-bun, test-deno]
|
|
permissions:
|
|
contents: read
|
|
actions: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Run end-to-end tests under Deno
|
|
env:
|
|
API_ID: ${{ secrets.TELEGRAM_API_ID }}
|
|
API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: cd e2e/deno && ./cli.sh ci
|