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

ADR-0001: Style guide #191

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

ADR-0001: Style guide #191

wants to merge 3 commits into from

Conversation

mikealfare
Copy link
Contributor

@mikealfare mikealfare commented May 3, 2024

Description

  • establish a style guide
  • setup basic ADR framework to support this decision and future decisions

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have signed the CLA
  • I have run this code in development and it appears to resolve the stated issue

Copy link
Member

@emmyoop emmyoop left a 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 😄

Comment on lines +70 to +72
- 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
Copy link
Member

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.

Copy link
Contributor Author

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.

Comment on lines +20 to +21
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.
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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.

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 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
Copy link
Member

Choose a reason for hiding this comment

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

So do workflows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

### 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
Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Member

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?

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 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 }}`
Copy link
Member

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

Copy link
Contributor Author

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
Copy link
Member

Choose a reason for hiding this comment

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

Alternatives?

Copy link
Contributor Author

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

Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Member

Choose a reason for hiding this comment

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

What does logging mean?

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'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.

Copy link
Member

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
Copy link
Member

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?

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