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

Always load the config file using the API #148

Closed
wants to merge 4 commits into from
Closed

Always load the config file using the API #148

wants to merge 4 commits into from

Conversation

Daverlo
Copy link
Contributor

@Daverlo Daverlo commented Aug 13, 2020

This PR is a prerequisite for using the prehooks. As we want to have the init step as a prehook, and that would happen before the checkout, we cannot rely on looking for the file locally.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.

Copy link
Contributor

@robertbrignull robertbrignull left a comment

Choose a reason for hiding this comment

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

Couple of points but looks good to me. I'll let someone from the other team have a look too though as I don't know the full picture.

@@ -142,28 +126,12 @@ test("load non-local input with invalid repo syntax", async t => {
});
});

test("load non-existent input", async t => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I note we don't actually have a test for when a remote config file doesn't exist. Instead of deleting this test case could you convert it to the case where the file doesn't exist, and check that the error message it gives is acceptable?

const configFilePath = configFile.substr(2);
const remote = util.getRequiredEnvParam("GITHUB_REPOSITORY") + "/" + configFilePath
+ "@" + util.getRef();
parsedYAML = await getRemoteConfig(remote);
Copy link
Contributor

Choose a reason for hiding this comment

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

I find it odd that we're constructing the remote here in the repo/path@ref format just so we can parse the various bits out of it again. I'm worried this just risks exaccerbating errors in the parsing code. Would it make sense to instead change getRemoteConfig to take the repository, path, and ref as separate arguments, then move the code for parsing user input into those three pieces to the else branch here?

// For using the api we have to remove the starting "./"
const configFilePath = configFile.substr(2);
const remote = util.getRequiredEnvParam("GITHUB_REPOSITORY") + "/" + configFilePath
+ "@" + util.getRef();
Copy link
Contributor

Choose a reason for hiding this comment

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

We could be slightly more specific and use the commit SHA instead of the ref. The advantage this would give is that it'll be more repeatable if the workflow is retried. It'll always use the commit the workflow was triggered on instead of using the latest version and potentially changing behaviour.

@Daverlo Daverlo marked this pull request as draft September 17, 2020 09:26
@github github deleted a comment from ffgarena Aug 12, 2021
@henrymercer
Copy link
Contributor

This PR would allow us to improve setup by migrating towards a state where users would only need to insert a single action into their workflows. However it would involve making an extra API call, which may put some users over the API limit. Since we haven't observed many problems with workflow setup, but we have observed problems with users going over the API limit, we don't plan to pick up this work in the foreseeable future, so I'll close this PR.

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.

4 participants