cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

Add `pre-commit` workflow with 3 Git hooks

Open jbampton opened this issue 2 years ago • 5 comments

Use pre-commit to autofix the mixed line endings

"Git hook scripts are useful for identifying simple issues before submission to code review. We run our hooks on every commit to automatically point out issues in code such as missing semicolons, trailing whitespace, and debug statements. By pointing these issues out before code review, this allows a code reviewer to focus on the architecture of a change while not wasting time with trivial style nitpicks."

https://pre-commit.com/

Description

This PR adds pre-commit as a GitHub Action. There are many Git hooks you can add but I just added 3 for easy review and I can expand on this framework in other PRs going forwards.

Apache Airflow has an amazing pre-commit framework almost seen as best practice.

https://github.com/apache/airflow/blob/main/.pre-commit-config.yaml

Types of changes

  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [X] New feature (non-breaking change which adds functionality)
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] Enhancement (improves an existing feature and functionality)
  • [ ] Cleanup (Code refactoring and cleanup, that may add test cases)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • [ ] Major
  • [X] Minor

Bug Severity

  • [ ] BLOCKER
  • [ ] Critical
  • [ ] Major
  • [ ] Minor
  • [X] Trivial

Screenshots (if appropriate):

How Has This Been Tested?

jbampton avatar Apr 16 '22 13:04 jbampton

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar Jul 01 '22 13:07 github-actions[bot]

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar Jul 07 '22 07:07 github-actions[bot]

@jbampton there seem to be a lot of irrelevant changes in this PR. Maybe line \n vs. \r? Are all of these necessary?

DaanHoogland avatar Jul 07 '22 08:07 DaanHoogland

Changing milestone to 4.18.0 as this targeted for main

shwstppr avatar Jul 29 '22 06:07 shwstppr

Hey @DaanHoogland best practice is to use only one type of line ending in a project.

From the prettier site:

"When people collaborate on a project from different operating systems, it becomes easy to end up with mixed line endings in a shared git repository. It is also possible for Windows users to accidentally change line endings in a previously committed file from LF to CRLF. Doing so produces a large git diff and thus makes the line-by-line history for a file (git blame) harder to explore."

https://prettier.io/docs/en/options.html#end-of-line

jbampton avatar Aug 04 '22 22:08 jbampton

@blueorangutan package

DaanHoogland avatar Nov 10 '22 13:11 DaanHoogland

@DaanHoogland a Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Nov 10 '22 13:11 blueorangutan

Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. LL-JID 246

blueorangutan avatar Nov 10 '22 14:11 blueorangutan

@blueorangutan test

DaanHoogland avatar Nov 13 '22 09:11 DaanHoogland

@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

blueorangutan avatar Nov 13 '22 10:11 blueorangutan

Trillian Build Failed (tid-69)

blueorangutan avatar Nov 13 '22 10:11 blueorangutan

Trillian test result (tid-74) Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7 Total time taken: 43466 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6273-t74-kvm-centos7.zip Smoke tests completed. 101 look OK, 3 have errors, 0 did not run Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_08_upgrade_kubernetes_ha_cluster Failure 476.64 test_kubernetes_clusters.py
test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL Failure 575.26 test_vpc_redundant.py
test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers Failure 404.86 test_vpc_redundant.py
test_01_redundant_vpc_site2site_vpn Failure 754.90 test_vpc_vpn.py
test_01_vpc_site2site_vpn_multiple_options Error 1293.34 test_vpc_vpn.py
test_01_vpc_site2site_vpn Error 598.71 test_vpc_vpn.py

blueorangutan avatar Nov 13 '22 23:11 blueorangutan

@blueorangutan package

DaanHoogland avatar Dec 13 '22 09:12 DaanHoogland

@DaanHoogland a Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Dec 13 '22 09:12 blueorangutan

Packaging result: :heavy_multiplication_x: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_multiplication_x: suse15. SL-JID 4907

blueorangutan avatar Dec 13 '22 18:12 blueorangutan

Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 4994

blueorangutan avatar Dec 16 '22 12:12 blueorangutan

@blueorangutan test matrix

DaanHoogland avatar Dec 19 '22 09:12 DaanHoogland

@DaanHoogland a Trillian-Jenkins matrix job (centos7 mgmt + xs71, centos7 mgmt + vmware65, centos7 mgmt + kvmcentos7) has been kicked to run smoke tests

blueorangutan avatar Dec 19 '22 09:12 blueorangutan

Trillian test result (tid-5550) Environment: xenserver-71 (x2), Advanced Networking with Mgmt server 7 Total time taken: 40785 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6273-t5550-xenserver-71.zip Smoke tests completed. 104 look OK, 1 have errors, 0 did not run Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_08_upgrade_kubernetes_ha_cluster Failure 567.96 test_kubernetes_clusters.py

