Skip to content

divar-ir/semangit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🩺 Semangit

Master Workflow Test Coverage
A simple tool to force version update in CI.
We've all experienced commits forgetting to update the corresponding version on the codebase; like changing a helm chart template without increasing the version in Chart.yaml. Semangit helps to prevent such mistakes by checking whether a change needs a corresponding version increase.

📖 Quick start guide

By now, the Semangit project only support helm version checker. To use it on your CI, use one of the following templates:

🚩 Gitlab

Sample usage of the helm version checker in Gitlab CI is shown below:

check-helm-version:
  stage: lint
  image: divaar/semangit:latest
  variables:
    GIT_DEPTH: 0
    GIT_STRATEGY: clone
    SEMANGIT_REPODIR: .
    SEMANGIT_OLDREVISION: ${CI_DEFAULT_BRANCH}
    SEMANGIT_NEWREVISION: ${CI_COMMIT_REF_NAME}
    SEMANGIT_HELMROOTDIR: .
    SEMANGIT_LOGLEVEL: info # Options: trace, debug, info, warn, error, fatal, panic
  script:
    - git branch ${SEMANGIT_OLDREVISION} origin/${SEMANGIT_OLDREVISION}
    - git branch ${SEMANGIT_NEWREVISION} origin/${SEMANGIT_NEWREVISION}
    - semangit run
  only:
    refs:
      - merge_requests # Override this section if you don't want this behaviour
  before_script: []

This plugin will fail the CI job if either the template files or the values.yaml file is changed.

📃 Compiled binary

The compiled version of the project can be found in releases page, you can simply download the artifact and run it as a command:

./semangit run [flags]

🐳 Official image

Semangit also comes with an official docker image. The image can be found in here. A sample usage is as follows:

docker run --rm divaar/semangit:latest semangit run [flags]

💡 Contribution

Fortunately, the plugins of Semangit project are written in a way that you don't have to get into the details of the project. Simply, just create a file in versionanalyzers directory and implement the VersionAnalyzer interface. Semangit will do the rest and register your plugin and after that, the new plugin can be used through the executing options:

semangit run 
--repo-dir .
--old-rev master
--new-rev HEAD
--log-level debug
--version-analyzer-name ${YOUR_DESIRED_PLUGIN_NAME} 
--{PLUGIN_NAME}-{EXTRA-ARG-NAME} {EXTRA-ARG-VALUE}