Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an initial prototype (or illustration) of what a meta-programming style generator for GitHub actions could look like. Basically the idea is to supply a static, declarative config of what the final workflow should look like and the meta-programming system then generates the appropriate yaml config. This allows very easy re-configuration, global updates across all workflows, isolated workflows for easy debugging and sharing of workflows generation across repositories.
I have supplied two approaches here that will allow us to evaluate the merits of each approach. First a dictionary/yaml style generator where the final config is specified in dictionary form and the final workflow string is generated using
yaml.dump. The second is a f-string based approach that uses an f-string style template and then injects the correct variables into it. Both approaches have advantages and disadvantages. The dictionary style approach is more verbose and less readable, but you have more control about how and what is generated. For example, you could splice a dictionary together from sub-dictionaries, you can for-loop over stuff to generate dictionaries dynamically. The f-string approach is more readable initially as it is closer to the final config. But, it's less flexible: we can't for-loop inside the f-string template (unless we use fancy templating engines such as jinja) and we need escape any f-string syntax such as{and}-- which is prone to duplication errors.Here is an example of running the provided script and the resulting output:
Note that this is a proposal for discussion and not a final decision on anything. Let's circle back together and find a suitable solution that we feel confident about as a team before committing and implementing anything further.