Skip to content
/ libs Public

... reusable scripts - retrieve specific versions with opsgang/fetch :)

License

Notifications You must be signed in to change notification settings

opsgang/libs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libs

... reusable scripts - retrieve specific versions with opsgang/fetch :)

Run Status

You need to have GNU coreutils installed for these scripts to work.

Mac users: We use realpath, and GNU versions of sed, awk, sort.

BSD flavours will not work, so homebrew some GNU-ey goodness if you plan to use these scripts locally.

PS: If you want to contribute, master branch of this repo requires signed commits.

USAGE

Typically we source all scripts under bash/habitual/ in our scripts

To grab these to a local dir e.g. ./lib, you can use fetch:

# retrieve latest v 1.x (but < 2.x) of files under bash/habitual
fetch --repo="https://github.com/opsgang/libs" --tag="~> 1.0" --source-path=/bash/habitual ./lib/habitual

# Now source all habitual libs in your scripts with something like:
for lib in $(find ./habitual -type f | grep -v 'README' | grep -vP '\.(awk|md|markdown|txt)$'); do
    ! . $lib && echo "ERROR $0: ... could not source $lib" && return 1
done

DOCUMENTATION

Generated from simple inline markup.

To generate it yourself:

cd bash
libs=$(find ./ -path './t' -prune -o -name '*.functions' -print)
for lib in $libs; do awk -f bashdoc-to-md.awk $lib > $lib.md ; done

BUILDS / PKGS

Shippable will react to the push of a git tag event by building, testing and on success creating a release for that tag.

Additionally, .tgz bundles are created as release attachments. Each bundle contains the assets needed to easily automate particular tasks in a consistent and predictable manner e.g for running terraform, or another bundle for building an AMI.

Bundles can be retrieved easily using opsgang/fetch.

TESTS

cd ./bash # all tests must be run from this dir.

# to run all tests for a particular script e.g. habitual/std.functions:
t/habitual/std.functions

# to run individual tests for a script e.g. for habitual/functions
t/habitual/std.functions t_can_source_multiple_files t_check_var_defined

# to run all tests for all scripts under ./habitual
t() {
    local suite="$1" rc=0
    [[ "$(basename $(realpath .))" != "bash" ]] && echo 'ERROR: run from ./bash dir' && return 1
    [[ -z "$suite" ]] && echo 'ERROR: pass suite name' >&2 && return 1

    libs=$(find $suite -path './t' -prune -o -name '*.functions' -print)
    for lib in $libs; do
        rc=0
        f="t/${lib#./}"
        [[ ! -x "$f" ]] && echo "no tests for $lib" && continue
        $f || rc=1
    done

    return $rc
}

# ... then you can run things like ...
t ./ || echo "FAILURES"       # run tests for all functions.
t habitual || echo "FAILURES" # run tests for all functions under habitual

About

... reusable scripts - retrieve specific versions with opsgang/fetch :)

Resources

License

Stars

Watchers

Forks

Packages

No packages published