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

Better dependency management, run tests against high and low version of deno #79

Merged
merged 6 commits into from
Aug 27, 2024

Conversation

filmaj
Copy link
Contributor

@filmaj filmaj commented May 5, 2023

  • 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
Copy link

codecov bot commented May 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (0a7a819) to head (402575d).
Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

src/api_test.ts Outdated
@@ -71,19 +65,16 @@ Deno.test("SlackAPI class", async (t) => {
});
});

await assertRejects(
Copy link
Contributor Author

@filmaj filmaj May 8, 2023

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)) {
Copy link
Contributor Author

@filmaj filmaj May 8, 2023

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.

Copy link
Collaborator

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
Copy link
Contributor Author

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.

@filmaj filmaj marked this pull request as ready for review May 8, 2023 15:45
@filmaj filmaj requested a review from a team as a code owner May 8, 2023 15:45
@filmaj filmaj changed the title Deps mgmt Better dependency management, run tests against high and low version of deno May 8, 2023
Copy link
Contributor

@WilliamBergamin WilliamBergamin left a 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.

src/api_test.ts Outdated Show resolved Hide resolved
@@ -85,13 +85,10 @@ Deno.test("Mock call for event", async (t) => {
},
});
assertEquals(res.ok, true);
if (res.ok) {
Copy link
Contributor Author

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);
Copy link
Contributor Author

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.

@WilliamBergamin WilliamBergamin self-requested a review May 9, 2023 15:36
Copy link
Contributor

@WilliamBergamin WilliamBergamin left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@filmaj filmaj requested a review from shapirone May 11, 2023 17:37
@filmaj filmaj added enhancement New feature or request semver:patch requires a patch version number bump labels May 11, 2023
Copy link
Collaborator

@shapirone shapirone left a 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)

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]
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Comment on lines 1 to 2
import { pascalCase } from "./deps.ts";
import { emptyDir, ensureDir } from "./deps.ts";
Copy link
Collaborator

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)) {
Copy link
Collaborator

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
Comment on lines 1 to 3
// 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.
Copy link
Collaborator

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";
Copy link
Collaborator

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 🤔

Copy link
Contributor Author

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 😢

Copy link
Contributor

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.
@filmaj filmaj merged commit 3d2507e into main Aug 27, 2024
17 checks passed
@filmaj filmaj deleted the deps-mgmt branch August 27, 2024 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request semver:patch requires a patch version number bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants