Sign inSign up

nexucis/ci-checkfiles

By nexucis

•Updated over 7 years ago

Check encoding and the end-of-line of the file of your project with your continuous integration

Image
0

4.8K

nexucis/ci-checkfiles repository overview

⁠Overview

This project provides two docker images (ubuntu and alpine) with two scripts to check the encoding file and the end-of-line of the file in a project.

These images can be used in a continuous integration system like circle-ci, gitlab-ci or travis-ci.

The code is hosted on github⁠

⁠Getting Started

⁠Check encoding

The tool who does the job (named checkEncoding), tooks as a first parameter the encoding target to check. As the tool uses uchardet⁠, we can have all supported encoding by uchardet.

As the second parameter, the tool takes all files that you want to check. It can take a regex too.

For example, you want to check if the files of your current project (let's say a Java project build with maven) is encoding in utf-8, you could use the tool like this:

docker run --rm -v ${PWD}:/var/workspace/project nexucis/ci-checkfiles /bin/bash -c "cd /var/workspace/project && checkEncoding utf-8 *.md *.java *.xml"
⁠Check end-of-line

For the moment, the tool (named checkEOL) checks only if the files have an UNIX end-of-line.

The tool takes only one thing : the kind of document that you want to check.

If we use the same example used in the "Check encoding" section, we could use the tool like this:

docker run --rm -v ${PWD}:/var/workspace/project nexucis/ci-checkfiles /bin/bash -c "cd /var/workspace/project && checkEOL *.md *.java *.xml"

⁠Do the same in continuous integration

This image is designed to work in a continuous integration system. So you could use it to check your project in a easy way.

⁠Circle-CI

The example below shows a simple circle-ci configuration files .circleci/config.yml who shows how to use the two tools describe in a previous section

version: 2
jobs:
  analyze_eol:
    docker:
      - image: nexucis/ci-checkfiles
    working_directory: ~/repo
    steps:
      - checkout
      - run: checkEOL *.cmd *.php *.md *.xml
      
  analyze_encoding_utf8:
    docker:
      - image: nexucis/ci-checkfiles
    working_directory: ~/repo
    steps:
      - checkout
      - run: checkEncoding utf-8 *.cmd *.php *.md *.xml
      
workflows:
  version: 2
  build_and_analyze:
    jobs:
      - analyze_eol
      - analyze_encoding_utf8

If you want to learn more about circle-ci please read the official documentation⁠

⁠Gitlab-ci

Same example but with Gitlab-ci .

stages:
  - analyze

analyze_eol:
  stage: analyze
  image: nexucis/ci-checkfiles
  script:
    - checkEOL *.md *.java *.xml *.json *.ts *.js

analyze_encoding_utf8:
  stage: analyze
  image: nexucis/ci-checkfiles
  script:
    - checkEncoding utf-8 *.md *.java *.xml *.json *.ts *.js
⁠Travis-CI

If you want to use it with tracis, you can do something like this :

sudo: required

language: java

services:
  - docker

script:
  - docker run --rm -v ${PWD}:/var/workspace/project nexucis/ci-checkfiles /bin/bash -c "cd /var/workspace/project && checkEOL *.md *.java *.xml"
  - docker run --rm -v ${PWD}:/var/workspace/project nexucis/ci-checkfiles /bin/bash -c "cd /var/workspace/project && checkEncoding utf-8 *.md *.java *.xml"

The example above is based on the official documentation⁠ when we want to use docker with travis-ci

Tag summary

Content type

Image

Digest

Size

69 MB

Last updated

over 8 years ago

docker pull nexucis/ci-checkfiles