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

Use @actions/github to invoke GraphQL for GHES compatibility #16

Merged
merged 1 commit into from
May 15, 2020

Conversation

ericsciple
Copy link
Contributor

Switched to @actions/[email protected] for GHES support when invoking GraphQL. It sets the correct baseUrl when running in a GHES environment. Related to PR actions/toolkit#449

@ericsciple
Copy link
Contributor Author

👋 I'm working on updating in-the-box actions for GHES.

Note, I was able to test the changes successfully against dotcom but doesnt look like packages is enabled on my local GHES deployment.

import {catchError, map, tap} from 'rxjs/operators'
import {GraphQlQueryResponse} from '@octokit/graphql/dist-types/types'
import {graphql} from './graphql'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To enable mocking, i switched to importing a local file instead. The problem is @actions/github exports a class which introduces a challenge for mocking... solved by adding one more level of indirection :)

* @param {string} query GraphQL query. Example: `'query { viewer { login } }'`.
* @param {object} parameters URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
export async function graphql(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wrapper function to make it easy to mock. Otherwise hard to mock since GitHub is an exported class.

@ericsciple ericsciple changed the title Use @actions/[email protected] to invoke GraphQL for GHES compatibility Use @actions/github to invoke GraphQL for GHES compatibility May 14, 2020
@ericsciple
Copy link
Contributor Author

@trent-j

Copy link
Collaborator

@trent-j trent-j left a comment

Choose a reason for hiding this comment

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

LGMT. Packages is not in GHES yet which is why you were not able to test it. It will be very soon though

@ericsciple
Copy link
Contributor Author

@trent-j thanks! Would you be able to merge and release? I dont have permission. With these changes, it should just work, once Packages is in GHES.

@ericsciple
Copy link
Contributor Author

ericsciple commented May 14, 2020

I end-to-end tested the scenario where it discovers old packages and deletes. I believe that exercises all of the cases where GraphQL is invoked (get version + delete).

@trent-j trent-j merged commit 84f259d into actions:master May 15, 2020
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.

2 participants