├── tests ├── bash.sh ├── ksh.sh ├── sh.sh ├── zsh.sh ├── ruby.rb ├── python.py ├── test-custom-no-extension └── test-custom-check.sh ├── travis.yml.example ├── .travis.yml ├── install.sh ├── LICENSE └── README.md /tests/bash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "hi" 3 | -------------------------------------------------------------------------------- /tests/ksh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/ksh 2 | echo "hi" 3 | -------------------------------------------------------------------------------- /tests/sh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "hi" 3 | -------------------------------------------------------------------------------- /tests/zsh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | echo "hi" 3 | -------------------------------------------------------------------------------- /tests/ruby.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | puts "test" 3 | -------------------------------------------------------------------------------- /tests/python.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | print("test") 3 | -------------------------------------------------------------------------------- /tests/test-custom-no-extension: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "hi" 3 | -------------------------------------------------------------------------------- /travis.yml.example: -------------------------------------------------------------------------------- 1 | language: bash 2 | sudo: required 3 | os: 4 | - linux 5 | - osx 6 | install: 7 | - ./build/install.sh 8 | script: 9 | - ./build/build.sh 10 | notifications: 11 | email: false 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: bash 2 | install: 3 | - ./install.sh 4 | script: 5 | - ./build.sh 6 | - ./tests/test-custom-check.sh 7 | notifications: 8 | email: false 9 | sudo: required 10 | os: 11 | - linux 12 | - osx 13 | -------------------------------------------------------------------------------- /tests/test-custom-check.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Grant that custom checks are working. 3 | set -eo pipefail 4 | 5 | # shellcheck disable=SC1091 6 | source ./build.sh 7 | 8 | # Lint the build script 9 | echo "Linting the build.sh script..." 10 | check ./build.sh 11 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eo pipefail 3 | 4 | linux() { 5 | sudo curl -Lso \ 6 | /usr/bin/shellcheck \ 7 | https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.6/shellcheck 8 | sudo chmod +x /usr/bin/shellcheck 9 | } 10 | 11 | osx() { 12 | brew update >/dev/null 13 | brew install shellcheck 14 | } 15 | 16 | if [ "$(uname -s)" = "Darwin" ]; then 17 | osx 18 | else 19 | linux 20 | fi 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2016 Carlos Alexandro Becker 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | shell-ci-build [![Build Status](https://travis-ci.org/caarlos0/shell-ci-build.svg?branch=master)](https://travis-ci.org/caarlos0/shell-ci-build) [![SayThanks.io](https://img.shields.io/badge/SayThanks.io-%E2%98%BC-1EAEDB.svg?style=flat-square)](https://saythanks.io/to/caarlos0) 2 | ================== 3 | 4 | A submodule to lint your shell projects with shellcheck in travis.ci builds. 5 | 6 | ## Build 7 | 8 | - The `install.sh` script will install shellckeck. 9 | - The `build.sh` will lint all executable files with shellcheck, avoiding 10 | Ruby, compdef and the like files. It will also ignore all files inside `.git` 11 | directory and files of your `gitmodules`, if any. 12 | 13 | ## Usage 14 | 15 | ```sh 16 | git submodule add https://github.com/caarlos0/shell-ci-build.git build 17 | cp build/travis.yml.example .travis.yml 18 | ``` 19 | 20 | Or tweak your `.travis.yml` to be like this: 21 | 22 | ```yml 23 | language: bash 24 | install: 25 | - ./build/install.sh 26 | script: 27 | - ./build/build.sh 28 | ``` 29 | 30 | ## Customizing 31 | 32 | You might want to lint other files, to do that, you need your own 33 | `build.sh` and a slight change in `.travis.yml` file. 34 | 35 | Example (from my [dotfiles](https://github.com/caarlos0/dotfiles)): 36 | 37 | ```sh 38 | #!/usr/bin/env bash 39 | set -eo pipefail 40 | source ./build/build.sh 41 | check "./zsh/zshrc.symlink" 42 | ``` 43 | 44 | ```yml 45 | language: bash 46 | install: 47 | - ./build/install.sh 48 | script: 49 | - ./build.sh 50 | notifications: 51 | email: false 52 | ``` 53 | 54 | This will make travis ran the `build.sh` from this project first, 55 | then, lint your custom files. 56 | 57 | You can also override the `find_cmd` function, which returns a string 58 | containing the `find` command to `eval`. Check the source or open an 59 | issue if you have any problems. 60 | 61 | ## Updating 62 | 63 | Update your projects is easy. Just run this: 64 | 65 | ```sh 66 | git submodule update --remote --merge && \ 67 | git commit -am 'updated shell-ci-build version' && \ 68 | git push 69 | ``` 70 | --------------------------------------------------------------------------------