ci: add commit checking workflows - #32
Conversation
b23a868 to
2de41f4
Compare
2de41f4 to
15152c1
Compare
|
Nice @ismay ! Can we reference a "global" commitlint config or download it from |
You mean instead of having a config at the repo root, point these actions to a central config somewhere else? It's technically possible I think. As long as the config exists on the filesystem you should be able to point the action to it. Commitlint does look for this file at the repo root by default though. From my understanding that's also one of the reasons we switched to having eslint and prettier configs at the root, it integrates well with editors and other tooling that expects these configs to be there. Would be unconventional to not have it there. In terms of potential divergence, the config looks like this: So what it points to is centralized (even though the config itself isn't). Should be easy enough to update if we ever want, we can just replace the entire config. If someone wanted to edit it they could of course. But personally I'm more worried about the complexity of going a non-standard route than the potential for people breaking the config. What do you think? |
|
By the way, on the topic of keeping our config files in sync across our repos: https://github.com/sapegin/mrm has always seemed like a good fit to me. It allows for configuration (and related tasks, like installing dependencies) to be shared via installable npm configs. It can also migrate existing configuration and retain or discard existing overrides. Basically codemods for your configuration. I think that might be a good way to address configuration across the org. |
|
Also, if we want to, we could check out another repo for the config like so: https://github.com/marketplace/actions/checkout#checkout-multiple-repos-side-by-side. |
In module.exports = {
extends: ['@commitlint/config-conventional'],
}So for apps, we could consider a const { config } = require('@dhis2/cli-style')
module.exports = {
...require(config.commitlint),
}I would have a slight preference for that because:
I discussed this with @ismay already on Slack and he pointed out that:
I think there is something to be said for both lines of reasoning, so I decided to summarise the conversation we had here, so others can also share their opinion on this. @ismay I hope the summary above is correct. If not, let me know what I should add/change. But none of the above actually relates to any of the changes in the current PR. These all look correct to me. The above does relate to the following:
|
|
Yeah with transient dependencies that you're relying on directly you don't have direct control over the version you're using. Or whether the dep is installed at all. Which makes things unpredictable. If commitlint were used directly in the (development) context of the app then I would be very much in favor of installing it explicitly. Currently though, the commitlint config is just text as far as the repo is concerned. The only actual use of that config should be on CI. And in that context I don't find it too weird to install the necessary dependencies directly there. Not as weird as proxying our own config at least. But that is what we do currently, so maybe we should just go that route with this config as well. |
|
So there's a couple options:
|
|
That should do it. I've made the commitlint job separate for the Also, the new jobs don't explicitly install node because the one that ships with the default ubuntu image is fine for what we're doing here (node 16). Saves time. One prerequisite is that |
Still a draft, but this adds workflows we could use to lint commits in a PR (and the PR title). See this thread on slack. The semantic pr check we use is a github app maintained by a single person. If it goes down all our pr commit checks go down (https://github.com/zeke/semantic-pull-requests).
It's not really technically necessary for this to be an app, github actions can do the job as well:
By default we use the semantic pr check to lint the pr title and the commits. See the template in cli-style. And this search for semantic.yml in our repos. Some codebases have modified the file.
The one thing we would need to change is to add a configuration file for commitlint to the root of our projects.
JulienKode/pull-request-name-linter-actionrequires it andwagoid/commitlint-github-actiondoesn't technically need it, but otherwise it might get out of sync with our settings.With cli-style we do expose commands like
d2-style check commitand we have a commitlint config here. But I think we have kept that hidden from users for now. I'm not sure if it would be all right for cli-style if we expose this. It's similar to what we've done with eslint for example, for which we now also have config in the root.Sidenote
I've only added the commit checking to our
appworkflow. It should be added to a couple other ones as well. Which leads me to this:As a followup we might be able to leverage action composition to get rid of (some of) the duplication in our actions.