-
Notifications
You must be signed in to change notification settings - Fork 18
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
Better dependency management, run tests against high and low version of deno #79
Conversation
filmaj
commented
May 5, 2023
•
edited
Loading
edited
- Tweaks CI to run against most recent stable deno as well as a minimum deno version (1.45.4 - based on what version of deno we Run on Slack)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #79 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 36 36
Lines 1130 1130
Branches 17 17
=========================================
Hits 1130 1130 ☔ View full report in Codecov by Sentry. |
src/api_test.ts
Outdated
@@ -71,19 +65,16 @@ Deno.test("SlackAPI class", async (t) => { | |||
}); | |||
}); | |||
|
|||
await assertRejects( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API for assertRejects
changed in a recent version of deno's stdlib, leading to type errors. So, removed its use and instead used a 'manual' try/catch approach.
src/api_test.ts
Outdated
await client.apiCall("chat.postMessage", {}); | ||
} catch (error) { | ||
assertInstanceOf(error, HttpError); | ||
if (isHttpError(error)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This conditional should always return true. If it doesn't, then the previous line's assertion would fail. Its main purpose in this block is for type narrowing; using isHttpError
narrows the error type and allows for referencing e.g. headers
and status
on the error object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Might be good to have this context in a small in-code comment
? [keyof Params["properties"]] extends [never] ? EmptyInputs | ||
: Params["required"] extends Array<infer T> ? [T] extends [never] | ||
// If there are no required properties, inputs are optional | ||
: Params["required"] extends Array<infer T> ? [T] extends [never] // If there are no required properties, inputs are optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were a newer deno version's deno fmt
changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a clean solution to the script dependency management issue 🥇 I was struggling with this earlier and did not think it would affect us this quickly
Left one comment, let me know what you think about it.
@@ -85,13 +85,10 @@ Deno.test("Mock call for event", async (t) => { | |||
}, | |||
}); | |||
assertEquals(res.ok, true); | |||
if (res.ok) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion above this line should ensure res.ok
is always true. As a result, this conditional is not needed. (similar change made to other similar tests in other files below)
@@ -85,13 +85,10 @@ Deno.test("Mock call for event", async (t) => { | |||
}, | |||
}); | |||
assertEquals(res.ok, true); | |||
if (res.ok) { | |||
assertEquals(res.trigger, event_response.trigger); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found this assertion to not be very useful. Since we control the contents of the response via the mocking utility earlier in the test, it will always be true. As a result, I removed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you want to revisit, but this LGTM as an iterative step (other than the ROSI Deno version)
.github/workflows/deno.yml
Outdated
matrix: | ||
# we test on both most recent stable version of deno (v1.x) as well as | ||
# the version of deno used by Run on Slack (v1.31.1) | ||
deno-version: [v1.x, v1.31.1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is already out of date with what we run on ROSI.
Is there a way we can sync this with what's on ROSI? Nothing to do here now but let's keep this in the back of our mind as we think about how to surface the ROSI Deno version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally, we talked about getting ROSI to post their deno runtime version in metadata.json
, so I imagine this CI script would pull from there and use that as the lower-bound deno version to test.
scripts/src/generate.ts
Outdated
import { pascalCase } from "./deps.ts"; | ||
import { emptyDir, ensureDir } from "./deps.ts"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: One line?
src/api_test.ts
Outdated
await client.apiCall("chat.postMessage", {}); | ||
} catch (error) { | ||
assertInstanceOf(error, HttpError); | ||
if (isHttpError(error)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Might be good to have this context in a small in-code comment
src/deps.ts
Outdated
// When changing std versions, ensure to check this list's `cli_to_std` section: https://raw.githubusercontent.com/denoland/dotland/main/versions.json | ||
// Whatever minimum deno version we are recommending to users should be used to index into the above list to determine the maximum version of std | ||
// we should use in our libraries. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bonus points if we can figure out a way to do this automatically!
src/dev_deps.ts
Outdated
export { | ||
afterEach, | ||
beforeAll, | ||
} from "https://deno.land/[email protected]/testing/bdd.ts"; | ||
} from "https://deno.land/[email protected]/testing/bdd.ts"; | ||
export { isHttpError } from "https://deno.land/[email protected]/http/http_errors.ts"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can take this offline, but our libraries define the same version of the std
library over and over making updates more challenging. I understand the "import maps are for applications" but using an import map would simplify this, and allow consuming developers to override the std
lib via scopes 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish imports and exports supported dynamic strings 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we could use an import_map
it could solve this 😢
…pts/src directory. Comment at the top of deps.ts and dev_deps.ts to guide what version of deno std we should use. run tests against most recent stable deno as well as minimum deno version used internally Move import map helper scripts (for use with sample app integration testing) under scripts/src, add comments to scripts/deps.ts to explain stdlib versioning strategy. Run both CI workflows against most recent stable deno as well as version of deno used by Run on Slack. Name deno CI workflow more specifically Set min deno version to 1.31.1 (version Run on Slack uses), set deno stdlib version to 0.178.0 (recommended for deno v1.31.1), update tests as a result of assertion method changes in 0.178.0.