|
| 1 | +name: Main |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + lint: |
| 7 | + runs-on: ubuntu-18.04 |
| 8 | + steps: |
| 9 | + - uses: actions/checkout@v1 |
| 10 | + - uses: actions/setup-python@v1 |
| 11 | + with: |
| 12 | + python-version: '3.7' |
| 13 | + |
| 14 | + - name: Install dependencies |
| 15 | + run: | |
| 16 | + sudo apt update -y |
| 17 | + python -m pip install --upgrade pip |
| 18 | + pip install -r requirements.txt |
| 19 | + sudo snap install shellcheck |
| 20 | + pip install ansible-lint |
| 21 | +
|
| 22 | + - name: Checks and linters |
| 23 | + run: | |
| 24 | + /snap/bin/shellcheck algo install.sh |
| 25 | + ansible-playbook main.yml --syntax-check |
| 26 | + ansible-lint -v *.yml roles/{local,cloud-*}/*/*.yml |
| 27 | +
|
| 28 | + scripted-deploy: |
| 29 | + runs-on: ubuntu-16.04 |
| 30 | + strategy: |
| 31 | + matrix: |
| 32 | + UBUNTU_VERSION: ["18.04", "19.10"] |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v1 |
| 35 | + - uses: actions/setup-python@v1 |
| 36 | + with: |
| 37 | + python-version: '3.7' |
| 38 | + |
| 39 | + - name: Install dependencies |
| 40 | + run: | |
| 41 | + sudo apt update -y |
| 42 | + sudo add-apt-repository -yu ppa:wireguard/wireguard |
| 43 | + sudo apt install -y \ |
| 44 | + python3-pip \ |
| 45 | + lxd \ |
| 46 | + expect-dev \ |
| 47 | + debootstrap \ |
| 48 | + tree \ |
| 49 | + bridge-utils \ |
| 50 | + dnsutils \ |
| 51 | + build-essential \ |
| 52 | + libssl-dev \ |
| 53 | + libffi-dev \ |
| 54 | + python3-dev \ |
| 55 | + linux-headers-$(uname -r) \ |
| 56 | + wireguard \ |
| 57 | + libxml2-utils \ |
| 58 | + crudini \ |
| 59 | + fping \ |
| 60 | + strongswan \ |
| 61 | + libstrongswan-standard-plugins \ |
| 62 | + resolvconf |
| 63 | +
|
| 64 | + python3 -m pip install --upgrade pip |
| 65 | + python3 -m pip install -r requirements.txt |
| 66 | +
|
| 67 | + - name: Provision |
| 68 | + env: |
| 69 | + DEPLOY: cloud-init |
| 70 | + UBUNTU_VERSION: ${{ matrix.UBUNTU_VERSION }} |
| 71 | + REPOSITORY: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }} |
| 72 | + BRANCH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} |
| 73 | + run: | |
| 74 | + ssh-keygen -f ~/.ssh/id_rsa -t rsa -N '' |
| 75 | + # sed -i "s/^reduce_mtu:\s0$/reduce_mtu: 80/" config.cfg |
| 76 | + sudo -E ./tests/pre-deploy.sh |
| 77 | +
|
| 78 | + - name: Deployment |
| 79 | + run: | |
| 80 | + 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 |
| 81 | + ( sudo lxc exec algo -- tail -f /var/log/cloud-init-output.log & ) |
| 82 | + until sudo lxc exec algo -- test -f /var/lib/cloud/data/result.json; do |
| 83 | + echo 'Cloud init is not finished. Sleep for 30 seconds'; |
| 84 | + sleep 30; |
| 85 | + done |
| 86 | + sudo lxc exec algo -- test -f /opt/algo/configs/localhost/.config.yml |
| 87 | + sudo lxc exec algo -- tar zcf /root/algo-configs.tar -C /opt/algo/configs/ . |
| 88 | + sudo lxc file pull algo/root/algo-configs.tar ./ |
| 89 | + sudo tar -C ./configs -zxf algo-configs.tar |
| 90 | +
|
| 91 | + - name: Tests |
| 92 | + run: | |
| 93 | + set -x |
| 94 | + sudo -E bash -x ./tests/wireguard-client.sh |
| 95 | + sudo env "PATH=$PATH" ./tests/ipsec-client.sh |
| 96 | +
|
| 97 | + local-deploy: |
| 98 | + runs-on: ubuntu-16.04 |
| 99 | + strategy: |
| 100 | + matrix: |
| 101 | + UBUNTU_VERSION: ["18.04", "19.10"] |
| 102 | + steps: |
| 103 | + - uses: actions/checkout@v1 |
| 104 | + - uses: actions/setup-python@v1 |
| 105 | + with: |
| 106 | + python-version: '3.7' |
| 107 | + |
| 108 | + - name: Install dependencies |
| 109 | + run: | |
| 110 | + set -x |
| 111 | + sudo add-apt-repository -yu ppa:wireguard/wireguard |
| 112 | + sudo add-apt-repository -yu ppa:ubuntu-lxc/stable |
| 113 | + sudo apt update -y |
| 114 | + sudo apt install -y \ |
| 115 | + python3-pip \ |
| 116 | + lxd \ |
| 117 | + expect-dev \ |
| 118 | + debootstrap \ |
| 119 | + tree \ |
| 120 | + bridge-utils \ |
| 121 | + dnsutils \ |
| 122 | + build-essential \ |
| 123 | + libssl-dev \ |
| 124 | + libffi-dev \ |
| 125 | + python3-dev \ |
| 126 | + linux-headers-$(uname -r) \ |
| 127 | + wireguard \ |
| 128 | + libxml2-utils \ |
| 129 | + crudini \ |
| 130 | + fping \ |
| 131 | + strongswan \ |
| 132 | + libstrongswan-standard-plugins \ |
| 133 | + resolvconf |
| 134 | +
|
| 135 | + python3 -m pip install --upgrade pip |
| 136 | + python3 -m pip install -r requirements.txt |
| 137 | +
|
| 138 | + - name: Provision |
| 139 | + env: |
| 140 | + DEPLOY: docker |
| 141 | + UBUNTU_VERSION: ${{ matrix.UBUNTU_VERSION }} |
| 142 | + REPOSITORY: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }} |
| 143 | + BRANCH: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} |
| 144 | + run: | |
| 145 | + ssh-keygen -f ~/.ssh/id_rsa -t rsa -N '' |
| 146 | + sed -i "s/^reduce_mtu:\s0$/reduce_mtu: 80/" config.cfg |
| 147 | + sudo -E ./tests/pre-deploy.sh |
| 148 | +
|
| 149 | + - name: Deployment |
| 150 | + env: |
| 151 | + DEPLOY: docker |
| 152 | + UBUNTU_VERSION: ${{ matrix.UBUNTU_VERSION }} |
| 153 | + run: | |
| 154 | + docker build -t local/algo . |
| 155 | + ./tests/local-deploy.sh |
| 156 | + ./tests/update-users.sh |
| 157 | +
|
| 158 | + - name: Tests |
| 159 | + run: | |
| 160 | + set -x |
| 161 | + sudo bash -x ./tests/wireguard-client.sh |
| 162 | + sudo env "PATH=$PATH" bash -x ./tests/ipsec-client.sh |
| 163 | + sudo bash -x ./tests/ssh-tunnel.sh |
0 commit comments