Skip to content

Commit

Permalink
Cache ansible installs in TravisCI
Browse files Browse the repository at this point in the history
  • Loading branch information
wtanaka committed Jul 13, 2020
1 parent 0fa231b commit 65c4db4
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 6 deletions.
17 changes: 16 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,23 @@ services:
before_install:
- sudo apt-get update -qq
- sudo apt-get install -y ansible

script:
- "./_self_test.sh"
- ./_self_test.sh

stages:
- prepare cache
- test

cache:
directories:
- .bootci/venv-ansible1.5.4

jobs:
include:
- stage: prepare cache
script: env COMMAND=preparecache ./run.sh

after_failure:
- "(cd fake-role/role-tester; cat .kitchen/logs/*.log | grep -v '^I, ')"
- "(cd fake-role-no-tests/role-tester; cat .kitchen/logs/*.log | grep -v '^I, ')"
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ wget -O- bit.ly/ansibletest |
env ANSIBLE_VERBOSE="vvv" sh
```

Development
-----------

To regenerate `all-versions.txt`, run:

```
pip download ansible==thisdoesnotexist 2>&1 |
grep from.versions |
cut -d: -f2- |
cut -d\) -f1 |
sed -e 's/,* /\
/g' |
grep -v '^[ ]*$' |
tee all-versions.txt
```

License
-------

Expand All @@ -68,4 +84,4 @@ GPLv2
Author Information
------------------

http://wtanaka.com/
https://wtanaka.com/
84 changes: 84 additions & 0 deletions all-versions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
1.0
1.1
1.2
1.2.1
1.2.2
1.2.3
1.3.0
1.3.1
1.3.2
1.3.3
1.3.4
1.4
1.4.1
1.4.2
1.4.3
1.4.4
1.4.5
1.5
1.5.1
1.5.2
1.5.3
1.5.4
1.5.5
1.6
1.6.1
1.6.2
1.6.3
1.6.4
1.6.5
1.6.6
1.6.7
1.6.8
1.6.9
1.6.10
1.7
1.7.1
1.7.2
1.8
1.8.1
1.8.2
1.8.3
1.8.4
1.9.0.1
1.9.1
1.9.2
1.9.3
1.9.4
1.9.5
1.9.6
2.0.0.0
2.0.0.1
2.0.0.2
2.0.1.0
2.0.2.0
2.1.0.0
2.1.1.0
2.1.2.0
2.1.3.0
2.1.4.0
2.1.5.0
2.1.6.0
2.2.0.0
2.2.1.0
2.2.2.0
2.2.3.0
2.3.0.0
2.3.1.0
2.3.2.0
2.3.3.0
2.4.0.0
2.4.1.0
2.4.2.0
2.4.3.0
2.4.4.0
2.5.0a1
2.5.0b1
2.5.0b2
2.5.0rc1
2.5.0rc2
2.5.0rc3
2.5.0
2.5.1
2.5.2
2.5.3
36 changes: 32 additions & 4 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,19 @@ download()
sys.stdout.buffer.write(u('""$@""').read())"
}

# The github user to download the role-tester-ansible distribution
# from. Default: wtanaka
if [ -z "$GITHUBUSER" ]; then
GITHUBUSER=wtanaka
fi

# The github project name. Default: role-tester-ansible
if [ -z "$PROJECT" ]; then
PROJECT=role-tester-ansible
fi

# Which version of role-tester-ansible to use, allow overriding with
# environment variable
# Which branch/tag/release of role-tester-ansible to use, allow
# overriding with environment variable
if [ -z "$BRANCH" ]; then
BRANCH=master
fi
Expand All @@ -67,6 +70,12 @@ if [ -z "$ROLENAME" ]; then
ROLENAME="${PWD##*/}"
fi

if [ -z "$COMMAND" ]; then
COMMAND=all
fi

# Also allow overriding parameters with the command line instead of
# environment variables.
while getopts a:b:ho:r: opt; do
case "$opt" in
a)
Expand All @@ -88,14 +97,16 @@ while getopts a:b:ho:r: opt; do
esac
done

# Download the code
URL=https://github.com/"$GITHUBUSER"/"$PROJECT"/archive/"$BRANCH".tar.gz

retry download "$URL" | tar xvfz -

# Internal environment variable name for ROLENAME
ROLE_UNDER_TEST="$ROLENAME"
export ROLE_UNDER_TEST

# Inlined from _functions.sh
# Inlined from _functions.sh because we're bootstrapping
ROLE_DIR="."
ROLE_TESTER_DIR="$PROJECT"-"$BRANCH"
if [ -d "$ROLE_DIR"/test/integration/default/serverspec ]; then
Expand All @@ -108,4 +119,21 @@ if [ -d "$ROLE_DIR"/test/integration/default/serverspec ]; then
done
fi

make -s -C "$PROJECT"-"$BRANCH"
case "$COMMAND" in
preparecache)
# Not sure if this is ruby-version-independent
# "$ROLE_TESTER_DIR/.bootci/make-vendor-bundle.sh"
if [ -z "$ANSIBLE_VERSIONS" ]; then
cat "$ROLE_TESTER_DIR"/all-versions.txt | while read VERSION; do
"$ROLE_TESTER_DIR"/.bootci/make-ansible.sh "$VERSION"
done
else
for VERSION in $ANSIBLE_VERSIONS; do
"$ROLE_TESTER_DIR"/.bootci/make-ansible.sh "$VERSION"
done
fi
;;
all)
make -s -C "$PROJECT"-"$BRANCH"
;;
esac

0 comments on commit 65c4db4

Please sign in to comment.