2024-02-20 00:46:09 +03:00
|
|
|
name: Tests
|
2023-09-21 00:47:57 +03:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [ master ]
|
2023-11-12 01:34:35 +03:00
|
|
|
paths-ignore:
|
|
|
|
- '*.md' # ignore changes to readmes
|
2023-09-21 00:47:57 +03:00
|
|
|
pull_request:
|
|
|
|
branches: [ master ]
|
|
|
|
|
|
|
|
jobs:
|
2023-11-29 20:31:18 +03:00
|
|
|
lint:
|
2023-09-21 00:47:57 +03:00
|
|
|
runs-on: ubuntu-latest
|
2023-11-12 01:34:35 +03:00
|
|
|
if: github.actor != 'mtcute-bot' # do not run after release
|
2023-09-21 00:47:57 +03:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
2023-11-29 20:31:18 +03:00
|
|
|
- uses: ./.github/actions/init
|
2023-09-21 00:47:57 +03:00
|
|
|
- name: 'TypeScript'
|
2023-10-16 19:23:53 +03:00
|
|
|
run: pnpm run lint:tsc:ci
|
2023-09-21 00:47:57 +03:00
|
|
|
- name: 'ESLint'
|
2023-09-24 01:08:01 +03:00
|
|
|
run: pnpm run lint:ci
|
2023-10-09 05:59:48 +03:00
|
|
|
- name: 'Circular dependencies'
|
|
|
|
run: pnpm run lint:dpdm
|
2023-11-29 20:31:18 +03:00
|
|
|
|
|
|
|
test-node:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2024-04-25 11:19:05 +03:00
|
|
|
node-version: [18.x, 20.x, 22.x]
|
2023-11-29 20:31:18 +03:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: ./.github/actions/init
|
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node-version }}
|
|
|
|
- name: 'Run tests'
|
|
|
|
run: pnpm run test:ci
|
2023-11-12 01:34:35 +03:00
|
|
|
- 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
|
2024-04-25 05:31:20 +03:00
|
|
|
|
2024-02-20 00:46:09 +03:00
|
|
|
test-bun:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
2024-03-18 01:49:55 +03:00
|
|
|
- uses: ./.github/actions/init
|
2024-04-25 05:31:20 +03:00
|
|
|
- uses: oven-sh/setup-bun@v1
|
|
|
|
with:
|
|
|
|
bun-version: '1.1.4'
|
2024-03-18 01:49:55 +03:00
|
|
|
- name: 'Build tests'
|
|
|
|
run: pnpm exec vite build -c .config/vite.bun.mts
|
2024-02-20 00:46:09 +03:00
|
|
|
- name: 'Run tests'
|
2024-03-18 01:49:55 +03:00
|
|
|
run: cd dist/tests && bun test
|
2023-11-29 20:31:18 +03:00
|
|
|
|
2024-04-25 05:31:20 +03:00
|
|
|
test-deno:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: ./.github/actions/init
|
|
|
|
- uses: denoland/setup-deno@v1
|
|
|
|
with:
|
2024-05-06 18:31:39 +03:00
|
|
|
deno-version: '1.43.1'
|
2024-04-25 05:31:20 +03:00
|
|
|
- name: 'Build tests'
|
|
|
|
run: pnpm exec vite build -c .config/vite.deno.mts
|
|
|
|
- name: 'Run tests'
|
2024-04-28 22:41:28 +03:00
|
|
|
run: cd dist/tests && deno test -A --unstable-ffi
|
2024-04-25 05:31:20 +03:00
|
|
|
|
2023-11-29 20:31:18 +03:00
|
|
|
test-web:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
browser: [chromium, firefox]
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
2024-04-24 15:30:39 +03:00
|
|
|
- name: 'Build Docker image'
|
|
|
|
run: docker build . -f .github/Dockerfile.test-web --build-arg BROWSER=${{ matrix.browser }} -t mtcute/test-web
|
2023-11-29 20:31:18 +03:00
|
|
|
- name: 'Run tests'
|
2023-12-02 19:24:35 +03:00
|
|
|
# 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
|
2024-04-24 15:30:39 +03:00
|
|
|
command: docker run -e CI=1 mtcute/test-web
|
2023-11-29 20:31:18 +03:00
|
|
|
|
2023-10-16 19:23:53 +03:00
|
|
|
e2e:
|
|
|
|
runs-on: ubuntu-latest
|
2024-04-25 06:04:00 +03:00
|
|
|
needs: [lint, test-node, test-web, test-bun, test-deno]
|
2024-04-13 06:59:12 +03:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
actions: write
|
2023-10-16 19:23:53 +03:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Run end-to-end tests
|
|
|
|
env:
|
|
|
|
API_ID: ${{ secrets.TELEGRAM_API_ID }}
|
|
|
|
API_HASH: ${{ secrets.TELEGRAM_API_HASH }}
|
2024-04-13 07:44:59 +03:00
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2024-04-22 00:05:08 +03:00
|
|
|
run: cd e2e/node && ./cli.sh ci
|
2023-12-19 00:56:44 +03:00
|
|
|
- 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 }}
|
2024-04-13 06:59:12 +03:00
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2023-12-19 00:56:44 +03:00
|
|
|
REGISTRY: 'https://npm.tei.su'
|
2024-04-22 00:05:08 +03:00
|
|
|
run: cd e2e/node && ./cli.sh ci-publish
|
2024-04-23 14:10:18 +03:00
|
|
|
e2e-deno:
|
|
|
|
runs-on: ubuntu-latest
|
2024-04-25 06:04:00 +03:00
|
|
|
needs: [lint, test-node, test-web, test-bun, test-deno]
|
2024-04-23 14:10:18 +03:00
|
|
|
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 }}
|
2024-04-25 12:22:13 +03:00
|
|
|
uses: nick-fields/retry@v2
|
|
|
|
# thanks docker networking very cool
|
|
|
|
with:
|
|
|
|
max_attempts: 3
|
|
|
|
timeout_minutes: 30
|
|
|
|
command: cd e2e/deno && ./cli.sh ci
|