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

Diff @actions/http-client changes #1060

Closed
wants to merge 33 commits into from

Conversation

brcrista
Copy link
Contributor

@brcrista brcrista commented Apr 25, 2022

Note: the base branch for this PR is brcrista/http-client-base, not main. This is a branch I created just from copying over the files from https://github.com/actions/http-client without any changes.

The purpose of this PR is to highlight the changes I had to make to get @actions/http-client building along with toolkit. See #1062 for the actual PR to the mainline.

The biggest change is having to update some exported types in http-client to get it to build with strict. For example, null checking is now enforced. While there are more involved ways to clean this up (for example, to eliminate the possibility of returning nulls), I tried just to describe the current state of things without making any changes to behavior.

@@ -3,7 +3,7 @@ import * as net from 'net'
import * as core from '@actions/core'
import * as configVariables from '../src/internal/config-variables'
import {retry} from '../src/internal/requestUtils'
import {IHttpClientResponse} from '@actions/http-client/interfaces'
import {IHttpClientResponse} from '@actions/http-client/lib/interfaces'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having to put lib in the module reference seems to be a lerna thing. I tested what happens if you install the actual package through npm and it doesn't change.

Other packages in this repo reference each other's submodules through lib/.

@@ -39,7 +39,7 @@ describe('basics', () => {
// "url": "https://httpbin.org/get"
// }

it('does basic http get request', async done => {
it('does basic http get request', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got an error about passing done to an async callback. The Jest version in this project is a couple major versions newer than what http-client had, so I figured that was a breaking change that went in.

@@ -1,5 +1,8 @@
# @actions/core Releases

### 1.7.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

might want to rebase to smooth out this diff

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 tried that and it made this change go away, but for some reason that made the files in http-client/src all show up as "added" instead of "modified" (????). Since those are the files that really matter here, I switched it back to the pre-rebase commit.

@@ -1,6 +1,6 @@
{
"name": "@actions/core",
"version": "1.6.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

should be 1.7.1

@@ -1,6 +1,6 @@
{
"name": "@actions/artifact",
"version": "1.0.0",
"version": "1.0.1",
"preview": true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should update all the package-lock.json as well, alongside release notes

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 think CI is failing because I need to update the package-lock.jsons. I'm struggling a bit to figure out how to get npm to update them with lerna in the mix

): Promise<ifm.IHttpClientResponse> {
return null
throw new Error("not implemented")
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do these changes do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Returning null fails type checking with strict: true. I could have just added | null to the return type, but that doesn't make sense for when the method is actually implemented. So better to throw an exception for when it's not implemented. Callers can use canHandleAuthentication() to make sure the method is implemented.

} else {
proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY']
}
const proxyVar = (() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why turn this into a function, shouldn't we set the string? No need to invoke this multiple times

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not a function, it's still a string. The RHS of the assignment is an IIFE. I did that to use const and to avoid using undefined.

@@ -1,37 +1,45 @@
{
"name": "@actions/http-client",
"version": "1.0.11",
"version": "2.0.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we add/update the releases.md with information on why we have published a new major version, update the readme, and let users know why they should use it?

@brcrista brcrista force-pushed the brcrista/http-client-base branch 2 times, most recently from bc486b2 to e1b5123 Compare April 25, 2022 17:27
@brcrista
Copy link
Contributor Author

This is out-of-date now. I'll open a new one

@brcrista brcrista closed this Apr 28, 2022
@michelledeprosse21
Copy link

michelledeprosse21 commented Apr 28, 2022 via email

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.

None yet

4 participants