blueorangutan avatar Dec 19 '22 20:12 blueorangutan

Trillian test result (tid-5551) Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7 Total time taken: 42131 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6273-t5551-kvm-centos7.zip Smoke tests completed. 104 look OK, 1 have errors, 0 did not run Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_08_upgrade_kubernetes_ha_cluster Failure 561.37 test_kubernetes_clusters.py

blueorangutan avatar Dec 19 '22 21:12 blueorangutan

Trillian test result (tid-5552) Environment: vmware-65u2 (x2), Advanced Networking with Mgmt server 7 Total time taken: 48695 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6273-t5552-vmware-65u2.zip Smoke tests completed. 102 look OK, 3 have errors, 0 did not run Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_attach_and_distribute_multiple_volumes Failure 52.66 test_attach_multiple_volumes.py
test_02_create_template_with_checksum_sha1 Error 5.16 test_templates.py
test_03_create_template_with_checksum_sha256 Error 5.24 test_templates.py
test_04_create_template_with_checksum_md5 Error 5.17 test_templates.py
test_08_upgrade_kubernetes_ha_cluster Failure 655.49 test_kubernetes_clusters.py

blueorangutan avatar Dec 19 '22 23:12 blueorangutan

Codecov Report

Merging #6273 (350ec92) into main (a3289f8) will not change coverage. The diff coverage is 0.00%.

@@            Coverage Diff            @@
##               main    #6273   +/-   ##
=========================================
  Coverage     11.59%   11.59%           
  Complexity     7560     7560           
=========================================
  Files          2494     2494           
  Lines        247109   247109           
  Branches      38619    38619           
=========================================
  Hits          28646    28646           
  Misses       214719   214719           
  Partials       3744     3744           
Impacted Files Coverage Δ
.../cloud/baremetal/database/BaremetalRctDaoImpl.java 0.00% <0.00%> (ø)
...a/com/cloud/baremetal/database/BaremetalRctVO.java 0.00% <0.00%> (ø)
...java/com/cloud/baremetal/manager/BaremetalRct.java 0.00% <0.00%> (ø)
...ud/baremetal/manager/BaremetalVlanManagerImpl.java 0.00% <0.00%> (ø)
...baremetal/networkservice/BaremetalRctResponse.java 0.00% <0.00%> (ø)
...networkservice/BaremetalVirtualRouterCommands.java 0.00% <0.00%> (ø)
.../baremetal/networkservice/BaremetalVlanStruct.java 0.00% <0.00%> (ø)
.../networkservice/Force10BaremetalSwitchBackend.java 0.00% <0.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov[bot] avatar Dec 20 '22 10:12 codecov[bot]

@blueorangutan test centos7 vmware-67u3

DaanHoogland avatar Dec 20 '22 13:12 DaanHoogland

@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + vmware-67u3) has been kicked to run smoke tests

blueorangutan avatar Dec 20 '22 13:12 blueorangutan

Trillian test result (tid-5591) Environment: vmware-67u3 (x2), Advanced Networking with Mgmt server 7 Total time taken: 43323 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6273-t5591-vmware-67u3.zip Smoke tests completed. 104 look OK, 1 have errors, 0 did not run Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_02_create_template_with_checksum_sha1 Error 5.14 test_templates.py
test_03_create_template_with_checksum_sha256 Error 5.13 test_templates.py
test_04_create_template_with_checksum_md5 Error 5.15 test_templates.py

blueorangutan avatar Dec 21 '22 02:12 blueorangutan

Trillian test result (tid-5591) Environment: vmware-67u3 (x2), Advanced Networking with Mgmt server 7 Total time taken: 43323 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr6273-t5591-vmware-67u3.zip Smoke tests completed. 104 look OK, 1 have errors, 0 did not run Only failed and skipped tests results shown below: Test Result Time (s) Test File test_02_create_template_with_checksum_sha1 Error 5.14 test_templates.py test_03_create_template_with_checksum_sha256 Error 5.13 test_templates.py test_04_create_template_with_checksum_md5 Error 5.15 test_templates.py

errors addressed in #7001

DaanHoogland avatar Dec 21 '22 08:12 DaanHoogland

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar Jan 03 '23 14:01 github-actions[bot]

@blueorangutan package

DaanHoogland avatar Jan 09 '23 14:01 DaanHoogland

@DaanHoogland a Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Jan 09 '23 14:01 blueorangutan

Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: el9 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 5209

blueorangutan avatar Jan 09 '23 15:01 blueorangutan