Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Add code formatting check to Travis CI build #29

Merged
merged 4 commits into from
Apr 9, 2019
Merged

Add code formatting check to Travis CI build #29

merged 4 commits into from
Apr 9, 2019

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented Apr 9, 2019

  • Auto format code
  • Add code formatting check to Travis CI build
  • Use TravisBuddy to comment on PRs that result in a failed CI build

Check compliance with the Artistic Style code formatter configuration found in https://github.com/arduino/Arduino/blob/master/build/shared/examples_formatter.conf. A consistent style will be used for example sketches as well as library code.

This required first doing an auto format of all the code in the repository.

I excluded the ./src/lib and ./test/external folders from the auto formatting and the formatting check because these appeared to contain only external projects. I felt that it didn't make sense to enforce a formatting standard on these projects, since that would likely make it more difficult to update these files and to view changes between updates. If you do want me to enable formatting checks on any of these folders, let me know, I'm happy to update this PR accordingly.

A TravisBuddy webhook was added to the Travis CI build configuration. TravisBuddy will automatically comment on any pull request that results in a failing Travis CI build so that the author of the PR will get a notification of the issue and hopefully resolve it without the need for any action from a repository maintainer.

Example of a build failure caused by non-compliant code formatting:
https://travis-ci.org/per1234/ArduinoCloudThing/jobs/517619571

Example of TravisBuddy automated comment on a demonstration pull request that failed the code formatting check:
https://github.com/per1234/ArduinoCloudThing/pull/1
Clipboard02

Related:

per1234 added 3 commits April 8, 2019 22:08
The Artistic Style code formatter tool was used with Arduino's example_formatter.conf configuration file:
https://github.com/arduino/Arduino/blob/master/build/shared/examples_formatter.conf
Check compliance with the code style standard established by Arduino's examples_formatter.conf Artistic Style configuration file:
https://github.com/arduino/Arduino/blob/master/build/shared/examples_formatter.conf
If the code does not comply with the standard, a diff between the submitted code and the auto-formatted code is shown in the log and the Travis CI job will fail.

I configured .travis.yml so that the formatting check will be done in a dedicated job.
When the Travis CI build of a pull request fails, TravisBuddy automatically comments to the pull request thread. This will cause the pull request author to get a notification and hopefully resolve the issue without the need for any action from a repository maintainer.
@per1234 per1234 changed the title Check formatting Add code formatting check to Travis CI build Apr 9, 2019
@codecov-io
Copy link

codecov-io commented Apr 9, 2019

Codecov Report

Merging #29 into master will increase coverage by 0.05%.
The diff coverage is 96.64%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #29      +/-   ##
==========================================
+ Coverage   96.23%   96.28%   +0.05%     
==========================================
  Files           7        7              
  Lines         451      484      +33     
==========================================
+ Hits          434      466      +32     
- Misses         17       18       +1
Impacted Files Coverage Δ
src/ArduinoCloudPropertyContainer.ipp 100% <100%> (ø) ⬆️
src/ArduinoCloudProperty.hpp 100% <100%> (ø) ⬆️
src/ArduinoCloudProperty.ipp 97.43% <100%> (+0.02%) ⬆️
src/ArduinoCloudPropertyContainer.hpp 100% <100%> (ø) ⬆️
src/ArduinoCloudThing.h 100% <100%> (ø) ⬆️
src/ArduinoCloudPropertyContainer.cpp 96.55% <92.85%> (+0.55%) ⬆️
src/ArduinoCloudThing.cpp 94.5% <94.84%> (-0.19%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 601e9e2...e55641f. Read the comment docs.

All the breaks were originally aligned. On some lines, this was accomplished by adding spaces before the closing parentheses, but not all lines have one. Because the auto format removes padding inside parentheses, this resulted in the spaces being removed from the lines with the parentheses, but not on the other lines. I chose to make the most minimal fix, but the alternative could be to add spaces outside the parentheses to recover alignment of all the breaks, which is fully compliant with the formatting check.
@aentinger aentinger merged commit 36f603c into arduino-libraries:master Apr 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants