50 Commits

Author SHA1 Message Date
7751fd9494 build(version): bump version 0.3.0 → 0.3.1 2022-01-11 07:03:09 +00:00
Jon
49a2e1185b Merge branch 'issue-2' into 'development'
docs(readme): Update project usage in own repo

See merge request nofusscomputing/projects/gitlab-ci!10
2021-08-13 02:12:35 +00:00
8ac36de8e0 docs(readme): Updated with an example .gitlab-ci.yml example
fixes #2 !10
2021-08-13 11:37:10 +09:30
Jon
aa28ef6553 Merge branch 'code-quality' into 'development'
style: improve python code quality

See merge request nofusscomputing/projects/gitlab-ci!9
2021-08-12 05:42:48 +00:00
4b6cc3176f fix(pylint): install the required packages for files being checked
closes #7
2021-08-12 15:06:07 +09:30
936299aefc fix(pylint): fix bug introduced in code quality commit
#7
2021-08-12 14:49:00 +09:30
2ac22c0e91 fix(commit_footer): fix bug introduced in code quality commit
#7
2021-08-12 14:46:26 +09:30
ccc601f641 style(cz_nfc): code quality on cz_nfc.py
#7
2021-08-12 14:42:16 +09:30
5676c5ee37 style(commit_footer): code quality on setup.py
#7
2021-08-12 14:27:41 +09:30
3d69e57714 style(commit_footer): code quality on __main__.py
#7
2021-08-12 14:26:43 +09:30
c093c31cbd style(commit_footer): code quality on commits.py
#7
2021-08-12 14:21:34 +09:30
73e061e649 build(pylint): added .pylintrc to exclude some rules
.pylintrc had rules ignore docs strings for module, function and class. this can be customised by the end user.

!9 #7
2021-08-12 14:04:32 +09:30
389bc08d76 build(version): bump version 0.3.0rc1 → 0.3.0 2021-08-12 03:32:36 +00:00
Jon
f455eb2e27 Merge branch 'style-readme' into 'development'
style(readme): fix badge table.

See merge request nofusscomputing/projects/gitlab-ci!7
2021-08-12 03:25:10 +00:00
3360a15fde fix(commit_message): fixed commit message check if there is only one commit to the branch
!7
2021-08-12 12:47:23 +09:30
2c61651d9c style(readme): fix formatting of badge table
The badge table did not render on github,
adjuested so that each row is on one line for github markdown to function

!7
2021-08-12 12:45:40 +09:30
Jon
a629e39f59 Merge branch 'update-readme' into 'development'
docs(readme): added how to use repo

See merge request nofusscomputing/projects/gitlab-ci!5
2021-08-11 06:37:28 +00:00
0653766c93 docs(readme): Updated badges and intro
!5
2021-08-11 15:52:28 +09:30
d610562438 feat(python_linting): added ci job, python linting, code quality and scoring
Added a job to lint python files and ouput a code quality report for gitlab MR.

A html report is also available within the artifacts. if the badge is used,
the badge links to the html code quality report.

 Changes to be committed:
	modified:   .gitlab-ci.yml
	new file:   python/.gitlab-ci.yml
	new file:   python/README.md
	new file:   python/requirements.txt

issue #1
2021-08-11 15:51:45 +09:30
def31ef562 style(yaml_lint): fixed yaml lint errors
yaml lint was producing linting errors. Amended affected lines.

#1
2021-08-11 13:47:34 +09:30
d20a56fa0c feat(yaml_lint): Added job yaml lint for checking yaml files
defaults to checking subfolder/.gitlab-ci.yml.

 Changes to be committed:
	modified:   .gitlab-ci.yml
	new file:   yaml_lint/.gitlab-ci.yml
	new file:   yaml_lint/.yamllint.yaml
	new file:   yaml_lint/README.md
	new file:   yaml_lint/requirements.txt

issue #1
2021-08-11 13:41:42 +09:30
9f7a24c1eb docs(gitlab_templates): added issue and merge request templates
#1
2021-08-11 12:44:22 +09:30
da8eb5c338 docs(template): added template readme for CI job folders
#1
2021-08-11 12:41:51 +09:30
ace7a03456 docs(readme): explain sync and using github to link gitlab-ci
!5 #1
2021-08-11 12:40:30 +09:30
8790917e7d docs(readme): explain repo layout and versioning
!5
2021-08-11 12:30:30 +09:30
19900945e7 docs(readme): added how to update gitlab-ci
!5
2021-08-11 12:26:18 +09:30
63af1efb4f fix(commit_footer_refs): Use the current git branch for comparison.
dynamically select the current branch so that it can be compared to the dev branch

!5 #1
2021-08-11 12:17:50 +09:30
8a988ebf09 docs(readme): Added how to use this repository
!5
2021-08-11 12:07:56 +09:30
Jon
f4ee55daa5 Merge branch 'changelog-footer-toggle' into 'development'
feat(changelog): be able to switch changelog references inclusion.

See merge request nofusscomputing/projects/gitlab-ci!4
2021-08-08 06:35:41 +00:00
dc13d4f284 docs(gitlab_release): Added user docs to fix errors from ci job 'commit footer refs'
User documentation provided as it is linked from the junit test report in the gitlab interface.

closes #3 closes #4
2021-08-08 15:57:50 +09:30
22136f7dd2 feat(gitlab_release): Toggle var added to enable switching changelog references.
using var 'CHANGELOG_FOOTER_REFERENCES' set to False when generating a changelog
with 'cz' will not add the commit footer refrences to the changelog.

issue #3
2021-08-08 15:28:00 +09:30
eb0bf4c174 refactor(gitlab_release): file link to be in local repository for helping fix commit footer ref check failures
issue #4
2021-08-08 15:18:11 +09:30
81776223c5 refactor(gitlab_release): use a name for failed test to denote the issue
issue #4
2021-08-08 15:05:35 +09:30
756b9406dd feat(gitlab_release): be able to toggle commit footer check job
if var CHANGELOG_FOOTER_REFERENCES=False, dont conduct validation job.

issue #4
2021-08-08 15:03:12 +09:30
7cb676eb98 ci(gitlab_release): Add a validation job to check if commit messages contain a gitlab reference in the footer
#4
2021-08-08 14:51:57 +09:30
11e156619d feat(gitlab_release): python module to check if a commit message has gitlab references in the footer
#4
2021-08-08 14:50:34 +09:30
d2d4ac0afa build(.gitignore): ignore python build files
!4
2021-08-08 14:47:49 +09:30
Jon
d929c1d3b0 Merge branch 'changelog-footer' into 'development'
feat(changelog): Add commit footer to Changelog

See merge request nofusscomputing/projects/gitlab-ci!3
2021-08-07 07:53:17 +00:00
35edb7cfc5 docs(changelog): Updated changelog to new layout
Changelog now adds issue and merge request references from the commit footer line.

!3 #3
2021-08-07 17:17:29 +09:30
8699c41219 feat(gitlab_release): Add commit footer to changelog
!1 #3
2021-08-07 17:11:17 +09:30
Jon
cc2f23b091 Merge branch 'fix-releases' into 'development'
fix(gitlab_releases): version increment workflow from RC-release -> full-release

See merge request nofusscomputing/projects/gitlab-ci!2
2021-08-07 05:31:59 +00:00
5f273ce23a docs(gitlab_release): Updated docs with new instructions on version incrementing
BREAKING CHANGE: !2
2021-08-07 14:56:51 +09:30
f76cabeeb0 fix(gitlab_release): Adjust release workflow
Previous release workflow only allowed version increment of RC on development brnach.

adjust to the following workflow:
    master branch: automatically increment the version
    development branch: option to manually increment version (RC increment only)

!2
2021-08-07 14:31:19 +09:30
eb5cc8a0e2 build(version): bump version 0.3.0rc0 → 0.3.0rc1 2021-08-04 03:23:08 +00:00
cb78ab8218 docs(changelog): regenerated so that all entries use the new url format
#1
2021-08-04 12:49:46 +09:30
09dcb65b09 build(version): bump version 0.2.1 → 0.3.0rc0 2021-08-04 03:13:54 +00:00
3e8c3ce7cd feat(gitlab_release): On the development brnach, releases to be 'rc' to denote considered non-stable
#1
2021-08-04 12:39:01 +09:30
cc3fabdaa2 refactor(gitlab_release): Use Short commit SHA1 in main changelog link to gitlab
#1
2021-08-04 12:24:02 +09:30
4453b433c8 build(version): bump version 0.2.0 → 0.2.1 2021-08-04 02:49:45 +00:00
588698df26 fix(gitlab_release): Correctly fetch the CI_PROJECT_URL for the environment 2021-08-04 12:05:01 +09:30
36 changed files with 1116 additions and 71 deletions

View File

@ -4,4 +4,4 @@ commitizen:
name: cz_conventional_commits
tag_format: v$major.$minor.$patch$prerelease
update_changelog_on_bump: true
version: 0.2.0
version: 0.3.1

4
.gitignore vendored
View File

@ -11,3 +11,7 @@ dev_env/
# ignore gitlab-ci artifacts
artifacts/
__pycache__
*.egg-info

