Skip to content

Commit

Permalink
WIP: add GHA CI
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Aug 15, 2023
1 parent 4f72b30 commit 9b940d7
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 16 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI

on:
push:
branches:
- 'master'
pull_request:
branches:
- 'master'

jobs:
test:
name: Test Suite
strategy:
fail-fast: false
matrix:
include:
- SELECT: nose
OLD_REV: "HEAD"
OLD_UBUNTU: bionic
- SELECT: nose
OLD_REV: "v0.3.0"
OLD_UBUNTU: bionic
- SELECT: nose
OLD_REV: "4e4f13cdc630c46909d47441093a5bdaffa0d67f"
OLD_UBUNTU: trusty
- SELECT: nose
OLD_REV: "c638231efca6b3a6e1c675ac0834a3e851ad1bdc"
OLD_UBUNTU: trusty
- SELECT: usage
- SELECT: client
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.6'
- name: Setup
run: |
set -x
git fetch --unshallow # GHA only does a shallow clone
sudo add-apt-repository universe
sudo apt-get -qq update
sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -qq --assume-no install bison build-essential flex gawk gettext git git-core libncurses5-dev libssl-dev lxc m4 subversion unzip zlib1g-dev python3-lxc python3-nose linux-libc-dev cmake libnl-3-dev libnl-genl-3-dev libasyncns-dev linux-modules-extra-$(uname -r)
sudo modprobe l2tp_netlink
sudo modprobe l2tp_eth
# Newer versions of the broker don't need the following but keep it around for cross-version testing
sudo modprobe nf_conntrack
sudo modprobe nf_conntrack_netlink
sudo iptables -t nat -L >/dev/null
sudo iptables -t filter -P FORWARD ACCEPT
- name: Run tests
run: |
export NEW_REV=$(git rev-parse HEAD)
export SELECT=${{ matrix.SELECT }}
export OLD_REV=${{ matrix.OLD_REV }}
export OLD_UBUNTU=${{ matrix.OLD_UBUNTU }}
sudo -E ./tests/travis.sh
2 changes: 1 addition & 1 deletion tests/test_nose.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

import logging
import lxc
Expand Down
2 changes: 1 addition & 1 deletion tests/test_usage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

import logging
import os
Expand Down
16 changes: 7 additions & 9 deletions tests/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,24 @@

. $(dirname $0)/lib_ci.sh

set -e

export WORKSPACE=$PWD
export PATH=/usr/bin/:/usr/sbin:/usr/local/bin:/usr/local/sbin:/bin:/sbin
unset VIRTUAL_ENV

# retrieve git rev
NEW_REV=$TRAVIS_COMMIT
#export PATH=/usr/bin/:/usr/sbin:/usr/local/bin:/usr/local/sbin:/bin:/sbin
#unset VIRTUAL_ENV

# OLD_REV defined by .travis.yml
# NEW_REV, OLD_REV defined by .travis.yml
# SELECT too

if [ "$OLD_REV" = "HEAD" ] ; then
OLD_REV=$TRAVIS_COMMIT
OLD_REV=$NEW_REV
fi

# We had a lot of intermittent failures with the default keyserver (pool.sks-keyservers.net).
#export DOWNLOAD_KEYSERVER="pgp.mit.edu"
#export DOWNLOAD_KEYSERVER="keyserver.ubuntu.com"

set -ex
/usr/bin/env python --version

# finish setup
$(dirname $0)/tunneldigger.py --setup bionic
if [[ "$OLD_UBUNTU" == "trusty" || "$SELECT" == "usage" ]]; then
Expand Down
11 changes: 6 additions & 5 deletions tests/tunneldigger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

import lxc
from random import randint
Expand Down Expand Up @@ -42,7 +42,7 @@ def setup_template(ubuntu_release):

lxc_run_command(container, ["ip", "a"])
lxc_run_command(container, ["dhclient", "eth0"])
check_ping(container, 'google-public-dns-a.google.com', 10)
lxc_run_command(container, ["ip", "a"])
lxc_run_command(container, ["apt-get", "update"])
lxc_run_command(container, ["apt-get", "dist-upgrade", "-y"])

Expand Down Expand Up @@ -193,9 +193,10 @@ def prepare(cont_type, name, revision, bridge, ip_netmask='172.16.16.1/24', ubun
if not cont.start():
raise RuntimeError("Can not start container %s" % cont.name)
sleep(3)
if not check_ping(cont, 'google-public-dns-a.google.com', 20):
raise RuntimeError("Container doesn't have an internet connection %s"
% cont.name)
# ping does not work on GHA...
#if not check_ping(cont, 'google-public-dns-a.google.com', 20):
# raise RuntimeError("Container doesn't have an internet connection %s"
# % cont.name)

script = '/testing/prepare_%s.sh' % cont_type
LOG.info("Server %s run %s", name, script)
Expand Down

0 comments on commit 9b940d7

Please sign in to comment.