mirror of
https://github.com/zhigang1992/mtcute.git
synced 2026-04-29 04:35:08 +08:00
ci: move to forgejo actions
This commit is contained in:
@@ -1,14 +1,6 @@
|
||||
inputs:
|
||||
node-version:
|
||||
default: '18.x'
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Use Node.js ${{ inputs.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ inputs.node-version }}
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
37
.forgejo/workflows/docs.yaml
Normal file
37
.forgejo/workflows/docs.yaml
Normal file
@@ -0,0 +1,37 @@
|
||||
name: Docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: pages
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: node22
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.forgejo/actions/init
|
||||
- name: Build
|
||||
env:
|
||||
BUILD_FOR_DOCS: 1
|
||||
run: pnpm run -r --workspace-concurrency=1 build
|
||||
- name: Build docs
|
||||
run: |
|
||||
pnpm run docs
|
||||
touch docs/.nojekyll
|
||||
echo "ref.mtcute.dev" > docs/CNAME
|
||||
- name: Deploy
|
||||
# do not run on forks and releases
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.actor == 'desu-bot'
|
||||
uses: https://github.com/cloudflare/wrangler-action@v3
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
command: pages deploy docs --project-name=mtcute-apiref
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
- if: ${{ github.event.inputs.branch != 'master' }}
|
||||
run: git checkout ${{ github.event.inputs.branch }}
|
||||
|
||||
- uses: ./.github/actions/init
|
||||
- uses: ./.forgejo/actions/init
|
||||
- uses: denoland/setup-deno@v1
|
||||
with:
|
||||
deno-version: '2.0'
|
||||
@@ -10,17 +10,11 @@ on:
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: node22
|
||||
if: github.actor != 'mtcute-bot' # do not run after release
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Fetch fuman
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: teidesu/fuman
|
||||
path: private/fuman
|
||||
token: ${{ secrets.BOT_PAT }}
|
||||
- uses: ./.github/actions/init
|
||||
- uses: ./.forgejo/actions/init
|
||||
- name: 'TypeScript'
|
||||
run: pnpm run lint:tsc:ci
|
||||
- name: 'ESLint'
|
||||
@@ -29,31 +23,21 @@ jobs:
|
||||
run: pnpm run lint:dpdm
|
||||
|
||||
test-node:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [18.x, 20.x, 22.x]
|
||||
node-version: [node18, node20, node22]
|
||||
runs-on: ${{ matrix.node-version }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/init
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- uses: ./.forgejo/actions/init
|
||||
- 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
|
||||
runs-on: node22
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/init
|
||||
- uses: ./.forgejo/actions/init
|
||||
- uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: '1.1.4'
|
||||
@@ -63,11 +47,11 @@ jobs:
|
||||
run: cd dist/tests && bun test
|
||||
|
||||
test-deno:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: node22
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/init
|
||||
- uses: denoland/setup-deno@v1
|
||||
- uses: ./.forgejo/actions/init
|
||||
- uses: https://github.com/denoland/setup-deno@v1
|
||||
with:
|
||||
deno-version: '2.0'
|
||||
- name: 'Build tests'
|
||||
@@ -76,33 +60,34 @@ jobs:
|
||||
run: cd dist/tests && deno test -A --unstable-ffi --node-modules-dir=false
|
||||
|
||||
test-web:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: docker
|
||||
container: mcr.microsoft.com/playwright:v1.42.1
|
||||
|
||||
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
|
||||
- run: apt-get update && apt-get install -y make gcc g++
|
||||
- uses: ./.forgejo/actions/init
|
||||
- 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
|
||||
uses: https://github.com/nick-fields/retry@v2
|
||||
with:
|
||||
max_attempts: 3
|
||||
timeout_minutes: 30
|
||||
command: docker run -e CI=1 mtcute/test-web
|
||||
|
||||
command: pnpm run test:browser --browser.name=${{ matrix.browser }}
|
||||
|
||||
e2e:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: node22
|
||||
needs: [lint, test-node, test-web, test-bun, test-deno]
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/init
|
||||
- uses: ./.forgejo/actions/init
|
||||
- name: Run end-to-end tests
|
||||
env:
|
||||
API_ID: ${{ secrets.TELEGRAM_API_ID }}
|
||||
@@ -112,15 +97,15 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: 'cd e2e && pnpm run test:all'
|
||||
e2e-deno:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: node22
|
||||
needs: [lint, test-node, test-web, test-bun, test-deno]
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/init
|
||||
- uses: denoland/setup-deno@v1
|
||||
- uses: ./.forgejo/actions/init
|
||||
- uses: https://github.com/denoland/setup-deno@v1
|
||||
with:
|
||||
deno-version: '2.0'
|
||||
- name: Run end-to-end tests under Deno
|
||||
@@ -130,19 +115,4 @@ jobs:
|
||||
SESSION_DC1: ${{ secrets.SESSION_DC1 }}
|
||||
SESSION_DC2: ${{ secrets.SESSION_DC2 }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: 'cd e2e && deno task test:all'
|
||||
|
||||
cr:
|
||||
needs:
|
||||
- e2e-deno
|
||||
- e2e
|
||||
runs-on: ubuntu-latest
|
||||
# dont run on forks or release commits
|
||||
if: github.repository == 'mtcute/mtcute' && github.actor != 'mtcute-bot'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/init
|
||||
- name: 'publish to pkg.pr.new'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: pnpx fuman-build cr
|
||||
run: 'cd e2e && deno task test:all'
|
||||
18
.github/Dockerfile.test-web
vendored
18
.github/Dockerfile.test-web
vendored
@@ -1,18 +0,0 @@
|
||||
FROM node:20
|
||||
WORKDIR /app
|
||||
|
||||
ARG BROWSER
|
||||
|
||||
RUN corepack enable && \
|
||||
corepack prepare pnpm@9.0.6 --activate
|
||||
|
||||
COPY ../ /app/
|
||||
|
||||
RUN pnpm install --frozen-lockfile && \
|
||||
pnpm -C packages/tl run gen-code && \
|
||||
pnpm exec playwright install --with-deps $BROWSER
|
||||
|
||||
ENV BROWSER="$BROWSER"
|
||||
|
||||
ENTRYPOINT [ "pnpm", "run", "test:browser" ]
|
||||
CMD [ "--browser.name=$BROWSER" ]
|
||||
6
.github/codecov.yaml
vendored
6
.github/codecov.yaml
vendored
@@ -1,6 +0,0 @@
|
||||
coverage:
|
||||
status:
|
||||
patch: off
|
||||
project:
|
||||
default:
|
||||
threshold: 1%
|
||||
55
.github/workflows/docs.yaml
vendored
55
.github/workflows/docs.yaml
vendored
@@ -1,55 +0,0 @@
|
||||
name: Docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: pages
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/init
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v3
|
||||
- name: Build
|
||||
env:
|
||||
BUILD_FOR_DOCS: 1
|
||||
run: pnpm run -r --workspace-concurrency=1 build
|
||||
- name: Build docs
|
||||
run: |
|
||||
pnpm run docs
|
||||
touch docs/.nojekyll
|
||||
echo "ref.mtcute.dev" > docs/CNAME
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v2
|
||||
with:
|
||||
path: docs
|
||||
|
||||
# Deployment job
|
||||
deploy:
|
||||
# only run on releases
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.actor == 'mtcute-bot'
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
name: Deploy
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v2
|
||||
@@ -31,6 +31,6 @@ describe('2. calling methods', () => {
|
||||
|
||||
expect(history[0].chat.type).to.equal('user')
|
||||
expect(history[0].chat.id).to.equal(777000)
|
||||
expect(history[0].chat.displayName).to.equal('Telegram')
|
||||
expect(history[0].chat.displayName).to.match(/^Telegram(?: Notifications)?$/)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user