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
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
8 changes: 5 additions & 3 deletions .github/workflows/deno.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: Deno app build and testing

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

jobs:
deno:
Expand All @@ -18,7 +20,7 @@ jobs:
- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x
deno-version: v2.x

- name: Verify formatting
run: deno fmt --check
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
dist
package
.DS_Store
.slack/apps.dev.json
2 changes: 2 additions & 0 deletions .slack/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
apps.dev.json
cache/
File renamed without changes.
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,9 @@ $ slack activity --tail
Contains `apps.dev.json` and `apps.json`, which include installation details for
development and deployed apps.

### `datastores/`

[Datastores](https://api.slack.com/automation/datastores) securely store data
for your application on Slack infrastructure. Required scopes to use datastores
include `datastore:write` and `datastore:read`.
Contains `hooks.json` used by the CLI to interact with the project's SDK
dependencies. It contains script hooks that are executed by the CLI and
implemented by the SDK.

### `functions/`

Expand Down Expand Up @@ -182,11 +180,6 @@ continuing to the next step.
The [app manifest](https://api.slack.com/automation/manifest) contains the app's
configuration. This file defines attributes like app name and description.

### `slack.json`

Used by the CLI to interact with the project's SDK dependencies. It contains
script hooks that are executed by the CLI and implemented by the SDK.

## Resources

To learn more about developing automations on Slack, visit the following:
Expand Down
11 changes: 8 additions & 3 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://deno.land/x/deno/cli/schemas/config-file.v1.json",
"$schema": "https://raw.githubusercontent.com/denoland/deno/main/cli/schemas/config-file.v1.json",
"fmt": {
"include": [
"README.md",
Expand All @@ -13,7 +13,6 @@
"workflows"
]
},
"importMap": "import_map.json",
"lint": {
"include": [
"datastores",
Expand All @@ -28,6 +27,12 @@
},
"lock": false,
"tasks": {
"test": "deno fmt --check && deno lint && deno test --allow-read --allow-none"
"test": "deno fmt --check && deno lint && deno test --allow-read"
Comment on lines -31 to +30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧠 Great way to make sure we're actually running tests!

},
"imports": {
"@std/assert": "jsr:@std/assert@^1.0.13",
"@std/testing": "jsr:@std/testing@^1.0.12",
"deno-slack-sdk/": "https://deno.land/x/deno_slack_sdk@2.15.0/",
"deno-slack-api/": "https://deno.land/x/deno_slack_api@2.8.0/"
}
}
43 changes: 43 additions & 0 deletions functions/post_issue_message_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { SlackFunctionTester } from "deno-slack-sdk/mod.ts";
import handler from "./post_issue_message.ts";
import { stub } from "@std/testing/mock";
import { assertEquals } from "@std/assert/equals";

const { createContext } = SlackFunctionTester("my-function");

Deno.test("Posts a message", async () => {
using _fetchStub = stub(
globalThis,
"fetch",
async (url: string | URL | Request, options?: RequestInit) => {
const request = url instanceof Request ? url : new Request(url, options);
const body = await request.formData();

assertEquals(request.method, "POST");
assertEquals(request.url, "https://slack.com/api/chat.postMessage");
assertEquals(body.get("channel"), "C111");

return Promise.resolve(
new Response(JSON.stringify({ ok: true }), {
status: 200,
}),
);
},
);

const inputs = {
channel: "C111",
submitting_user: "U111",
severity: "low",
description: "there ware an issue",
link: "https://example.ca",
};
const { outputs } = await handler(createContext({ inputs }));
assertEquals(outputs, {
channel: "C111",
description: "there ware an issue",
link: "https://example.ca",
severity: "low",
submitting_user: "U111",
});
});
6 changes: 0 additions & 6 deletions import_map.json

This file was deleted.

4 changes: 2 additions & 2 deletions triggers/submit_issue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Trigger } from "deno-slack-sdk/types.ts";
import type { Trigger } from "deno-slack-sdk/types.ts";
import { TriggerContextData, TriggerTypes } from "deno-slack-api/mod.ts";
import SubmitIssueWorkflow from "../workflows/submit_issue.ts";
import type SubmitIssueWorkflow from "../workflows/submit_issue.ts";

/**
* Triggers determine when workflows are executed. A trigger
Expand Down