Skip to content

Commit

Permalink
update travis-ci tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jackivanov committed Mar 21, 2019
1 parent e8f733a commit cbc8db3
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 34 deletions.
71 changes: 42 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
---
language: python
python: "2.7"
sudo: required
dist: trusty
dist: xenial

services:
- docker

matrix:
fast_finish: true

addons:
apt:
sources:
Expand Down Expand Up @@ -41,35 +37,52 @@ before_cache:
- sudo tar cf $HOME/lxc/cache.tar /var/lib/lxd/images/
- sudo chown $USER. $HOME/lxc/cache.tar

env:
- LXC_NAME=docker LXC_DISTRO=ubuntu LXC_RELEASE=18.04

before_install:
- test "${LXC_NAME}" != "docker" && sudo modprobe wireguard || docker build -t travis/algo .
matrix:
fast_finish: true
include:
# - stage: Test
# name: local deployment from docker
# script:
# - docker build -t travis/algo .
# - sudo tar xf $HOME/lxc/cache.tar -C / || echo "Didn't extract cache."
# - sudo cp -f tests/lxd-bridge /etc/default/lxd-bridge
# - ssh-keygen -f ~/.ssh/id_rsa -t rsa -N ''
# - echo -e "#cloud-config\nssh_authorized_keys:\n - $(cat ~/.ssh/id_rsa.pub)" | sudo lxc profile set default user.user-data -
# - sudo service lxd restart
# - sudo lxc launch ubuntu:18.04 algo
# - until host algo.lxd 10.0.8.1 -t A; do sleep 3; done
# - export LXC_IP="$(dig algo.lxd @10.0.8.1 +short)"
# - pip install -r requirements.txt
# - pip install ansible-lint
# - gem install awesome_bot
# - ansible-playbook --version
# - tree . -L 2
# - ansible-playbook main.yml --syntax-check
# - ./tests/local-deploy.sh
# - ./tests/update-users.sh

install:
- sudo tar xf $HOME/lxc/cache.tar -C / || echo "Didn't extract cache."
- ssh-keygen -f ~/.ssh/id_rsa -t rsa -N ''
- chmod 0644 ~/.ssh/config
- echo -e "#cloud-config\nssh_authorized_keys:\n - $(cat ~/.ssh/id_rsa.pub)" | sudo lxc profile set default user.user-data -
- sudo cp -f tests/lxd-bridge /etc/default/lxd-bridge
- sudo service lxd restart
- sudo lxc launch ${LXC_DISTRO}:${LXC_RELEASE} ${LXC_NAME}
- until host ${LXC_NAME}.lxd 10.0.8.1 -t A; do sleep 3; done
- export LXC_IP="$(dig ${LXC_NAME}.lxd @10.0.8.1 +short)"
- pip install -r requirements.txt
- pip install ansible-lint
- gem install awesome_bot
- ansible-playbook --version
- tree . -L 2
- stage: Test
name: cloud-init deployment
script:
- sudo tar xf $HOME/lxc/cache.tar -C / || echo "Didn't extract cache."
- sudo cp -f tests/lxd-bridge /etc/default/lxd-bridge
- sudo service lxd restart
- sudo lxc profile unset default environment.http_proxy
- echo "curl -s https://raw.githubusercontent.com/${TRAVIS_PULL_REQUEST_SLUG:-${TRAVIS_REPO_SLUG}}/${TRAVIS_PULL_REQUEST_BRANCH:-${TRAVIS_BRANCH}}/install.sh | sudo -E bash -x" >> tests/cloud-init.sh
- sudo lxc profile set default user.user-data - < tests/cloud-init.sh
- sudo lxc profile show default
- sudo lxc launch ubuntu:18.04 algo
- until sudo lxc exec algo -- test -f /var/log/cloud-init-output.log; do echo 'Log file not found, Sleep for 3 seconds'; sleep 3; done
- ( sudo lxc exec algo -- tail -f /var/log/cloud-init-output.log & )
- timeout 900 bash -c "until sudo lxc exec algo -- test -f /var/lib/cloud/data/result.json; do echo 'Cloud init is not finished. Sleep for 30 seconds'; sleep 30; done"
/var/lib/cloud/data/result.json
# - sudo lxc exec algo -- cat /var/log/cloud-init-output.log
- sudo lxc exec algo -- test -f /opt/algo/configs/localhost/.config.yml

