Skip to content
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
45 changes: 0 additions & 45 deletions .github/workflows/deno.yml

This file was deleted.

76 changes: 76 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: PR Checks

on:
pull_request:
branches: [main]

permissions:
contents: read

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- uses: actions/cache@v4
with:
path: ~/.cache/deno
key: deno-v2-${{ hashFiles('deno.json', 'deno.lock') }}
restore-keys: deno-v2-
- name: Run linter
run: deno lint

format:
name: Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- uses: actions/cache@v4
with:
path: ~/.cache/deno
key: deno-v2-${{ hashFiles('deno.json', 'deno.lock') }}
restore-keys: deno-v2-
- name: Check format
run: deno fmt --check

typecheck:
name: Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- uses: actions/cache@v4
with:
path: ~/.cache/deno
key: deno-v2-${{ hashFiles('deno.json', 'deno.lock') }}
restore-keys: deno-v2-
- name: Run type check
run: deno check ./main.ts ./handlers/ ./models/ ./utils/

test:
name: Tests
runs-on: ubuntu-latest
needs: [lint, format, typecheck]
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- uses: actions/cache@v4
with:
path: ~/.cache/deno
key: deno-v2-${{ hashFiles('deno.json', 'deno.lock') }}
restore-keys: deno-v2-
- name: Create test db directory
run: mkdir -p db/test_db
- name: Run tests
run: deno test --no-check --allow-write --allow-read --allow-net --allow-env ./tests/*
80 changes: 80 additions & 0 deletions .github/workflows/push-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Push Checks

on:
push:
branches: [main]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- uses: actions/cache@v4
with:
path: ~/.cache/deno
key: deno-v2-${{ hashFiles('deno.json', 'deno.lock') }}
restore-keys: deno-v2-
- name: Run linter
run: deno lint

format:
name: Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- uses: actions/cache@v4
with:
path: ~/.cache/deno
key: deno-v2-${{ hashFiles('deno.json', 'deno.lock') }}
restore-keys: deno-v2-
- name: Check format
run: deno fmt --check

typecheck:
name: Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- uses: actions/cache@v4
with:
path: ~/.cache/deno
key: deno-v2-${{ hashFiles('deno.json', 'deno.lock') }}
restore-keys: deno-v2-
- name: Run type check
run: deno check ./main.ts ./handlers/ ./models/ ./utils/

test:
name: Tests
runs-on: ubuntu-latest
needs: [lint, format, typecheck]
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- uses: actions/cache@v4
with:
path: ~/.cache/deno
key: deno-v2-${{ hashFiles('deno.json', 'deno.lock') }}
restore-keys: deno-v2-
- name: Create test db directory
run: mkdir -p db/test_db
- name: Run tests
run: deno test --no-check --allow-write --allow-read --allow-net --allow-env ./tests/*
24 changes: 1 addition & 23 deletions handlers/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,7 @@ export async function register(conversation: Conversation, ctx: Context) {
await ctx.editMessageText(
`Before we finish, would you like to set a custom 404 image? This image will be shown when viewing entries without a selfie.`,
{
reply_markup: new InlineKeyboard().text("Yes", "set-custom-404").text(
"No",
"skip-custom-404",
),
reply_markup: new InlineKeyboard().text("New Entry", "new-entry"),
},
);

const custom404Ctx = await conversation.waitForCallbackQuery([
"set-custom-404",
"skip-custom-404",
]);

if (custom404Ctx.callbackQuery.data === "set-custom-404") {
await custom404Ctx.editMessageText("Setting up custom 404 image...");
await conversation.select("set_custom_404_image");
} else {
await custom404Ctx.editMessageText(
"Skipped. You can set a custom 404 image anytime from Settings.",
);
}

await ctx.reply(
`Welcome ${user.username}! You have been successfully registered. Would you like to start by recording an entry?`,
{ reply_markup: new InlineKeyboard().text("New Entry", "new-entry") },
);
}
4 changes: 3 additions & 1 deletion handlers/set_custom_404_image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export async function set_custom_404_image(
}

const realPath = await Deno.realPath(filePath);
await selfieResponse.body.pipeTo(file.writable);
if (selfieResponse.body) {
await selfieResponse.body.pipeTo(file.writable);
}
console.log("Custom 404 image saved to:", realPath);

settings!.custom404ImagePath = realPath;
Expand Down
Loading