-
Notifications
You must be signed in to change notification settings - Fork 3
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
ADR-0001: Style guide #191
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass. Definitely a few things to discuss 😄
- actions and workflows are not versioned individually; instead, the entire repo is versioned, similar to the `pre-commit` hooks repo | ||
- tags should be used to communicate new functionality | ||
- tagging should follow calver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the expectation here that whatever utilizes the workflows works off main
or off the calver
tag? Would also be useful to link to calver docs and define the specific format we should be using.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and agreed; I'll update this with the link and format.
Folks can use main
if they're looking for something to do down the line, or they can use the calver
tag and use dependabot
to test updates.
As an alternative, each topic could be its own ADR. Reviewers may request this approach, which will require | ||
breaking this ADR into several ADRs and associated PRs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should split this into workflows and actions. They're different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we would have one style guide for workflows and another for actions? There's a significant overlap. If we want to distinguish between actions and workflows, but reduce redundancy, can we do one shared style guide, and then an action style guide and workflow style guide that only focus on things specific to actions/workflows?
|
||
### Workflows | ||
- workflows need to live in `.github/workflows` | ||
- we prefer actions to workflows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't agree with this. I want to avoid composition of the same 7 actions to accomplish one thing. Having to dig multiple levels down is also frustrating and makes it unclear what's happening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I struggle with building new workflows off of other workflows for a few reasons:
- reusable workflows are forced to be their own jobs in the calling workflow
- I can't embed them in a job
- I can't pass environment variables to workflows, which is especially a problem when those change by repo (e.g. connection credentials)
- I need to create a bunch of inputs to pass to them, to get a bunch of outputs from them, to pass those outputs to another job, in many cases to perform one or two additional steps
- any reusable workflow that needs access to the code requires adding repo and branch/ref as arguments
- with an action, you do the checkout in the calling workflow and the called action can focus on the task
- reusable workflows tend to take on too much scope, making them difficult to combine
- for example, we currently run tests twice during our release for each adapter because both the bumpversion/changelog workflow and build/test workflow runs tests; ideally there is an action for bumpversion, an action for changelog generation, an action for build, and these can all be selected al a carte as needed
- stated another way, actions should be created to perform a specific task, which should minimize maintenance for a particular action, similar to how python functions should be built
- workflows need to live in `.github/workflows` | ||
- we prefer actions to workflows | ||
- actions can be inserted into other actions and as part of workflows | ||
- actions can inherit environment variables |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So do workflows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Workflows do not inherit environment variables: https://docs.github.com/en/enterprise-cloud@latest/actions/using-workflows/reusing-workflows#limitations
### Workflows | ||
- workflows need to live in `.github/workflows` | ||
- we prefer actions to workflows | ||
- actions can be inserted into other actions and as part of workflows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference here being that workflows can't be part of actions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Workflow can't be part of actions, and can't be part of other jobs. They need to be stand alone jobs, which is pretty limiting.
|
||
## Proposal | ||
|
||
### Actions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What types of actions should we prefer - why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion on this. I've been using composite actions since most of the actions I create are pretty small. But some of our actions are more complex and I could see how using python would be easier (like semver parsing). Using python might also be more testable in certain scenarios (again thinking about semver parsing).
- `version-number` -> `version` | ||
- `archive-name` -> `archive` | ||
- yaml files use a four space tab | ||
- scripts use environment variables in `env` instead of inline substitution like `${{ inputs.value }}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have a scripts section. When should we write a script vs just doing it inline? Where should scripts live? etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that probably makes sense. To initially respond to the few examples you gave:
- I am moving more and more towards scripts always; so basically if it's more than a line, make it a script
- scripts should live alongside the
action.yml
which calls them, multiple actions should not depend on the same script
- linter: `check-yaml` @ https://github.com/pre-commit/pre-commit-hooks | ||
- `yamllint` @ https://github.com/adrienverge/yamllint | ||
|
||
Alternatives should support `pre-commit`: https://pre-commit.com/hooks.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatives?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatives to the proposed linters and formatters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh. Should we set up pre-commit in this repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
|
||
Alternatives should support `pre-commit`: https://pre-commit.com/hooks.html | ||
|
||
### Logging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does logging mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking of debug/summary notifications/etc. as logging. So when we print inputs/outputs to standard out, that's a debug log to me. And when we generate a notification that shows up in the summary section, that's an info/error/warn log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'll be useful to explicitly distinguish between when to "echo" vs using the GitHub notification that show in the summary.
- any step that changes state outside of the scope of the action has an associated info log | ||
- any step that results in predictable failure (e.g. unit tests) has an associated error log | ||
- any step that results in a predictable skip (e.g. version bump not needed) has an associated warning log | ||
- log types are standardized as an action in this repo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want an action that just does the notify that's built into github?
Description
Checklist