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 needs: lint 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 needs: lint steps: - uses: actions/checkout@v4 - uses: ./.github/actions/init - uses: ./.github/actions/init-bun - name: 'Build tests' run: pnpm exec vite build -c .config/vite.bun.mts - name: 'Run tests' run: cd dist/tests && bun test test-web: runs-on: ubuntu-latest needs: lint strategy: matrix: browser: [chromium, firefox] steps: - uses: actions/checkout@v4 - uses: ./.github/actions/init - name: 'Initialize browser' run: pnpm exec playwright install --with-deps ${{ matrix.browser }} - 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: pnpm run test:browser --browser.name=${{ matrix.browser }} e2e: runs-on: ubuntu-latest needs: [test-node, test-web, test-bun] steps: - uses: actions/checkout@v4 - name: Run end-to-end tests env: API_ID: ${{ secrets.TELEGRAM_API_ID }} API_HASH: ${{ secrets.TELEGRAM_API_HASH }} run: cd e2e && ./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 }} REGISTRY: 'https://npm.tei.su' run: cd e2e && ./cli.sh ci-publish