diff --git a/.travis.yml b/.travis.yml index da42d779e..85469a186 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,17 @@ language: generic sudo: required env: - DOCKER_COMPOSE_VERSION: 1.16.1 + global: + - DOCKER_CACHE_DIR=$HOME/docker + - DOCKER_COMPOSE_VERSION=1.26.2 + - ANSIBLE_VERSION=2.9.9 + jobs: + - PLATFORM=centos PLAYBOOK=user.yml + - PLATFORM=debian PLAYBOOK=user.yml + - PLATFORM=ubuntu PLAYBOOK=user.yml + - PLATFORM=centos PLAYBOOK=root.yml + - PLATFORM=debian PLAYBOOK=root.yml + - PLATFORM=ubuntu PLAYBOOK=root.yml services: - docker @@ -12,29 +22,34 @@ services: cache: pip: true directories: - - $HOME/docker + - $DOCKER_CACHE_DIR before_install: - - if [[ -d $HOME/docker ]]; then ls $HOME/docker/*.tar.gz | xargs -I {file} sh -c "zcat {file} | docker load"; fi + - set -e # Let's fail fast (as Travis CI doesn't by default, see travis-ci/travis-ci#1066) + - if [[ -d $DOCKER_CACHE_DIR ]]; then ls $DOCKER_CACHE_DIR/tests_$PLATFORM*.tar.gz | xargs -I {file} sh -c "zcat {file} | docker load"; fi - sudo rm /usr/local/bin/docker-compose - curl -L https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-`uname -s`-`uname -m` > docker-compose - chmod +x docker-compose - sudo mv docker-compose /usr/local/bin install: - - sudo pip install ansible==2.4.6.0 > /dev/null 2>&1 + - sudo pip install ansible==$ANSIBLE_VERSION > /dev/null 2>&1 script: - cd tests - - docker-compose up -d - - ansible-playbook user.yml -l centos - - ansible-playbook user.yml -l debian - - ansible-playbook user.yml -l ubuntu + - docker-compose config --services | grep $PLATFORM | xargs docker-compose up -d + - ansible-playbook $PLAYBOOK -l $PLATFORM before_cache: + # Put docker images used during this run into travis cache (if not already cached). + # Tarballs are named after the pattern -.tar.gz, + # to allow "filtering" by platform type (e.g. only import debian images from cache). - > - mkdir -p $HOME/docker && docker images -a --filter='dangling=false' --format '{{.Repository}}:{{.Tag}} {{.ID}}' - | xargs -n 2 -t sh -c 'test -e $HOME/docker/$1.tar.gz || docker save $0 | gzip -2 > $HOME/docker/$1.tar.gz' + mkdir -p $DOCKER_CACHE_DIR && docker images -a --filter='dangling=false' --format '{{.Repository}} {{.ID}}' "tests_$PLATFORM*" + | xargs -n 2 -t sh -c 'test -e $DOCKER_CACHE_DIR/$0-$1.tar.gz || docker save $0 | gzip -2 > $DOCKER_CACHE_DIR/$0-$1.tar.gz' + # Show cache usage details (useful to know if a cache cleanup is needed) + - du -hs $DOCKER_CACHE_DIR/* + - du -hs $DOCKER_CACHE_DIR notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 79c46f33d..5fa5fa88f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,15 +2,31 @@ ### NEXT -* Fixes bare variables in conditionals (deprecation warnings with Ansible 2.8+) (#204) +#### New features + +* Report when Ruby is removed and don't ignore when version listing fails (#212) + +#### Bug fixes + +* Fix bare variables in conditionals (deprecation warnings with Ansible 2.8+) (#204) * Fix boolean values when checking array (#207) -* Fixes regression forbidding installation of rubies (#209, fixed via #207) +* Fix regression forbidding installation of rubies (#209, fixed via #207) * Fix conditional logic for detecting and removing versions of Ruby (#212) -* Report when Ruby is removed and don't ignore when version listing fails (#212) + +#### Changes + +* Extend test matrix with: (#215) + * CentOS 8, Debian 10, Ubuntu 18.04 and 20.04 + * Ruby 2.6.6 and 2.7.1 +* Modify some test assertions to better abstract RVM behaviour from its internal implementation ("blackbox" testing) (#205) +* Fix and enhance Travis CI setup (#205) + * Install more recent versions of Ruby, to be compatible with latest Bundler version + * Validate system-wide setup (root.yml) + * Parallelize the tests to speed up the builds ### 2.1.2 2018-12-28 · [Changes](https://github.com/rvm/rvm1-ansible/compare/v2.1.1...v2.1.2) -) + * Fallback to alternative GPG key servers (#192) * Remove keys.gnupg.net in favour of pool.sks-keyservers.net (#192) diff --git a/README.md b/README.md index f1ba42c58..6b62c6bb3 100644 --- a/README.md +++ b/README.md @@ -163,9 +163,14 @@ Just add `--extra-vars 'rvm1_delete_ruby=ruby-2.1.0'` to the end of your play bo ## Requirements -- Tested on CentOS 6 and 7 -- Tested on Debian 8 and 9 -- Tested on Ubuntu 14.04 and 16.04 +Potentially, any Linux/Unix system supported by Ansible and satisfying the [RVM prerequisites](https://rvm.io/rvm/prerequisites) should work. + +Compatibility with Linux distributions based on Debian, Ubuntu or Redhat families is actively tested. + +The continuous integration setup of this project currently covers following platforms: +- CentOS 6, 7 and 8 +- Debian 8, 9 and 10 +- Ubuntu 14.04, 16.04, 18.04 and 20.04 ## Ansible galaxy diff --git a/tests/assertions.yml b/tests/assertions.yml index 8a21c7796..0f13a26f8 100644 --- a/tests/assertions.yml +++ b/tests/assertions.yml @@ -1,37 +1,54 @@ --- -- name: Check that ruby exists - shell: . $HOME/.bash_profile && ruby -v | cut -c1-4 - args: - executable: /bin/bash - register: check_ruby +- name: Check default ruby version + shell: + cmd: bash -lc 'ruby -v | cut -c1-10' + register: check_ruby_default changed_when: false - assert: that: - - check_ruby.stdout == 'ruby' - - check_ruby.rc == 0 - msg: No ruby installed + - check_ruby_default.stdout == 'ruby {{ rvm_tests_mri_version_default }}' + - check_ruby_default.rc == 0 + msg: Default ruby version is wrong -- name: Check default ruby - shell: ~/.rvm/wrappers/default/ruby -v | cut -c1-10 - register: check_ruby_default +- name: Check that rvm is in use + shell: + cmd: bash -lc 'which ruby' + register: check_rvm_loaded changed_when: false - assert: that: - - check_ruby_default.stdout == 'ruby 2.3.1' - msg: No default ruby installed + - check_rvm_loaded.stdout == '{{ rvm1_install_path }}/rubies/ruby-{{ rvm_tests_mri_version_default }}/bin/ruby' + - check_rvm_loaded.rc == 0 + msg: Default ruby is in the wrong path - name: Check multiple rubies - command: ls ~/.rvm/rubies + command: + cmd: bash -lc 'rvm list strings' register: check_ruby_multiple changed_when: false - assert: that: - - "'ruby-2.2.5' in check_ruby_multiple.stdout" - - "'ruby-2.3.1' in check_ruby_multiple.stdout" + - "'ruby-{{ rvm_tests_mri_version_other }}' in check_ruby_multiple.stdout" + - "'ruby-{{ rvm_tests_mri_version_default }}' in check_ruby_multiple.stdout" + - check_ruby_multiple.rc == 0 msg: No multiple rubies installed +- name: Check ruby switch + command: + cmd: bash -lc 'rvm use {{ rvm_tests_mri_version_other }} && ruby -v | cut -c1-10' + register: check_ruby_switch + changed_when: false +- assert: + that: + - "'Using {{ rvm1_install_path }}/gems/ruby-{{ rvm_tests_mri_version_other }}' in check_ruby_switch.stdout" + - "'ruby {{ rvm_tests_mri_version_other }}' in check_ruby_switch.stdout" + - check_ruby_switch.rc == 0 + msg: Failed to switch the ruby version + - name: Check bundler symlinked on system path - shell: ls ~/.rvm/wrappers/default/ |grep 'bundler' + shell: + cmd: ls wrappers/default/ | grep 'bundler' + chdir: "{{ rvm1_install_path }}" register: check_ruby_bundler changed_when: false - assert: diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index 3f71c4f13..2e27ed732 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -1,26 +1,35 @@ version: "3" services: + centos6: build: ./dockerfiles/centos6 - cap_add: - - ALL + cap_add: [ALL] centos7: build: ./dockerfiles/centos7 - cap_add: - - ALL + cap_add: [ALL] + centos8: + build: ./dockerfiles/centos8 + cap_add: [ALL] + debian8: build: ./dockerfiles/debian8 - cap_add: - - ALL + cap_add: [ALL] debian9: build: ./dockerfiles/debian9 - cap_add: - - ALL + cap_add: [ALL] + debian10: + build: ./dockerfiles/debian10 + cap_add: [ALL] + ubuntu14: build: ./dockerfiles/ubuntu14 - cap_add: - - ALL + cap_add: [ALL] ubuntu16: build: ./dockerfiles/ubuntu16 - cap_add: - - ALL + cap_add: [ALL] + ubuntu18: + build: ./dockerfiles/ubuntu18 + cap_add: [ALL] + ubuntu20: + build: ./dockerfiles/ubuntu20 + cap_add: [ALL] diff --git a/tests/dockerfiles/centos8/Dockerfile b/tests/dockerfiles/centos8/Dockerfile new file mode 100644 index 000000000..1ad2d8681 --- /dev/null +++ b/tests/dockerfiles/centos8/Dockerfile @@ -0,0 +1,12 @@ +FROM centos:8 + +RUN yum update -y \ + && yum install -y \ + sudo \ + which \ + && yum clean all + +RUN useradd -ms /bin/bash user && \ + echo 'user ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers + +CMD ["/usr/sbin/init"] diff --git a/tests/dockerfiles/debian10/Dockerfile b/tests/dockerfiles/debian10/Dockerfile new file mode 100644 index 000000000..a89ca4040 --- /dev/null +++ b/tests/dockerfiles/debian10/Dockerfile @@ -0,0 +1,17 @@ +FROM debian:10 + +RUN apt-get update \ + && apt-get install -y \ + curl \ + gpg \ + procps \ + python \ + sudo \ + systemd \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN useradd -ms /bin/bash user && \ + echo 'user ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers + +CMD ["/lib/systemd/systemd"] diff --git a/tests/dockerfiles/ubuntu18/Dockerfile b/tests/dockerfiles/ubuntu18/Dockerfile new file mode 100644 index 000000000..7a94eb2f3 --- /dev/null +++ b/tests/dockerfiles/ubuntu18/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:18.04 + +RUN apt-get update \ + && apt-get install -y \ + curl \ + gpg \ + python \ + sudo \ + systemd \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN useradd -ms /bin/bash user && \ + echo 'user ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers + +CMD ["/lib/systemd/systemd"] diff --git a/tests/dockerfiles/ubuntu20/Dockerfile b/tests/dockerfiles/ubuntu20/Dockerfile new file mode 100644 index 000000000..318a3d530 --- /dev/null +++ b/tests/dockerfiles/ubuntu20/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:20.04 + +RUN apt-get update \ + && apt-get install -y \ + curl \ + gpg \ + python \ + sudo \ + systemd \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN useradd -ms /bin/bash user && \ + echo 'user ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers + +CMD ["/lib/systemd/systemd"] diff --git a/tests/group_vars/all b/tests/group_vars/all new file mode 100644 index 000000000..07150f6b4 --- /dev/null +++ b/tests/group_vars/all @@ -0,0 +1,7 @@ +--- +rvm_tests_mri_version_default: 2.7.1 +rvm_tests_mri_version_other: 2.6.6 + +# Upcoming +# rvm_tests_jruby_version_x: 9.2.12.0 +# ... \ No newline at end of file diff --git a/tests/inventory b/tests/inventory index 02faca241..8467d29c9 100644 --- a/tests/inventory +++ b/tests/inventory @@ -1,9 +1,15 @@ [centos] tests_centos6_1 ansible_connection=docker tests_centos7_1 ansible_connection=docker +tests_centos8_1 ansible_connection=docker + [debian] tests_debian8_1 ansible_connection=docker tests_debian9_1 ansible_connection=docker +tests_debian10_1 ansible_connection=docker + [ubuntu] tests_ubuntu14_1 ansible_connection=docker tests_ubuntu16_1 ansible_connection=docker +tests_ubuntu18_1 ansible_connection=docker +tests_ubuntu20_1 ansible_connection=docker diff --git a/tests/root.yml b/tests/root.yml index 96db50653..0372b0d25 100644 --- a/tests/root.yml +++ b/tests/root.yml @@ -1,19 +1,23 @@ --- -- hosts: all +- name: RVM System Wide Setup + hosts: all gather_facts: false vars: rvm1_user: root rvm1_install_flags: '--auto-dotfiles' - rvm1_install_path: '/home/{{ rvm1_user }}/.rvm' + rvm1_install_path: '/opt/rvm' rvm1_rubies: - - 'ruby-2.2.5' - - 'ruby-2.3.1' + - 'ruby-{{ rvm_tests_mri_version_other }}' + - 'ruby-{{ rvm_tests_mri_version_default }}' roles: - - role: rvm1-ansible + - rvm1-ansible + tags: setup -# Asserts tasks -- hosts: all +- name: RVM Setup Validation + hosts: all gather_facts: false + vars: + rvm1_install_path: '/opt/rvm' tasks: - - name: Assert tasks - import_tasks: assertions.yml + - import_tasks: assertions.yml + tags: validate \ No newline at end of file diff --git a/tests/user.yml b/tests/user.yml index ac0005fd3..d7f77dfc6 100644 --- a/tests/user.yml +++ b/tests/user.yml @@ -1,21 +1,25 @@ --- -- hosts: all +- name: RVM Single User Setup + hosts: all gather_facts: false remote_user: user vars: rvm1_user: user rvm1_install_path: '/home/{{ rvm1_user }}/.rvm' rvm1_rubies: - - 'ruby-2.2.5' - - 'ruby-2.3.1' + - 'ruby-{{ rvm_tests_mri_version_other }}' + - 'ruby-{{ rvm_tests_mri_version_default }}' roles: - role: rvm1-ansible become: yes + tags: setup -# Asserts tasks -- hosts: all +- name: RVM Setup Validation + hosts: all gather_facts: false remote_user: user + vars: + rvm1_install_path: '/home/user/.rvm' tasks: - - name: Assert tasks - import_tasks: assertions.yml + - import_tasks: assertions.yml + tags: validate \ No newline at end of file