Can circleCI lint files?

circle.yml

#1

I’m looking for a way to use circle ci to run lint checks against changed files. Can someone point me towards some documentation as to how to do this if it’s possible? If not, I think that it would be a good new feature.


#2

What kind of files are you working with?


#3

Here’s how I lint the numerous packages that together form my main project :

circle.yml fragment :

    : 
dependencies:
  pre:
   # Pull each of our packages and link them into our project
    - ./packages/obtain_managed_packages.sh
     : 
     : 
test:
 override:
   # Perform per package CI Tasks
   - ./packages/perform_per_package_ci_tasks.sh
    : 

The first script iterates a list of packages, git cloning them from GitHub.

The second script iterates the list again, looking for an executable file ${TARGET_PKG}/tools/perform_ci_tasks.sh. Some, but not all packages have a tools directory containing a bash script perform_ci_tasks.sh.

perform_per_package_ci_tasks.sh passes control to each perform_ci_tasks.sh that it finds.

Some of them look as simple as this :

function checkCodeStyle() {

  echo -e "\nChecking code style\n";
  # If there's no setting for CIRCLE_ARTIFACTS, then we're testing locally
  if [[ ">${CIRCLE_ARTIFACTS}<" == "><" ]]; then CIRCLE_ARTIFACTS="."; fi;
  script -qc "eslint ." ${CIRCLE_ARTIFACTS}/esLintReport.txt  > /dev/null;
  echo -e "\n     Generated esLint report :";
  cat ${CIRCLE_ARTIFACTS}/esLintReport.txt;
  echo -e "\n#################################################################\n";

}

checkCodeStyle;

The script command preserves formatting and color coding of results.

The cat is optional, but it makes it easy to spot problems as the build happens.


#4