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

Fix push with no configured module names #31

Merged
merged 13 commits into from
Jun 13, 2024
Merged

Fix push with no configured module names #31

merged 13 commits into from
Jun 13, 2024

Conversation

emcfarlane
Copy link
Collaborator

@emcfarlane emcfarlane commented Jun 11, 2024

This PR allows for better push behaviour when unnamed modules are present. The action will now read the buf.yaml config file to check for missing names before running the push or archive steps. With the latest release of buf@v.1.33.0 we can now also use the flag --exclude-unnamed to avoid failing push on unnamed modules when multiple modules are present.

As a test (and example) see the test-push-unnamed step in CI:

/opt/hostedtoolcache/buf/1.33.0/x64/buf push --error-format github-actions --exclude-unnamed --create --git-metadata
WARN	Excluding unnamed module	{"module": "bar"}
buf.build/***/foo:2969b75dd86b4895a5e590dc1bb89

In addition is the introduction of outputs in the action.yml by setting the resolved version of buf.

Read the config file to determine if a module name is present before
trying to push to the remote. On no configured modules skip both push
and archive steps.

This comment has been minimized.

Copy link
Member

@nicksnyder nicksnyder left a comment

Choose a reason for hiding this comment

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

Can you add a test that has two modules in the workspace, one with a name and one without?

.github/workflows/ci.yaml Outdated Show resolved Hide resolved
.github/workflows/ci.yaml Outdated Show resolved Hide resolved
src/main.ts Outdated Show resolved Hide resolved
@emcfarlane emcfarlane marked this pull request as draft June 11, 2024 20:10
@emcfarlane
Copy link
Collaborator Author

emcfarlane commented Jun 11, 2024

Need to fix multi-module pushes. We should push only named modules.

@emcfarlane emcfarlane marked this pull request as ready for review June 13, 2024 16:56
outputs:
buf_version:
description: |-
Version of the Buf CLI used.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is an unrelated change. Originally planned to use it to read back the version in different locations, but went with passing args. It does seem useful to provide outputs for other actions with the version being used supported by most actions.

const args = ["push", "--error-format", "github-actions"];
// Add --exclude-unnamed on buf versions that support the flag.
if (semver.satisfies(bufVersion, ">=1.33.0")) {
Copy link
Member

Choose a reason for hiding this comment

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

when we 1.0 this action, I would be in favor of just bumping the required minimum version of the whole action to 1.33.0 so we can eliminate this check

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, any version bumps we can increase the min version on. Left here to allow for a patch on 0.1.

@emcfarlane emcfarlane merged commit d17c53a into main Jun 13, 2024
34 checks passed
@emcfarlane emcfarlane deleted the ed/readConfig branch June 13, 2024 18:12
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.

3 participants