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

Remove non-token dependencies on GitHub Actions #109

Merged
merged 16 commits into from
Feb 21, 2024

Conversation

Hoverbear
Copy link
Contributor

@Hoverbear Hoverbear commented Feb 15, 2024

This does quite a bit of logic changing to make us not require GitHub Actions for anything but the bearer token.

It is important to note that this (for now) refuses to run if GITHUB_ACTION is not set or --github-token is not passed. So this doesn't actually remove the need for Github Actions, it just sets the stage for us to add support (similar to #107 and #108).

I believe some of the error messages are still a bit rough... Should give them a better pass before merge.

@Hoverbear Hoverbear self-assigned this Feb 15, 2024
@Hoverbear Hoverbear force-pushed the even-less-github-dependencies branch from 1e0a334 to 22b8c0e Compare February 16, 2024 21:20
@Hoverbear Hoverbear force-pushed the even-less-github-dependencies branch from 22b8c0e to a05a1bc Compare February 16, 2024 21:22
@Hoverbear Hoverbear marked this pull request as draft February 16, 2024 21:32
@@ -338,16 +384,7 @@ impl FlakeHubPushCli {
PathBuf::new()
};

let repository = if let Some(repository) = &repository.0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to populate_missing_from_github

@@ -369,12 +406,6 @@ impl FlakeHubPushCli {
repository.clone()
};

let tag = if let Some(tag) = &tag.0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to populate_missing_from_github

git_root.clone()
} else if let Ok(github_workspace) = std::env::var("GITHUB_WORKSPACE") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to populate_missing_from_github

.unwrap_or_else(|| "<none>".into()),
github_graphql_data_result.rev_count as usize
);
commit_count = Some(github_graphql_data_result.rev_count as usize);
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 could see us checking if it's len 1 or something but this feels safe.

rolling,
rolling_minor.0,
github_graphql_data_result,
Copy link
Contributor Author

@Hoverbear Hoverbear Feb 20, 2024

Choose a reason for hiding this comment

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

Getting this arg out of push_new_release was part of the main goal here.

flake_metadata: serde_json::Value,
flake_outputs: serde_json::Value,
upload_name: String,
mirror: bool,
visibility: Visibility,
github_graphql_data_result: GithubGraphqlDataResult,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Getting this arg out of build was part of the main goal here.

src/release_metadata.rs Outdated Show resolved Hide resolved
@Hoverbear Hoverbear marked this pull request as ready for review February 21, 2024 17:54
#[tracing::instrument(skip_all)]
pub(crate) async fn get_actions_id_bearer_token() -> color_eyre::Result<String> {
#[tracing::instrument(skip_all, fields(audience = tracing::field::Empty))]
pub(crate) async fn get_actions_id_bearer_token(host: &url::Url) -> color_eyre::Result<String> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change mostly included for help with testing.

Copy link
Member

@cole-h cole-h left a comment

Choose a reason for hiding this comment

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

LGTM and I tested that rolling releases are still properly calculated 🚀

revision_info,
&repository,
revision,
commit_count,
Copy link
Member

Choose a reason for hiding this comment

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

I'm going to keep looking to see if I can answer this, but it seems like maybe we use local commit count, but most times that's over-ridden by getting it from github?

I'm just a bit nervous this exposes us to (running outside github) and then having rolling releases be broken there.

(I'm looking to see if I've missed/forgotten a more fundamental fix to the local commit count)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any time a github token is present we rely on Github (since it is likely more correct -- and if we're in GHA then it's always 1).

If the user is running the tool outside GHA then we can't necessarily rely on being able to ask Github -- so we need to rely on the locally discovered commit count (which may be wrong).

Copy link
Member

Choose a reason for hiding this comment

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

(which may be wrong).

totally understood, I just feel like we sorta still have an underlying bug that is mostly masked because we only expect to work in github. Yet we have an explicit code path that we know might return bad data.

It almost feels like we should be erroring out without a commit count we return. It feels like it's a Maybe<T> almost, unless we're in GitHub.

again, not an issue with this PR but I don't want us to merge this, forget, and then re-expose ourselves to this bug in a new codepath.

Copy link
Member

@colemickens colemickens left a comment

Choose a reason for hiding this comment

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

Left a comment with a question, but I don't think it's a blocker or needs to be fixed now. Maybe a ticket if appropriate?

@Hoverbear Hoverbear merged commit 26a955a into main Feb 21, 2024
5 checks passed
@Hoverbear Hoverbear deleted the even-less-github-dependencies branch February 21, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants