Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make tests compatible with Deno 2.0 #638

Merged
merged 6 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 72 additions & 72 deletions .github/workflows/deno.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,77 +9,77 @@
name: grammY

on:
push:
branches: [main]
pull_request:
branches: [main]
push:
branches: [main]
pull_request:
branches: [main]

jobs:
backport:
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3

- name: Install dependencies
run: npm install --ignore-scripts

- name: Run backporting
run: npm run backport

format-and-lint:
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3

- uses: denoland/setup-deno@main
with:
deno-version: v1.x

- name: Check Format
run: deno fmt --check

- name: Lint
run: deno lint

test:
runs-on: ${{ matrix.os }} # runs a test on Ubuntu, Windows and macOS

strategy:
matrix:
os: [macOS-latest, windows-latest, ubuntu-latest]

steps:
- name: Setup repo
uses: actions/checkout@v3

- uses: denoland/setup-deno@main
with:
deno-version: v1.x

- name: Cache Dependencies
run: deno task check

- name: Run Tests
run: deno task test

coverage:
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: denoland/setup-deno@main
with:
deno-version: v1.x

- name: Create coverage files
run: deno task coverage

- name: Collect coverage
uses: codecov/[email protected] # upload the report on Codecov
with:
file: ./coverage.lcov
backport:
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v4

- name: Install dependencies
run: npm install --ignore-scripts

- name: Run backporting
run: npm run backport

format-and-lint:
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v4

- uses: denoland/setup-deno@2
with:
deno-version: v2.x

- name: Check Format
run: deno fmt --check

- name: Lint
run: deno lint

test:
runs-on: ${{ matrix.os }} # runs a test on Ubuntu, Windows and macOS

strategy:
matrix:
os: [macOS-latest, windows-latest, ubuntu-latest]

steps:
- name: Setup repo
uses: actions/checkout@v4

- uses: denoland/setup-deno@2
with:
deno-version: v2.x

- name: Cache Dependencies
run: deno task check

- name: Run Tests
run: deno task test

coverage:
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: denoland/setup-deno@2
with:
deno-version: v2.x

- name: Create coverage files
run: deno task coverage

- name: Collect coverage
uses: codecov/[email protected] # upload the report on Codecov
with:
file: ./coverage.lcov
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

# Setup deno so we can bundle for the web

- uses: denoland/setup-deno@main
- uses: denoland/setup-deno@2
with:
deno-version: v1.x
deno-version: v2.x

- run: npm install
- run: deno task bundle-web
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/third_party.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ jobs:
- https://raw.githubusercontent.com/grammyjs/docs-bot/main/bot.ts

steps:
- uses: denoland/setup-deno@v1
- uses: denoland/setup-deno@2
with:
deno-version: v1.x
deno-version: v2.x

- name: Create import_map.json
run: |
set -o pipefail;
curl --silent https://cdn.deno.land/grammy/meta/versions.json |
jq '
(.latest / ".")[0] as $major
| .versions
| map(select(startswith($major + ".")) | {
key: @uri "https://deno.land/x/grammy@\(.)/mod.ts",
value: @uri "https://raw.githubusercontent.com/grammyjs/grammY/\(env.GITHUB_SHA)/src/mod.ts"
})
| { imports: from_entries }
' > import_map.json
set -o pipefail;
curl --silent https://cdn.deno.land/grammy/meta/versions.json |
jq '
(.latest / ".")[0] as $major
| .versions
| map(select(startswith($major + ".")) | {
key: @uri "https://deno.land/x/grammy@\(.)/mod.ts",
value: @uri "https://raw.githubusercontent.com/grammyjs/grammY/\(env.GITHUB_SHA)/src/mod.ts"
})
| { imports: from_entries }
' > import_map.json

- run: deno check --import-map=import_map.json --remote ${{ matrix.url }}
- run: deno check --allow-import --import-map=import_map.json --remote ${{ matrix.url }}
1 change: 1 addition & 0 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"lock": false,
"nodeModulesDir": "none",
"tasks": {
"check": "deno cache --check=all src/mod.ts",
"backport": "deno run --no-prompt --allow-read=. --allow-write=. https://deno.land/x/[email protected]/src/cli.ts tsconfig.json",
Expand Down
4 changes: 2 additions & 2 deletions test/core/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ describe("API client", () => {
let api: TransformableApi;
let canUseWebhookReply: boolean;
let response: ApiResponse<{ testValue: number }>;
let fetchStub: Stub<Window & typeof globalThis>;
let fetchStub: Stub<typeof globalThis>;

beforeEach(() => {
fetchStub = stub(
window,
globalThis,
"fetch",
() => Promise.resolve(new Response(JSON.stringify(response))),
);
Expand Down