View File

@ -8,9 +8,24 @@ stages:
- sync
include:
- local: $JOB_ROOT_DIR/yaml_lint/.gitlab-ci.yml
- local: $JOB_ROOT_DIR/conventional_commits/.gitlab-ci.yml
- local: $JOB_ROOT_DIR/git_push_mirror/.gitlab-ci.yml
- local: $JOB_ROOT_DIR/gitlab_release/.gitlab-ci.yml
- local: $JOB_ROOT_DIR/python/.gitlab-ci.yml
PyLint:
extends:
- .PyLint
image: python:3.6-slim
gilab-ci.yml Lint (python 3.6):
variables:
YAML_LINT_PATH: "/*/.gitlab-ci.yml"
extends:
- .yaml_lint_defaults
image: python:3.6-slim
Gitlab Release:
@ -20,7 +35,6 @@ Gitlab Release:
- .gitlab_release
Github (Push --mirror):
variables:
GIT_SYNC_URL: "https://$GITHUB_USERNAME_ROBOT:$GITHUB_TOKEN_ROBOT@github.com/NoFussComputing/gitlab-ci.git"

0
.gitlab/.gitkeep Normal file
View File

View File

View File

@ -0,0 +1,84 @@
## :new: Ansible Role - {new ansible role name}
<!--
- provide a summary of the role and what you propose including what the role will do. ensure all explainations are detailed.
- include any templates here using the collapsable sections. remove/add as many as is required and name as to what it is.
- you can add/delete any details section as required.
- emojis ref: https://github.com/yodamad/gitlab-emoji
-->
<details>
<summary>:clipboard: template filename.extension</summary>
``` yaml
your yaml playbook here
```
</details>
### Playbook usage
<!--
provide examples on how this role would be used in a playbook.
include a playbook example i.e.
<details>
<summary>:clipboard: example playbook</summary>
``` yaml
your yaml playbook here
```
</details>
-->
<!-- provide a summary here -->
<details>
<summary>:clipboard: example playbook</summary>
``` yaml
your yaml playbook here
```
</details>
### :ledger: Documentation
<!-- provide a summary of what is required or even better contribute by writing the docs here -->
<details>
<summary>:clipboard: contribution - Documentation</summary>
<!-- if you are contributing docs write them here. -->
</details>
## :link: Links
<!-- Add a list of links to items relevant to this issue-->
- link 1
- issue #number
## :ballot_box_with_check: Tasks
<!--
don't delete tasks from the list strike them through to denote not-applicable use double tidle '~~'. i.e. '~~[ ] a random task~~'
tasks are used as part of the development stage
-->
- [ ] ~Documentation Added
- [ ] (dev) Merge request opened and linked to this issue
<!-- don't adjust the below slash commands -->
/label ~"workflow::not started"
/label ~"category::feature"

View File

View File

@ -0,0 +1,34 @@
## :books: Summary
<!-- your summary here emojis ref: https://github.com/yodamad/gitlab-emoji-->
-----
| :link: **Related Issue(s)** | :link: **Related Merge Request(s)** |
|:----:|:----:|
| <!-- example #1 <br> #2 <br> #3 etc. if none enter *none* --> | <!-- example !1 <br> !2 <br> !3 etc. if none enter *none* --> |
### :construction_worker: Tasks
<!-- dont remove tasks strike through including the checkbox by enclosing in double tidle '~~' -->
- [ ] merging to correct branch?
- [ ] issue linked to this MR?
- related issues:
- [ ] closed in a commit message
- [ ] Manually closed
- [ ] All related issues tasks complete?
<!-- don't adjust the below slash commands -->
/label ~"workflow::not started"
/label ~"category::feature"

40
.templates/README.md Normal file
View File

@ -0,0 +1,40 @@
# {CI Job Name}
Summary of job here
This job provides the following badge:
{A badge here}
## Dependencies
- {dependent job name}
## your .gitlab-ci.yml changes
To use this job add the following to your `.gitlab-ci.yml` file
``` yaml
variables:
VARNAME: "a var value"
stages:
- {new stage name}
include:
- local: CI/{job name}/.gitlab-ci.yml
```
## CI/CD Variables required
| var name | Description |
|:----:|:----|
| NEW VAR | this var does this and bka |
## Job Workflow
## Artifacts
## License
To view the license for this folder and any sub-folders, refer [here](https://gitlab.com/nofusscomputing/projects/gitlab-ci)

View File

@ -1,44 +1,125 @@
## v0.3.1 (2022-01-11)
### Bug Fixes
- **pylint**: [4b6cc317](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/4b6cc3176fc4acc3b7dbb954162802af9cbb4c68) - install the required packages for files being checked [ [#7](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/7) ]
- **pylint**: [936299ae](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/936299aefc6eadf9cbfec3152b352b321969cfab) - fix bug introduced in code quality commit [ [#7](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/7) ]
- **commit_footer**: [2ac22c0e](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/2ac22c0e914016a8944ff9b94640f3e87f409069) - fix bug introduced in code quality commit [ [#7](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/7) ]
### Documentaton / Guides
- **readme**: [8ac36de8](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/8ac36de8e0f113ce17d54dfce1345a0adab41bc8) - Updated with an example .gitlab-ci.yml example [ [#2](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/2) [!10](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/10) ]
## v0.3.0 (2021-08-12)
### BREAKING CHANGE
- !2
### Bug Fixes
- **commit_message**: [3360a15f](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/3360a15fde12682edfd9044d2541dc819615b838) - fixed commit message check if there is only one commit to the branch [ [!7](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/7) ]
- **commit_footer_refs**: [63af1efb](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/63af1efb4fd92a9f8755f766728a18d8f390b805) - Use the current git branch for comparison. [ [!5](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/5) [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
- **gitlab_release**: [f76cabee](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/f76cabeeb04b028a231dc1c232862db5fcad4345) - Adjust release workflow [ [!2](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/2) ]
### Code Refactor
- **gitlab_release**: [eb0bf4c1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/eb0bf4c1740dbd7a47ceb031c0d1c854899a1e40) - file link to be in local repository for helping fix commit footer ref check failures [ [#4](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/4) ]
- **gitlab_release**: [81776223](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/81776223c5cb392c12c7ca63488a1df10290e9d1) - use a name for failed test to denote the issue [ [#4](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/4) ]
### Continious Integration
- **gitlab_release**: [7cb676eb](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/7cb676eb98a7de30d47a6b49a87067116684cfd2) - Add a validation job to check if commit messages contain a gitlab reference in the footer [ [#4](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/4) ]
### Documentaton / Guides
- **readme**: [0653766c](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/0653766c935cb117082bfe1481ae83e4a1b2bb5c) - Updated badges and intro [ [!5](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/5) ]
- **gitlab_templates**: [9f7a24c1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/9f7a24c1ebc0bdb5a153977dcb1c53d7ec2fb140) - added issue and merge request templates [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
- **template**: [da8eb5c3](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/da8eb5c3381379f6e405c3ebe14d9a883c52f41a) - added template readme for CI job folders [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
- **readme**: [ace7a034](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/ace7a03456861d59e2f904405f45409c53e831ab) - explain sync and using github to link gitlab-ci [ [!5](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/5) [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
- **readme**: [8790917e](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/8790917e7d959aa7b8305912bb443ba6b72200c6) - explain repo layout and versioning [ [!5](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/5) ]
- **readme**: [19900945](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/19900945e763249b6ef7a9e2e2cbcf11748b1eea) - added how to update gitlab-ci [ [!5](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/5) ]
- **readme**: [8a988ebf](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/8a988ebf09015211f8f6566acc0ba71c1f00bee1) - Added how to use this repository [ [!5](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/5) ]
- **gitlab_release**: [dc13d4f2](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/dc13d4f2841038c085dcf29dfb0b0c5d2f00f099) - Added user docs to fix errors from ci job 'commit footer refs' [ [#3](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/3) [#4](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/4) ]
- **changelog**: [35edb7cf](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/35edb7cfc59e2d147bdb5cb5d03710ec747073ae) - Updated changelog to new layout [ [!3](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/3) [#3](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/3) ]
- **gitlab_release**: [5f273ce2](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/5f273ce23a331eaf11623207ec4aba8b856c14f0) - Updated docs with new instructions on version incrementing [ [!2](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/2) ]
### Features
- **python_linting**: [d6105624](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/d61056243804728e059b99fce1644a8cc37230bb) - added ci job, python linting, code quality and scoring [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
- **yaml_lint**: [d20a56fa](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/d20a56fa0ca492e3fc2ad7c548fc891cc8ffc8ec) - Added job yaml lint for checking yaml files [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
- **gitlab_release**: [22136f7d](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/22136f7dd22b9487d362a7ed63ca1b76e52b9cc7) - Toggle var added to enable switching changelog references. [ [#3](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/3) ]
- **gitlab_release**: [756b9406](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/756b9406dde8cf0bf0030ac72855a054ece3a883) - be able to toggle commit footer check job [ [#4](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/4) ]
- **gitlab_release**: [11e15661](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/11e156619d0d820e534897bafd5f39e6f9defcbf) - python module to check if a commit message has gitlab references in the footer [ [#4](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/4) ]
- **gitlab_release**: [8699c412](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/8699c41219d70e6f41f42dc7f2c1bcf542b3f723) - Add commit footer to changelog [ [!1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests/1) [#3](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/3) ]
## v0.3.0rc1 (2021-08-04)
### Documentaton / Guides
- **changelog**: [cb78ab82](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/cb78ab82182a9edcd568a8b4c315490041539149) - regenerated so that all entries use the new url format [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
## v0.3.0rc0 (2021-08-04)
### Code Refactor
- **gitlab_release**: [cc3fabda](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/cc3fabdaa28f97c3e1600e4a0d95a05bb547e772) - Use Short commit SHA1 in main changelog link to gitlab [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
### Features
- **gitlab_release**: [3e8c3ce7](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/3e8c3ce7cd64a6e9110818d32c15c3602fefb76c) - On the development brnach, releases to be 'rc' to denote considered non-stable [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
## v0.2.1 (2021-08-04)
### Bug Fixes
- **gitlab_release**: [588698df](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/588698df2668853a97fe60901ab324310f34f279) - Correctly fetch the CI_PROJECT_URL for the environment
## v0.2.0 (2021-08-04)
### Code Refactor
- **gitlab_release**: [7a69685b53cbe5bd7341a176bf63fd17d36bc7f0]($CI_PROJECT_URL/-/commit/7a69685b53cbe5bd7341a176bf63fd17d36bc7f0) - Dont conduct any release, git push or tag delete if the version was not bumped
- **gitlab_release**: [72e8b6c84defdb903c5741e3469651987769713f]($CI_PROJECT_URL/-/commit/72e8b6c84defdb903c5741e3469651987769713f) - build gitlab commit url for changelog so that there is a weblink to the changes
- **gitlab_release**: [7a69685b](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/7a69685b53cbe5bd7341a176bf63fd17d36bc7f0) - Dont conduct any release, git push or tag delete if the version was not bumped
- **gitlab_release**: [72e8b6c8](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/72e8b6c84defdb903c5741e3469651987769713f) - build gitlab commit url for changelog so that there is a weblink to the changes [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
### Documentaton / Guides
- **gitlab_release**: [eebe8e30dcb11cd239f35fcb98216b2ae4d20ece]($CI_PROJECT_URL/-/commit/eebe8e30dcb11cd239f35fcb98216b2ae4d20ece) - Include custom command instructions
- **gitlab_release**: [eebe8e30](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/eebe8e30dcb11cd239f35fcb98216b2ae4d20ece) - Include custom command instructions [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
### Features
- **gitlab_release**: [287b4c954dddfaaf0a66af387676ea438cc80e61]($CI_PROJECT_URL/-/commit/287b4c954dddfaaf0a66af387676ea438cc80e61) - Include code refactor as part of the changelog
- **gitlab_release**: [287b4c95](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/287b4c954dddfaaf0a66af387676ea438cc80e61) - Include code refactor as part of the changelog [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
## v0.1.0 (2021-08-04)
### Bug Fixes
- **gitlab_release**: 80ca3618ee56d0f2a2c012416cb6206599a4f3f6 - A 'feat' commit must do a MINOR bump to version
- **gitlab_release**: ed5be7fd3c16e86d48e179a2cded53a38f79e1d9 - ci image is alpine, use '/bin/sh' and add the changlogs to git cache for commiting
- **gitlab_release**: 7706085b09f3cd9b7c09f7f93b182fd425f6525a - All tasks run as part of script including user custom script
- **gitlab_release**: 1446c28ed2bfe2efec99bc2fc83b111717bcb2af - Use a user token to access the git repo for pushing commits back
- **ansible**: 2a3266fb537e22dddf47708d0af101945027128f - Ensure the default ci directory is populated
- **gitlab_release**: [80ca3618](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/80ca3618ee56d0f2a2c012416cb6206599a4f3f6) - A 'feat' commit must do a MINOR bump to version [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
- **gitlab_release**: [ed5be7fd](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/ed5be7fd3c16e86d48e179a2cded53a38f79e1d9) - ci image is alpine, use '/bin/sh' and add the changlogs to git cache for commiting [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
- **gitlab_release**: [7706085b](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/7706085b09f3cd9b7c09f7f93b182fd425f6525a) - All tasks run as part of script including user custom script [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
- **gitlab_release**: [1446c28e](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/1446c28ed2bfe2efec99bc2fc83b111717bcb2af) - Use a user token to access the git repo for pushing commits back [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
- **ansible**: [2a3266fb](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/2a3266fb537e22dddf47708d0af101945027128f) - Ensure the default ci directory is populated [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
### Code Refactor
- **gitlab_release**: [2035ed27](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/2035ed27af7fc1f3f5b2c42aa5874219fc5fe323) - use 'git log' to get current commit hash [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
### Continious Integration
- **git_push_mirror**: b593505698b3d3359569f29f97c90e17e211f304 - Push repo to github NoFussComputing/gitlab-gi
- **conventional_commits**: a2174104d1eb05d329bacd44700bf81ac709dcac - Add conventional commits job to check commits and MR titles
- **git_push_mirror**: [b5935056](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/b593505698b3d3359569f29f97c90e17e211f304) - Push repo to github NoFussComputing/gitlab-gi [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
- **conventional_commits**: [a2174104](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/a2174104d1eb05d329bacd44700bf81ac709dcac) - Add conventional commits job to check commits and MR titles [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
### Documentaton / Guides
- **README.md**: 247264e36bc0b6c86d2f06f8dae09ff7447fc156 - Added readme for the repo
- **git_push_mirror**: 7ffb20418cfa8e6fa20cca60e42155171961d1ce - Update workflow and typos
- **README.md**: [247264e3](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/247264e36bc0b6c86d2f06f8dae09ff7447fc156) - Added readme for the repo [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
- **git_push_mirror**: [7ffb2041](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/7ffb20418cfa8e6fa20cca60e42155171961d1ce) - Update workflow and typos [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
### Features
- **job_changelog**: 1ecd857c0bf8ef009ad2482ad1d52604adadc0ed - Create a changelog per job folder
- **git_release**: 6678a3dbab2763addc185e766cbaffbc074a6e98 - Migrated from ansible-roles
- **ansible**: 2413daefb1e7e5a9e7a3cbb2d8cff2214f4a98ae - Added ansible validation job for linting
- **git_push_mirror**: 9b28ae5952adfb3d61e660814074ad3c7b42ff61 - Added a job that syncs to a remote git repo
- **conventional_commits**: 392a200fd469c4161dbab5f2b59031a7a64f20a2 - Added conventional commit job
- **job_changelog**: [1ecd857c](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/1ecd857c0bf8ef009ad2482ad1d52604adadc0ed) - Create a changelog per job folder [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
- **git_release**: [6678a3db](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/6678a3dbab2763addc185e766cbaffbc074a6e98) - Migrated from ansible-roles [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
- **ansible**: [2413daef](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/2413daefb1e7e5a9e7a3cbb2d8cff2214f4a98ae) - Added ansible validation job for linting [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
- **git_push_mirror**: [9b28ae59](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/9b28ae5952adfb3d61e660814074ad3c7b42ff61) - Added a job that syncs to a remote git repo [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
- **conventional_commits**: [392a200f](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/392a200fd469c4161dbab5f2b59031a7a64f20a2) - Added conventional commit job [ [#1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues/1) ]
## v0.0.1 (2021-08-03)

120
README.md
View File

@ -1,20 +1,132 @@
# Ansible Roles
<div align="center">
[![Gitlab build status - stable](https://img.shields.io/badge/dynamic/json?color=ff782e&label=Build%20%5B%20Stable%20%5D&query=0.status&url=https%3A%2F%2Fgitlab.com%2Fapi%2Fv4%2Fprojects%2F28543717%2Fpipelines%3Fref%3Dmaster&logo=gitlab&style=plastic)](https://gitlab.com/nofusscomputing/projects/gitlab-ci)
# No Fuss Computing - Gitlab-CI
[![Open Issues](https://img.shields.io/badge/dynamic/json?color=ff782e&logo=gitlab&style=plastic&label=Open%20Issues&query=%24.statistics.counts.opened&url=https%3A%2F%2Fgitlab.com%2Fapi%2Fv4%2Fprojects%2F28543717%2Fissues_statistics)](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues)
[![Gitlab build status - development](https://img.shields.io/badge/dynamic/json?color=ff782e&label=Build%20[%20Development%20]&query=0.status&url=https%3A%2F%2Fgitlab.com%2Fapi%2Fv4%2Fprojects%2F28543717%2Fpipelines%3Fref%3Ddevelopment&logo=gitlab&style=plastic)](https://gitlab.com/nofusscomputing/projects/gitlab-ci)
| Stable Branch | [![Gitlab build status - stable](https://img.shields.io/badge/dynamic/json?color=ff782e&label=Build&query=0.status&url=https%3A%2F%2Fgitlab.com%2Fapi%2Fv4%2Fprojects%2F28543717%2Fpipelines%3Fref%3Dmaster&logo=gitlab&style=plastic)](https://gitlab.com/nofusscomputing/projects/gitlab-ci) | [![PyLint Score](https://img.shields.io/badge/dynamic/json?&style=plastic&logo=python&label=PyLint%20Score&query=%24.PyLintScore&url=https%3A%2F%2Fgitlab.com%2Fnofusscomputing%2Fprojects%2Fgitlab-ci%2F-%2Fjobs%2Fartifacts%2Fmaster%2Fraw%2Fartifacts%2Fvalidation%2FPyLint%2Fbadge_pylint.json%3Fjob%3DPyLint)](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/jobs/artifacts/master/file/artifacts/validation/tests/gl-code-quality-report.html?job=PyLint) |
|:----|:----|:----|
| development Branch | [![Gitlab build status - development](https://img.shields.io/badge/dynamic/json?color=ff782e&label=Build&query=0.status&url=https%3A%2F%2Fgitlab.com%2Fapi%2Fv4%2Fprojects%2F28543717%2Fpipelines%3Fref%3Ddevelopment&logo=gitlab&style=plastic)](https://gitlab.com/nofusscomputing/projects/gitlab-ci) | [![PyLint Score](https://img.shields.io/badge/dynamic/json?&style=plastic&logo=python&label=PyLint%20Score&query=%24.PyLintScore&url=https%3A%2F%2Fgitlab.com%2Fnofusscomputing%2Fprojects%2Fgitlab-ci%2F-%2Fjobs%2Fartifacts%2Fdevelopment%2Fraw%2Fartifacts%2Fvalidation%2FPyLint%2Fbadge_pylint.json%3Fjob%3DPyLint)](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/jobs/artifacts/development/file/artifacts/validation/tests/gl-code-quality-report.html?job=PyLint) |
|:----|:----|:----|
</div>
This repository is hosted on [gitlab.com](https://gitlab.com/nofusscomputing/projects/gitlab-ci) and has a read-only copy hosted on [github.com](https://github.com/NoFussComputing/gitlab-ci).
links:
- [Issues](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/issues)
- [Merge Requests (Pull Requests)](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/merge_requests)
> *To Do: expand on how repo setup and how to use.*
## Using this repository for your Gitlab CI/CD Jobs.
This repository has been designed as a central point for your repositories CI/CD jobs. By simply linking this repository to your repository and configuring, your CI/CD jobs will run as part of the build process, whilst keeping any CI/CD commits limited within your git history.
Each CI/CD job is contained within its own sub-folder. Each sub-folder has a readme specific to the job, which includes the details on how to implement, use etc.
### gitlab-ci layout
We use the following branches *(these jobs assume you do as well)*:
- `master` - Considered as the stable branch
- `development` considered as unstable
We also tag each branch to denote the version of release. We use our own repo to do the version increment automagically in line with [semantic versioning](https://semver.org/).
### CI Stages
The CI stages for these jobs are as follows, and in the order expected by the jobs:
- validation
> validation of files, commits, Merge Request titles, code quality, license checks.
- build
> build any binaries or files that would be used in the later stages .
- prepare
> any jobs that must run after build but before testing. for example a docker image build that includes artifacts from the build job
- test
> unit, functional, integration and any other tests.
- release
> git tagging and creating a gitlab release. Also includes adding build artifacts to gitlab registry.
- sync
> repository synchronization, i.e. push mirror to github.
- publish
> placement of build objects to external sources
### .gitlab-ci.yml example
example:
``` yaml
stages:
- validation
- build
- prepare
- test
- release
- sync
- publish
variables:
GIT_SUBMODULE_STRATEGY: recursive
MY_PROJECT_ID: "{your_project_id}"
include:
- project: nofusscomputing/projects/gitlab-ci
ref: 68b6bc3bfacf0770e10d2e10a5c57952070d44fe
file:
- conventional_commits/.gitlab-ci.yml
- gitlab_release/.gitlab-ci.yml
- git_push_mirror/.gitlab-ci.yml
- ansible/.gitlab-ci.yml
```
| :bulb: Tip |
|:----|
| *Use a project import in your `.gitlab-ci.yml` file that is tied to a specific `ref`. for example a commit or tag. Also ensure that the `gitlab-ci` `git sub-module` and the `ref` as part of the includes matches.* |
### Artifacts
Any artifacts by jobs will be created in folders named after the stage.
preference is placed on jobs to output JUnit.xml test reports. This is because they are visible in merge requests.
## Git Sub-Module setup
It is recommended that you set-up this repo as a git sub-module to your repo and that you configure it to a set commit/tag. This ensures that any change to `gitlab-ci` repo, does not effect your CI/CD jobs.
run the following commands:
``` bash
git submodule add -b {ref} https://gitlab.com/nofusscomputing/projects/gitlab-ci.git gitlab-ci
git submodule update --remote
```
| :bulb: Tip |
|:-----|
| NOTE: `{ref}` should be replaced with the branch name, `master` is the stable branch and recommended. by default the sub-module will be created in folder `gitlab-ci`, it is recommended that you **don't** change this folder name.
You can also substitute the gitlab url with the github url `https://github.com/NoFussComputing/gitlab-ci.git` for the submodule if you desire. this repo is auto-synced with github on each change to the repo. |
After each `git submodule update --remote` you will have to commit the sub-module update to your repo. Suggested commands as follows:
``` bash
git add .gitmodules
git add gitlab-ci
git commit -m "ci(gitlab-ci): updated to use version x
{your reason here or explain what is provided/changed}"
```
Then push the changes to your source.
## Contributing

View File

@ -22,13 +22,13 @@
after_script:
- echo deactivate
artifacts:
expire_in: 3 days
when: always
paths:
- "artifacts/*"
reports:
junit:
- "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/*.junit.xml"
expire_in: 3 days
when: always
paths:
- "artifacts/*"
reports:
junit:
- "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/*.junit.xml"
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: never

View File

@ -1,5 +1,11 @@
# Changelog
2021-08-12 03:32:36 +0000 [389bc08](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/389bc08d7686153fb374aa83d440c35c9b4eac90) - build(version): bump version 0.3.0rc1 → 0.3.0
2021-08-11 13:47:34 +0930 [def31ef](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/def31ef562c0002713401652657d59320548ee85) - style(yaml_lint): fixed yaml lint errors
2021-08-04 03:23:08 +0000 [eb5cc8a](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/eb5cc8a0e2885a9ed16a8d1a81611aec4d5a4d31) - build(version): bump version 0.3.0rc0 → 0.3.0rc1
2021-08-04 03:13:54 +0000 [09dcb65](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/09dcb65b090f59e9f8a6bea5eba4bb98bddbad3d) - build(version): bump version 0.2.1 → 0.3.0rc0
2021-08-04 02:49:45 +0000 [4453b43](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/4453b433c8966a334f02af592a6ce8092f2ac9de) - build(version): bump version 0.2.0 → 0.2.1
2021-08-04 02:24:12 +0000 [856f2e1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/856f2e1770d0bda823996122ee70916dc0fe455b) - build(version): bump version 0.1.0 → 0.2.0
2021-08-04 01:33:47 +0000 [6d34977](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/6d349774269bcd7c6e406cfe72c78b99f246df7b) - build(version): bump version 0.0.1 → 0.1.0
2021-08-03 15:23:19 +0930 [2a3266f](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/2a3266fb537e22dddf47708d0af101945027128f) - fix(ansible): Ensure the default ci directory is populated
2021-08-03 15:08:37 +0930 [2413dae](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/2413daefb1e7e5a9e7a3cbb2d8cff2214f4a98ae) - feat(ansible): Added ansible validation job for linting

View File

@ -50,11 +50,11 @@
junit:
- "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/*.junit.xml"
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: never
- if: '$CI_COMMIT_BRANCH'
when: always
- when: never
- if: '$CI_COMMIT_BRANCH == "master"'
when: never
- if: '$CI_COMMIT_BRANCH'
when: always
- when: never
MR Title:
@ -69,5 +69,6 @@ Commit Messages:
extends:
- .conventional_commit
script:
- cz_exit=0 && cz check --rev-range $first_sha1..HEAD > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/cz_output.log" 2>&1 || cz_exit=$?
- if [ "$(git log $first_sha1..HEAD --format=format:%H | wc -l)" -eq 0 ]; then echo "[DEBUG] Single Commit"; cz_exit=0 && cz check -m "$(git log HEAD --format=format:%B -1)" > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/cz_output.log" 2>&1 || cz_exit=$?; fi
- if [ "$(git log $first_sha1..HEAD --format=format:%H | wc -l)" -gt 0 ]; then echo "[DEBUG] Commit range"; cz_exit=0 && cz check --rev-range $first_sha1..HEAD > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/cz_output.log" 2>&1 || cz_exit=$?; fi
- . $ROOT_DIR/conventional_commits/scripts/cz_junit.sh > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$CI_JOB_NAME-cz.junit.xml"

View File

@ -1,4 +1,11 @@
# Changelog
2021-08-12 03:32:36 +0000 [389bc08](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/389bc08d7686153fb374aa83d440c35c9b4eac90) - build(version): bump version 0.3.0rc1 → 0.3.0
2021-08-12 12:47:23 +0930 [3360a15](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/3360a15fde12682edfd9044d2541dc819615b838) - fix(commit_message): fixed commit message check if there is only one commit to the branch
2021-08-11 13:47:34 +0930 [def31ef](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/def31ef562c0002713401652657d59320548ee85) - style(yaml_lint): fixed yaml lint errors
2021-08-04 03:23:08 +0000 [eb5cc8a](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/eb5cc8a0e2885a9ed16a8d1a81611aec4d5a4d31) - build(version): bump version 0.3.0rc0 → 0.3.0rc1
2021-08-04 03:13:54 +0000 [09dcb65](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/09dcb65b090f59e9f8a6bea5eba4bb98bddbad3d) - build(version): bump version 0.2.1 → 0.3.0rc0
2021-08-04 02:49:45 +0000 [4453b43](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/4453b433c8966a334f02af592a6ce8092f2ac9de) - build(version): bump version 0.2.0 → 0.2.1
2021-08-04 02:24:12 +0000 [856f2e1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/856f2e1770d0bda823996122ee70916dc0fe455b) - build(version): bump version 0.1.0 → 0.2.0
2021-08-04 01:33:47 +0000 [6d34977](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/6d349774269bcd7c6e406cfe72c78b99f246df7b) - build(version): bump version 0.0.1 → 0.1.0
2021-08-03 13:26:05 +0930 [392a200](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/392a200fd469c4161dbab5f2b59031a7a64f20a2) - feat(conventional_commits): Added conventional commit job

View File

@ -14,9 +14,7 @@
artifacts:
expire_in: 1 day
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
- if: '$CI_COMMIT_BRANCH == "development"'
when: always
- if: '$CI_COMMIT_BRANCH == "master"'
- if: '$CI_COMMIT_BRANCH == "development"'
when: always

View File

@ -1,5 +1,11 @@
# Changelog
2021-08-12 03:32:36 +0000 [389bc08](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/389bc08d7686153fb374aa83d440c35c9b4eac90) - build(version): bump version 0.3.0rc1 → 0.3.0
2021-08-11 13:47:34 +0930 [def31ef](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/def31ef562c0002713401652657d59320548ee85) - style(yaml_lint): fixed yaml lint errors
2021-08-04 03:23:08 +0000 [eb5cc8a](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/eb5cc8a0e2885a9ed16a8d1a81611aec4d5a4d31) - build(version): bump version 0.3.0rc0 → 0.3.0rc1
2021-08-04 03:13:54 +0000 [09dcb65](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/09dcb65b090f59e9f8a6bea5eba4bb98bddbad3d) - build(version): bump version 0.2.1 → 0.3.0rc0
2021-08-04 02:49:45 +0000 [4453b43](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/4453b433c8966a334f02af592a6ce8092f2ac9de) - build(version): bump version 0.2.0 → 0.2.1
2021-08-04 02:24:12 +0000 [856f2e1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/856f2e1770d0bda823996122ee70916dc0fe455b) - build(version): bump version 0.1.0 → 0.2.0
2021-08-04 01:33:47 +0000 [6d34977](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/6d349774269bcd7c6e406cfe72c78b99f246df7b) - build(version): bump version 0.0.1 → 0.1.0
2021-08-03 14:44:28 +0930 [247264e](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/247264e36bc0b6c86d2f06f8dae09ff7447fc156) - docs(README.md): Added readme for the repo
2021-08-03 14:40:17 +0930 [7ffb204](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/7ffb20418cfa8e6fa20cca60e42155171961d1ce) - docs(git_push_mirror): Update workflow and typos

View File

@ -15,16 +15,16 @@
- pip install $ROOT_DIR/gitlab_release/python-module/cz_nfc/.
- 'CLONE_URL="https://gitlab-ci-token:$GIT_COMMIT_TOKEN@gitlab.com/$CI_PROJECT_PATH.git"'
- echo "[DEBUG] CLONE_URL[$CLONE_URL]"
- git clone -b $CI_COMMIT_BRANCH $CLONE_URL repo
- git clone -b development $CLONE_URL repo
- cd repo
- git branch
- git config --global user.email "CI@nfc-gitlab"
- git config --global user.name "NFC CI"
- git push --set-upstream origin $CI_COMMIT_BRANCH
- git push --set-upstream origin development
- RELEASE_VERSION_CURRENT=$(cz -n cz_nfc version --project)
script:
- "$MY_COMMAND"
- RELEASE_CHANGELOG=$(cz -n cz_nfc bump --changelog --changelog-to-stdout)
- if [ "$CI_COMMIT_BRANCH" == "development" ] ; then RELEASE_CHANGELOG=$(cz -n cz_nfc bump --changelog --changelog-to-stdout --prerelease rc); else RELEASE_CHANGELOG=$(cz -n cz_nfc bump --changelog --changelog-to-stdout); fi
- RELEASE_VERSION_NEW=$(cz -n cz_nfc version --project)
- RELEASE_TAG=v$RELEASE_VERSION_NEW
- if [ "0$RELEASE_VERSION_CURRENT" == "0$RELEASE_VERSION_NEW" ]; then echo "[DEBUG] No tag to delete, version was not bumped"; else git tag -d $RELEASE_TAG; fi
@ -36,14 +36,59 @@
- echo "[DEBUG] RELEASE_TAG_SHA1[$RELEASE_TAG_SHA1]"
- if [ "0$RELEASE_VERSION_CURRENT" == "0$RELEASE_VERSION_NEW" ]; then echo "[DEBUG] No push will be conducted, version was not bumped"; else git push; fi
- if [ "0$RELEASE_VERSION_CURRENT" == "0$RELEASE_VERSION_NEW" ]; then echo "[DEBUG] No release will be created, version was not bumped"; else release-cli create --name "Release $RELEASE_TAG" --tag-name "$RELEASE_TAG" --ref "$RELEASE_TAG_SHA1" --description "$RELEASE_CHANGELOG"; fi
- if [ "$CI_COMMIT_BRANCH" == "master" ] ; then git checkout master; fi
- if [ "$CI_COMMIT_BRANCH" == "master" ] ; then git push --set-upstream origin master; fi
- if [ "$CI_COMMIT_BRANCH" == "master" ] ; then git merge --no-ff development; fi
- if [ "$CI_COMMIT_BRANCH" == "master" ] ; then git push origin master; fi
after_script:
- rm -Rf repo
rules:
- if: "$CI_COMMIT_AUTHOR =='NFC CI <CI@nfc-gitlab>'"
when: never
- if: '$CI_COMMIT_BRANCH == "development"'
- if: '$TRIGGER_RELEASE == "True" && $CI_COMMIT_BRANCH == "development"'
when: on_success
- if: '$CI_COMMIT_BRANCH == "master"'
when: always
allow_failure: false
- if: '$CI_COMMIT_BRANCH == "development"'
when: manual
allow_failure: true
- when: never
commit footer refs:
stage: validation
image: python:3.6-slim
variables:
DEFAULT_ROOT_DIR: './gitlab-ci'
before_script:
- mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME"
- mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests"
- if [ "0$JOB_ROOT_DIR" == "0" ]; then export ROOT_DIR=$DEFAULT_ROOT_DIR; else export ROOT_DIR=$JOB_ROOT_DIR ; fi
- echo "[DEBUG] ROOT_DIR[$ROOT_DIR]"
- apt update
- apt install --no-install-recommends -y git
- pip install -e $ROOT_DIR/gitlab_release/python-module/commit_footer/.
- git clone --depth 150 -b development $CI_REPOSITORY_URL check
- cd check
- git remote rm origin
- git remote add origin $CI_REPOSITORY_URL
- git fetch --all
- git checkout --track origin/$CI_COMMIT_BRANCH
- git submodule update --init
script:
- commit_footer > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$CI_JOB_NAME.junit.xml"
artifacts:
expire_in: 1 days
when: always
paths:
- "$CI_PROJECT_DIR/artifacts/*"
reports:
junit:
- "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/*.junit.xml"
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
- if: '$CI_COMMIT_BRANCH == "development"'
when: never
- if: '$CI_COMMIT_BRANCH && $CHANGELOG_FOOTER_REFERENCES != "False"'
when: always
- when: never

View File

@ -1,5 +1,30 @@
# Changelog
2021-08-12 14:46:26 +0930 [2ac22c0](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/2ac22c0e914016a8944ff9b94640f3e87f409069) - fix(commit_footer): fix bug introduced in code quality commit
2021-08-12 14:42:16 +0930 [ccc601f](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/ccc601f641a9b07b63a160d779c5037481316e75) - style(cz_nfc): code quality on cz_nfc.py
2021-08-12 14:27:41 +0930 [5676c5e](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/5676c5ee376f574a8581e8c8f4810eb5a7c511ba) - style(commit_footer): code quality on setup.py
2021-08-12 14:26:43 +0930 [3d69e57](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/3d69e57714cd529b13ddc9c575c2dc955a350dd9) - style(commit_footer): code quality on __main__.py
2021-08-12 14:21:34 +0930 [c093c31](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/c093c31cbd12989f7109dbcb6fd4f029c42a3919) - style(commit_footer): code quality on commits.py
2021-08-12 03:32:36 +0000 [389bc08](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/389bc08d7686153fb374aa83d440c35c9b4eac90) - build(version): bump version 0.3.0rc1 → 0.3.0
2021-08-11 13:47:34 +0930 [def31ef](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/def31ef562c0002713401652657d59320548ee85) - style(yaml_lint): fixed yaml lint errors
2021-08-11 12:17:50 +0930 [63af1ef](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/63af1efb4fd92a9f8755f766728a18d8f390b805) - fix(commit_footer_refs): Use the current git branch for comparison.
2021-08-08 15:57:50 +0930 [dc13d4f](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/dc13d4f2841038c085dcf29dfb0b0c5d2f00f099) - docs(gitlab_release): Added user docs to fix errors from ci job 'commit footer refs'
2021-08-08 15:28:00 +0930 [22136f7](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/22136f7dd22b9487d362a7ed63ca1b76e52b9cc7) - feat(gitlab_release): Toggle var added to enable switching changelog references.
2021-08-08 15:18:11 +0930 [eb0bf4c](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/eb0bf4c1740dbd7a47ceb031c0d1c854899a1e40) - refactor(gitlab_release): file link to be in local repository for helping fix commit footer ref check failures
2021-08-08 15:05:35 +0930 [8177622](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/81776223c5cb392c12c7ca63488a1df10290e9d1) - refactor(gitlab_release): use a name for failed test to denote the issue
2021-08-08 15:03:12 +0930 [756b940](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/756b9406dde8cf0bf0030ac72855a054ece3a883) - feat(gitlab_release): be able to toggle commit footer check job
2021-08-08 14:51:57 +0930 [7cb676e](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/7cb676eb98a7de30d47a6b49a87067116684cfd2) - ci(gitlab_release): Add a validation job to check if commit messages contain a gitlab reference in the footer
2021-08-08 14:50:34 +0930 [11e1566](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/11e156619d0d820e534897bafd5f39e6f9defcbf) - feat(gitlab_release): python module to check if a commit message has gitlab references in the footer
2021-08-07 17:11:17 +0930 [8699c41](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/8699c41219d70e6f41f42dc7f2c1bcf542b3f723) - feat(gitlab_release): Add commit footer to changelog
2021-08-07 14:56:51 +0930 [5f273ce](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/5f273ce23a331eaf11623207ec4aba8b856c14f0) - docs(gitlab_release): Updated docs with new instructions on version incrementing
2021-08-07 14:31:19 +0930 [f76cabe](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/f76cabeeb04b028a231dc1c232862db5fcad4345) - fix(gitlab_release): Adjust release workflow
2021-08-04 03:23:08 +0000 [eb5cc8a](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/eb5cc8a0e2885a9ed16a8d1a81611aec4d5a4d31) - build(version): bump version 0.3.0rc0 → 0.3.0rc1
2021-08-04 03:13:54 +0000 [09dcb65](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/09dcb65b090f59e9f8a6bea5eba4bb98bddbad3d) - build(version): bump version 0.2.1 → 0.3.0rc0
2021-08-04 12:39:01 +0930 [3e8c3ce](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/3e8c3ce7cd64a6e9110818d32c15c3602fefb76c) - feat(gitlab_release): On the development brnach, releases to be 'rc' to denote considered non-stable
2021-08-04 12:24:02 +0930 [cc3fabd](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/cc3fabdaa28f97c3e1600e4a0d95a05bb547e772) - refactor(gitlab_release): Use Short commit SHA1 in main changelog link to gitlab
2021-08-04 02:49:45 +0000 [4453b43](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/4453b433c8966a334f02af592a6ce8092f2ac9de) - build(version): bump version 0.2.0 → 0.2.1
2021-08-04 12:05:01 +0930 [588698d](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/588698df2668853a97fe60901ab324310f34f279) - fix(gitlab_release): Correctly fetch the CI_PROJECT_URL for the environment
2021-08-04 02:24:12 +0000 [856f2e1](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/856f2e1770d0bda823996122ee70916dc0fe455b) - build(version): bump version 0.1.0 → 0.2.0
2021-08-04 11:50:41 +0930 [287b4c9](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/287b4c954dddfaaf0a66af387676ea438cc80e61) - feat(gitlab_release): Include code refactor as part of the changelog
2021-08-04 11:48:28 +0930 [eebe8e3](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/eebe8e30dcb11cd239f35fcb98216b2ae4d20ece) - docs(gitlab_release): Include custom command instructions
2021-08-04 11:29:22 +0930 [7a69685](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/7a69685b53cbe5bd7341a176bf63fd17d36bc7f0) - refactor(gitlab_release): Dont conduct any release, git push or tag delete if the version was not bumped

View File

@ -1,5 +1,58 @@
# Gitlab Release
This job bumps the version, updates the changelog, creates a git tag and creates a gitlab release. The git tag and release title use [semantic versioning](https://semver.org/). for this job to function correctly a `.cz.yaml` is required in the root of the repository. this file contains the [commitizen](https://github.com/commitizen-tools/commitizen) config and the version details. This job runs on successful completion of previous jobs and only on `development` and `master` branches.
# Commit Message Footer References - User Manual
All commit messages must be in [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0/) and have a footer with a gitlab reference. The reference **must** be either a merge request or a gitlab issue. (format i.e. `!1` or `#2` *using the correct reference number*).
## fixing commit messages (suggestion)
If only the last commit is the commit with an error just use `git commit --amend` and edit your commit message to be in the correct format and save. now push your changes.
You will require the following information if the commit message with the error is further down the commit tree:
- Commit message SHA1 of your first commit message to the branch `{original_commit}`
- Commit message SHA1 prior to your first commit `{source_commit}`
Run these commands once you have the information above.
``` bash
git format-patch {original_commit}..HEAD -o diff-patches
git reset {source_commit} --hard
```
Now, navigate to the `diff-patches` folder, open up the offending patch (commit) and edit the `subject` or message body as appropriate and save. Once all the edits have been done, re-apply the patches to your tree with:
``` bash
git am diff-patches/*.patch
```
Now push your changes upstream.
| :notebook_with_decorative_cover: Note |
|:-----:|
| *As you have changed the commit SHA1(s), when you next push your changes upstream, you must force push. `git push --force`* |
| :octagonal_sign: **WARNING** |
|:-----:|
| *Ensure that all of your commits were exported prior to reseting the branch and when re-applying, that all of your commits were applied correctly* |
# Gitlab Release - Developer Manual
This job bumps the version, updates the changelog, creates a git tag and creates a gitlab release. The git tag and release title use [semantic versioning](https://semver.org/). for this job to function correctly a `.cz.yaml` is required in the root of the repository. this file contains the [commitizen](https://github.com/commitizen-tools/commitizen) config and the version details.
This job has the following workflow:
- `master` Branch
> Automatically increment the version
- `development` Branch
> Manual CI job made available to increment the version. (release-candidate increment only)
| :octagonal_sign: Danger |
|:----|
| *If prior to merging to the master branch you do a version increment, and there are no commits prior to merging. the job will not increment the version and the job will fail. it is recommended that you only do a version increment on the `development` branch if you are going to commit further changes to the `development` branch* |
This job provides the following badge:
@ -8,13 +61,16 @@ This job provides the following badge:
## Dependencies
- This job will only run if all previous jobs run.
- None
## your .gitlab-ci.yml changes
To use this job add the following to your `.gitlab-ci.yml` file
CI Job `ci commit footer` is automatically set to run on all branches except `development` and `master`. This job checks the commits on the users branch that they contain a footer with gitlab references. i.e. `#1` for issue one or `!1` for merge request one.
``` yaml
stages:
- validate
- release
include:
@ -34,6 +90,7 @@ Gitlab Release:
| var name | Description |
|:----:|:----|
| GIT_COMMIT_TOKEN | *this must be a personal token that has write access to the repository* |
| CHANGELOG_FOOTER_REFERENCES | ***Optional** If set to `False` the changelog will not output gitlab references for each entry of the changelog. If this variable is set globally, it will also prevent the creation of the CI job to validate a users commits as having gitlab references.* |
## Job Workflow
@ -46,23 +103,19 @@ This CI job's workflow is:
1. pushes the change back to the repo
1. creates a git release from the `git tag`
| :octagonal_sign: **NOTE** |
|:----|
| *If the user has forked the branch, they must keep the development brnach synced with the main repo. If they **don't** the CI job 'commit footer refs' will fail as it will not be able to fetch the parent (`development`) hash of the branch.* |
## Artifacts
- None
- `ci commit footer`
> $CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$CI_JOB_NAME.junit.xml
- `Gitlab Release`
> None
## License
To view the license for this folder and any sub-folders, refer [here](https://gitlab.com/nofusscomputing/projects/gitlab-ci)

View File

@ -0,0 +1,6 @@
#-*- coding: utf-8 -*-
import cli
if __name__ == '__main__':
cli.main()

View File

@ -0,0 +1,14 @@
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
import sys
from commits import Commits
def main():
commits = Commits()
if commits.check():
sys.exit(0)
else:
sys.exit(1)

View File

@ -0,0 +1,139 @@
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
import os
import re
import git
class Commits:
def __init__(self):
self._repository = git.Repo(os.getcwd())
self._failed = []
merge_base = self._repository.merge_base('development', self._repository.active_branch)
self._merge_base = str(merge_base[0])
self.fetch_all()
def fetch_all(self) -> bool: # get the commits and filter to only the current branch
commits = list(self._repository.iter_commits(self._repository.active_branch))
clean = True
branch_commits = []
for remove in commits:
if str(remove).lower() == self._merge_base.lower():
clean = False
if clean:
branch_commits.append(remove)
self._commits = branch_commits
def fetch(self, sha1:str) -> str: # fetch a single git message
for commit in self._commits:
if str(commit).lower() == sha1.lower():
return commit.message
return ''
# Get the last line of the commit message if has more than 2 lines
def footer(self, git_message:str) -> list:
footer = None
if git_message.count("\n") > 2:
footer_line = git_message.split("\n")
footer_line = footer_line[(len(footer_line)-1)]
commit_footer = re.findall(r"([\!|\#][0-9]+)", str(git_message))
if len(commit_footer) > 0:
footer = commit_footer
else:
footer = False
return footer
def junit(self) -> bool:
junit_testsuites = '''<testsuites
id="Commits Messages Check"
name="commit footer references"
errors="{0}"
tests="{1}"
time="0">'''.format(len(self._failed), len(self._commits))
junit_testsuite = '''<testsuite
errors="{0}"
name="commit footer references"
tests="{1}">'''.format(len(self._failed), len(self._commits))
junit_testcase = ''
for commit in self._failed:
for key in commit:
junit_testcase += '''
<testcase
classname="{0}"
file="{2}/gitlab_release/README.md"
line="0"
name="No commit footer references found"
time="0"
timestamp="date">
<failure
message="No References in the commit footer"
type="validation">{1}</failure>
<system-out>
<![CDATA[ {1} ]]>
</system-out>
<system-err>
<![CDATA[ {1} ]]>
</system-err>
</testcase>'''.format(key, str(commit[key]), os.environ['ROOT_DIR'])
if junit_testcase == '':
junit_testcase = '''<testcase
classname="Commit footer references check"
file="' + os.environ['ROOT_DIR'] + '/gitlab_release/README.md"
name="has commit footer references"/>'''
junit_close = '</testsuite></testsuites>'
print(str(junit_testsuites))
print(str(junit_testsuite))
print(str(junit_testcase))
print(str(junit_close))
def check(self) -> bool:
check = True
for commit in self._commits:
if commit.message.count('\n') < 3:
continue
footer = self.footer(commit.message)
if footer is False:
failed = {str(commit): str(commit.message)}
self._failed.append(failed)
continue
self.junit()
if len(self._failed) > 0:
check = False
return check

View File

@ -0,0 +1,13 @@
from setuptools import setup
setup(
name='NFC commit footer validation',
version='0.1.0',
py_modules=['main'],
license='MIT',
long_description='this is a long description',
install_requires=['gitpython'],
entry_points = {
'console_scripts': ['commit_footer=cli:main'],
},
)

View File

@ -1,16 +1,38 @@
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
import os
import re
import git as Git
from commitizen import git
from commitizen.cz.base import BaseCommitizen
class nfc_cz(BaseCommitizen):
class NoFussCz(BaseCommitizen):
bump_pattern = r"^(break|new|fix|feat|hotfix|ci|docs)"
bump_map = {"break": "MAJOR", "new": "MINOR", "feat": "MINOR","fix": "PATCH", "hotfix": "PATCH", "ci": "PATCH", "docs": "PATCH"}
bump_map = {
"break": "MAJOR",
"new": "MINOR",
"feat": "MINOR",
"fix": "PATCH",
"hotfix": "PATCH",
"ci": "PATCH",
"docs": "PATCH"
}
changelog_pattern = "^(break|new|fix|feat|hotfix|refactor|ci|docs)"
change_type_order = ["BREAKING CHANGE", "feat", "fix", "refactor", "perf", "docs", "ci"]
change_type_order = [
"BREAKING CHANGE",
"feat",
"fix",
"refactor",
"perf",
"docs",
"ci"
]
change_type_map = {
"feat": "Features",
"fix": "Bug Fixes",
@ -25,8 +47,63 @@ class nfc_cz(BaseCommitizen):
def changelog_message_builder_hook(self, parsed_message: dict, commit: git.GitCommit) -> dict:
rev = commit.rev
m = parsed_message["message"]
parsed_message["message"] = f"[{rev}]($CI_PROJECT_URL/-/commit/{rev}) - {m}"
rev_short = str(rev)[0:8]
repo = Git.Repo(os.getcwd())
tree = list(repo.iter_commits(repo.active_branch))
footer_references = ''
for item in tree:
if item.message.count("\n") > 2 and str(item).lower() == rev.lower():
footer_line = item.message.split("\n")
footer_line = footer_line[(len(footer_line)-1)]
footer = re.findall(r"([\!|\#][0-9]+)", str(item.message))
try:
for reference in footer:
if '#' in reference:
footer_references += ' ' + str(
'[{0}]({1}/-/issues/{2})'.format(
reference,
os.environ['CI_PROJECT_URL'],
reference.replace('#', '')
)
)
if '!' in reference:
footer_references += ' ' + str(
'[{0}]({1}/-/merge_requests/{2})'.format(
reference,
os.environ['CI_PROJECT_URL'],
reference.replace('!', '')
)
)
except Exception:
pass
add_references = True
try:
if os.environ['CHANGELOG_FOOTER_REFERENCES'] == 'False':
add_references = False
except KeyError: # continue if the os var doesn't exist
add_references = True
if footer_references != '' and add_references:
footer_references = ' [' + footer_references + ' ]'
else:
footer_references = ''
msg = parsed_message["message"]
project_url = os.environ['CI_PROJECT_URL']
parsed_message["message"] = f"[{rev_short}]({project_url}/-/commit/{rev}) - {msg}{footer_references}"
return parsed_message
@ -37,4 +114,4 @@ class nfc_cz(BaseCommitizen):
raise NotImplementedError("Not Implemented yet")
discover_this = nfc_cz
discover_this = NoFussCz

View File

@ -6,5 +6,5 @@ setup(
py_modules=['cz_nfc'],
license='MIT',
long_description='this is a long description',
install_requires=['commitizen']
install_requires=['commitizen', 'gitpython']
)

52
python/.gitlab-ci.yml Normal file
View File

@ -0,0 +1,52 @@
.pylint_badge: &pylint_badge |
echo "{
\"PyLintScore\": \"$PyPIScore\"
}" > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/badge_pylint.json"
.PyLint:
variables:
PYLINT_PATH: "/*/python-module/*/*.py"
PYLINT_RC_PATH: "/python/.pylintrc"
stage: validation
before_script:
- if [ "0$JOB_ROOT_DIR" == "0" ]; then ROOT_DIR=gitlab-ci; else ROOT_DIR=$JOB_ROOT_DIR ; fi
- echo "[DEBUG] ROOT_DIR[$ROOT_DIR]"
- mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME"
- mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests"
- export PYTHON_VERSION=`python -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}.{2}".format(*version))'`
- apt update
- apt install --no-install-recommends -y git
- python3 -m venv env
- . env/bin/activate
- pip install --upgrade pip
- pip install -r $ROOT_DIR/python/requirements.txt
- mkdir $PYTHON_VERSION
script:
- PYLINT_PATH=$ROOT_DIR$PYLINT_PATH
- echo "[DEBUG] PYLINT_PATH[$PYLINT_PATH]"
- PYLINT_RC_PATH=$ROOT_DIR$PYLINT_RC_PATH
- echo "[DEBUG] PYLINT_RC_PATH[$PYLINT_RC_PATH]"
- python3 -m pylint --rcfile $PYLINT_RC_PATH --exit-zero --output-format=pylint_gitlab.GitlabCodeClimateReporter $PYLINT_PATH > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/gl-code-quality-report.json"
- python3 -m pylint --rcfile $PYLINT_RC_PATH --exit-zero --output-format=pylint_gitlab.GitlabPagesHtmlReporter $PYLINT_PATH > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/gl-code-quality-report.html"
- PyPIScore=$(python3 -m pylint --rcfile $PYLINT_RC_PATH --exit-zero $PYLINT_PATH | sed -n 's/^Your code has been rated at \([-0-9./]*\).*/\1/p')
- *pylint_badge
after_script:
- echo deactivate
artifacts:
expire_in: 1 days
when: always
paths:
- "artifacts/*"
reports:
codequality: "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/gl-code-quality-report.json"
rules:
- if: '$CI_COMMIT_BRANCH'
when: always
- when: never

5
python/.pylintrc Normal file
View File

@ -0,0 +1,5 @@
[MASTER]
disable=
C0114, # missing-module-docstring
C0115, # missing-class-docstring
C0116, # missing-function-docstring

7
python/CHANGELOG.md Normal file
View File

@ -0,0 +1,7 @@
# Changelog
2021-08-12 15:06:07 +0930 [4b6cc31](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/4b6cc3176fc4acc3b7dbb954162802af9cbb4c68) - fix(pylint): install the required packages for files being checked
2021-08-12 14:49:00 +0930 [936299a](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/936299aefc6eadf9cbfec3152b352b321969cfab) - fix(pylint): fix bug introduced in code quality commit
2021-08-12 14:04:32 +0930 [73e061e](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/73e061e649e8fbeee34c6d18cf1f901b394a1f26) - build(pylint): added .pylintrc to exclude some rules
2021-08-12 03:32:36 +0000 [389bc08](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/389bc08d7686153fb374aa83d440c35c9b4eac90) - build(version): bump version 0.3.0rc1 → 0.3.0
2021-08-11 15:51:45 +0930 [d610562](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/d61056243804728e059b99fce1644a8cc37230bb) - feat(python_linting): added ci job, python linting, code quality and scoring

90
python/README.md Normal file
View File

@ -0,0 +1,90 @@
# Python
This folder (`python`) covers jobs for python development
These jobs provides the following badge:
- `PyLint` - code quality [![PyLint Score](https://img.shields.io/badge/dynamic/json?&style=plastic&logo=python&label=PyLint%20Score&query=%24.PyLintScore&url=https%3A%2F%2Fgitlab.com%2Fnofusscomputing%2Fprojects%2Fgitlab-ci%2F-%2Fjobs%2Fartifacts%2Fdevelopment%2Fraw%2Fartifacts%2Fvalidation%2FPyLint%2Fbadge_pylint.json%3Fjob%3DPyLint)](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/jobs/artifacts/development/file/artifacts/validation/tests/gl-code-quality-report.html?job=PyLint)
Use the following MD to add a badge adjusting the variables and ensuring everything is on one line.
``` md
[![PyLint Score](https://img.shields.io/badge/dynamic/json?&style=plastic&logo=python&label=PyLint%20Score&query=%24.PyLintScore&url=https%3A%2F%2Fgitlab.com%2F
{project path}
%2F-%2Fjobs%2Fartifacts%2F
{branch}
%2Fraw%2Fartifacts%2Fvalidation%2FPyLint%2Fbadge_pylint.json%3Fjob%3D
{Job Name}
)](https://gitlab.com/
{project path}
/-/jobs/artifacts/
{branch}
/file/
artifacts/validation/tests/gl-code-quality-report.html
?job=
{Job Name}
)
```
| Variable | Description |
|:----|:----|
| `{project path}` | *project path, what's after gitlab.com/* |
| `{branch}` | *git branch to fetch the score from* |
| `{Job Name}` | *name of the gitlab-ci job for the linting* |
## Dependencies
- None
## your .gitlab-ci.yml changes
To add the `PyLint` job, add the following to your `.gitlab-ci.yml` file
``` yaml
stages:
- validation
include:
- remote: https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/raw/master/python/.gitlab-ci.yml
PyLint:
variables:
PYLINT_PATH: "/*/*.py"
PYLINT_RC_PATH: "."
extends:
- .PyLint
image: python:3.6-slim
```
## CI/CD Variables required
| var name | Description |
|:----:|:----|
| PYLINT_PATH | *The path you wish the linter to search for python files* |
| PYLINT_RC_PATH | *The path to your `.pylintrc` file.* |
## Job Workflow
- This job will lint any yaml file in the specified directory using the specified rules.
## Artifacts
- `$CI_PROJECT_DIR/artifacts` - Root artifact directory
- `$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/gl-code-quality-report.json` - Gitlab code quality report (displays in merge request)
- `$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/gl-code-quality-report.html` - html code quality report
## License
To view the license for this folder and any sub-folders, refer [here](https://gitlab.com/nofusscomputing/projects/gitlab-ci)

4
python/requirements.txt Normal file
View File

@ -0,0 +1,4 @@
pylint==2.9.6
pylint-gitlab==0.3.0
gitpython==3.1.18
commitizen==2.17.13

44
yaml_lint/.gitlab-ci.yml Normal file
View File

@ -0,0 +1,44 @@
.yaml_lint_defaults:
variables:
YAML_LINT_PATH: "/*.yml"
YAML_LINT_CONFIG: "/yaml_lint/.yamllint.yaml"
stage: validation
before_script:
- if [ "0$JOB_ROOT_DIR" == "0" ]; then ROOT_DIR=gitlab-ci; else ROOT_DIR=$JOB_ROOT_DIR ; fi
- echo "[DEBUG] ROOT_DIR[$ROOT_DIR]"
- mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME"
- mkdir -p "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests"
- export PYTHON_VERSION=`python -c 'import sys; version=sys.version_info[:3]; print("{0}.{1}.{2}".format(*version))'`
- apt update
- apt install --no-install-recommends -y git
- python3 -m venv env
- . env/bin/activate
- pip install --upgrade pip
- pip install -r $ROOT_DIR/yaml_lint/requirements.txt
- mkdir $PYTHON_VERSION
script:
- YAML_LINT_PATH=$ROOT_DIR$YAML_LINT_PATH
- echo "[DEBUG] YAML_LINT_PATH[$YAML_LINT_PATH]"
- YAML_LINT_CONFIG=$ROOT_DIR$YAML_LINT_CONFIG
- echo "[DEBUG] YAML_LINT_CONFIG[$YAML_LINT_CONFIG]"
- yamllint $YAML_LINT_PATH -f parsable -c $ROOT_DIR/yaml_lint/.yamllint.yaml > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/$PYTHON_VERSION-yaml-lint.log" 1>&1 || YAML_LINT=$?
- cat "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/$PYTHON_VERSION-yaml-lint.log" | ansible-lint-to-junit-xml > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$PYTHON_VERSION-yaml-lint.junit.xml"
- if [ $YAML_LINT > 0 ]; then echo "YAML lint failed with $YAML_LINT"; exit $YAML_LINT; fi
after_script:
- echo deactivate
artifacts:
expire_in: 3 days
when: always
paths:
- "artifacts/*"
reports:
junit:
- "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/*.junit.xml"
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: never
- if: '$CI_COMMIT_BRANCH'
when: always
- when: never

26
yaml_lint/.yamllint.yaml Normal file
View File

@ -0,0 +1,26 @@
---
extends: default
rules:
braces: {max-spaces-inside: 1, level: error}
brackets: {max-spaces-inside: 1, level: error}
colons: {max-spaces-after: -1, level: error}
commas: {max-spaces-after: -1, level: error}
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
max: 2
max-start: 1
max-end: 1
level: error
hyphens: {level: error}
# indentation: disable
indentation:
spaces: consistent
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: disable
new-lines: {type: unix}
trailing-spaces: disable
truthy: disable

4
yaml_lint/CHANGELOG.md Normal file
View File

@ -0,0 +1,4 @@
# Changelog
2021-08-12 03:32:36 +0000 [389bc08](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/389bc08d7686153fb374aa83d440c35c9b4eac90) - build(version): bump version 0.3.0rc1 → 0.3.0
2021-08-11 13:41:42 +0930 [d20a56f](https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/commit/d20a56fa0ca492e3fc2ad7c548fc891cc8ffc8ec) - feat(yaml_lint): Added job yaml lint for checking yaml files

52
yaml_lint/README.md Normal file
View File

@ -0,0 +1,52 @@
# Yaml Lint
This job does yaml linting when any commit is pushed to any branch.
This job provides the following badge:
- None
## Dependencies
- None
## your .gitlab-ci.yml changes
To use this job add the following to your `.gitlab-ci.yml` file
``` yaml
stages:
- validation
include:
- remote: https://gitlab.com/nofusscomputing/projects/gitlab-ci/-/raw/master/yaml_lint/.gitlab-ci.yml
Yaml Lint (python 3.6):
variables:
YAML_LINT_PATH: "roles/"
YAML_LINT_CONFIG: ".yamllint.yaml"
extends:
- .yaml_linter_defaults
image: python:3.6-slim
```
> You can use any python version you wish.
## CI/CD Variables required
| var name | Description |
|:----:|:----|
| YAML_LINT_PATH | *The path you wish the linter to search for yaml files* |
| YAML_LINT_CONFOG | *The path you have stored the yaml config file in* |
## Job Workflow
- This job will lint any yaml file in the specified directory using the specified rules.
## Artifacts
- `$CI_PROJECT_DIR/artifacts` - Root artifact directory
- `$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$PYTHON_VERSION-yaml-lint.junit.xml` - JUnit Test report
- `$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/$PYTHON_VERSION-yaml-lint.log` - Linter log
## License
To view the license for this folder and any sub-folders, refer [here](https://gitlab.com/nofusscomputing/projects/gitlab-ci)

View File

@ -0,0 +1,2 @@
yamllint
ansible-lint-to-junit-xml