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

convert the implementation of the action to TypeScript #75

Closed
wants to merge 8 commits into from

Conversation

devoncarew
Copy link
Member

@devoncarew devoncarew commented Feb 17, 2023

Convert the implementation of the action to TypeScript:

  • a mostly direct translation from the Bash implementation to TypeScript
  • kept the dart.yml CI the same, so we could verify correct behavior of the port
  • as part of the port, addressed an issue related to auto-detection of the platform architecture (fix Automatically choose the correct architecture #59)
  • also, added a new action output - dart-version
  • much of the boilerplate for the action was taken from the https://github.com/actions/typescript-action template repo
  • done as part of general updates to the setup action #62
  • updated the changelog w/ the relevant changes, and rev'd the action version to 1.5.0-dev
  • updated with our std CONTRIBUTING.md file from dart-lang/.github, and added a section on developing the action (building the typescript)

@devoncarew devoncarew marked this pull request as draft February 17, 2023 19:37
@devoncarew
Copy link
Member Author

@DanTup - before I ask for a general review of the implementation and such - do you mind looking over the typescript code here, and the various typescript config files? It's been a while since I've written typescript, and it would be good to have somebody w/ domain expertise look the files over :)

Copy link

@DanTup DanTup left a comment

Choose a reason for hiding this comment

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

All looks good to me. I'm not completely familiar with all the latest TS config options/files (my experience is mostly only setting up Dart-Code and keeping it running), but what's there seems reasonable (esp. if the TS action was used as a base).

Added a few questions/nits.

src/setup.ts Outdated Show resolved Hide resolved
src/setup.ts Outdated Show resolved Hide resolved
__tests__/main.test.ts Outdated Show resolved Hide resolved
Copy link
Member Author

@devoncarew devoncarew left a comment

Choose a reason for hiding this comment

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

Thanks for the review! Updated w/ the noted changes.

__tests__/main.test.ts Outdated Show resolved Hide resolved
src/setup.ts Outdated Show resolved Hide resolved
src/setup.ts Outdated Show resolved Hide resolved
@devoncarew devoncarew marked this pull request as ready for review February 19, 2023 03:10
@devoncarew
Copy link
Member Author

@athomas and @mit-mit - adding you both for a general review.

@jonasfj and @isoos - you might want to look at the code around the OIDC token (mostly in the src/oidc.ts file).

@jonasfj
Copy link
Member

jonasfj commented Feb 20, 2023

Looks pretty nice to me. The src/oidc.ts file seems great!

if (fs.existsSync(versionFilePath)) {
return fs.readFileSync(versionFilePath, 'utf8').trim()
} else {
return null
Copy link
Member

Choose a reason for hiding this comment

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

Should we throw here? Or is there a legit case where there is no version file?

The action will end up storing an empty string in the output in this case:
https://github.com/actions/toolkit/blob/0db3029fcfcb1393a2b3ccd14caecd7a3460af4e/packages/core/src/utils.ts#L11

import * as versions from './versions'
import * as tc from '@actions/tool-cache'

// TODO: Support version patterns of '2.19.x' to mean the latest 2.19 version.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe instead we should support patterns similar to lower bounds in packages?

import * as versions from './versions'
import * as tc from '@actions/tool-cache'

// TODO: Support version patterns of '2.19.x' to mean the latest 2.19 version.
Copy link
Member

Choose a reason for hiding this comment

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

I believe mono_repo has a feature to generate tests using the lower bound of the package, maybe setup-dart could also have that feature?
version = auto -> find pubspec yaml (or perhaps lock) and use the lower bound.

export async function latestPublishedVersion(
channel: string,
flavor: string
): Promise<string | null> {
Copy link
Member

Choose a reason for hiding this comment

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

The null isn't handled at the call sites, shouldn't we throw instead?

Right now, the action will print "Installing the linux-x64 Dart SDK version null..." and then fail somewhere later (probably when it tries to download from dart-archive, which hopefully doesn't have a file at the URL containing null).

Copy link
Member

@mit-mit mit-mit left a comment

Choose a reason for hiding this comment

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

Would like to chat a bit about this before we go ahead and make the change

@devoncarew
Copy link
Member Author

Would like to chat a bit about this before we go ahead and make the change

Gotcha; I'll respond to Alex's feedback, but will hold off on landing until we've had a chance to talk.

@devoncarew
Copy link
Member Author

Converting this PR to a draft in favor of #77.

@devoncarew devoncarew marked this pull request as draft March 1, 2023 00:46
@devoncarew devoncarew closed this Mar 4, 2023
@devoncarew devoncarew deleted the typescript branch March 9, 2023 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically choose the correct architecture
5 participants