script:
# script:
# - awesome_bot --allow-dupe --skip-save-results *.md docs/*.md --white-list paypal.com,do.co,microsoft.com,https://github.com/trailofbits/algo/archive/master.zip,https://github.com/trailofbits/algo/issues/new
# - shellcheck algo
# - ansible-lint main.yml users.yml deploy_client.yml
- ansible-playbook main.yml --syntax-check
- ./tests/local-deploy.sh
- ./tests/update-users.sh

notifications:
email: false
11 changes: 9 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ LOCAL_DNS="${7:-${LOCAL_DNS:-false}}"
SSH_TUNNELING="${8:-${SSH_TUNNELING:-false}}"
ENDPOINT="${9:-${ENDPOINT:-localhost}}"
USERS="${10:-${USERS:-user1}}"
REPO_SLUG="${11:-${REPO_SLUG:-trailofbits/algo}}"
REPO_BRANCH="${12:-${REPO_BRANCH:-master}}"
EXTRA_VARS="${13:-${EXTRA_VARS:-placeholder=null}}"
ANSIBLE_EXTRA_ARGS="${14:-${ANSIBLE_EXTRA_ARGS}}"

cd /opt/

Expand All @@ -32,9 +36,11 @@ installRequirements() {
}

getAlgo() {
[ ! -d "algo" ] && git clone https://github.com/trailofbits/algo algo
[ ! -d "algo" ] && git clone https://github.com/${REPO_SLUG} algo
cd algo

git checkout ${REPO_BRANCH}

python -m virtualenv --python=`which python2` .venv
. .venv/bin/activate
python -m pip install -U pip virtualenv
Expand Down Expand Up @@ -95,7 +101,8 @@ deployAlgo() {
-e users=$(echo "$USERS" | jq -Rc 'split(",")') \
-e server=localhost \
-e ssh_user=root \
--skip-tags debug |
-e "${EXTRA_VARS}" \
--skip-tags debug ${ANSIBLE_EXTRA_ARGS} |
tee /var/log/algo.log
}

Expand Down
4 changes: 2 additions & 2 deletions roles/ssh_tunneling/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
passphrase: "{{ p12_export_password }}"
cipher: aes256
force: false
no_log: true
# no_log: true
when: not item.stat.exists
with_items: "{{ privatekey.results }}"
register: openssl_privatekey
Expand All @@ -76,7 +76,7 @@
privatekey_passphrase: "{{ p12_export_password }}"
format: OpenSSH
force: true
no_log: true
# no_log: true
when: item.changed
with_items: "{{ openssl_privatekey.results }}"

Expand Down
2 changes: 1 addition & 1 deletion roles/strongswan/tasks/client_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
with_together:
- "{{ users }}"
- "{{ PayloadContent.results }}"
no_log: True
# no_log: True

- name: Build the client ipsec config file
template:
Expand Down
13 changes: 13 additions & 0 deletions tests/cloud-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
export METHOD=local
export ONDEMAND_CELLULAR=true
export ONDEMAND_WIFI=true
export ONDEMAND_WIFI_EXCLUDE=test1,test2
export WINDOWS=true
export STORE_CAKEY=true
export LOCAL_DNS=true
export SSH_TUNNELING=true
export ENDPOINT=algo.lxc
export USERS=user1,user2
export EXTRA_VARS="install_headers=false tests=true apparmor_enabled=false"
export ANSIBLE_EXTRA_ARGS="--skip-tags apparmor"

0 comments on commit cbc8db3

Please sign in to comment.