From 74cd4594d6bda034f7a3782c7a6ec175112dd085 Mon Sep 17 00:00:00 2001 From: ly1217 <yu.liu@seafile.com> Date: Mon, 13 Jan 2020 18:55:55 -0800 Subject: [PATCH] Use github action as ci test. --- .github/workflows/ci.yml | 20 ++++++++++++++++++++ .travis.yml | 40 ---------------------------------------- ci/install-deps.sh | 12 +++++------- ci/requirements.txt | 1 + ci/run.py | 38 ++++++++++++++++++++++++++++++-------- ci/serverctl.py | 4 ++-- ci/utils.py | 4 ++-- 7 files changed, 60 insertions(+), 59 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b8d5fe0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,20 @@ +name: Seafile CI + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + with: + fetch-depth: 1 + - uses: actions/setup-python@v1 + with: + python-version: "3.6" + - name: install dependencies and test + run: | + cd $GITHUB_WORKSPACE + ./ci/install-deps.sh + ./ci/run.py diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0150bb6..0000000 --- a/.travis.yml +++ /dev/null @@ -1,40 +0,0 @@ -sudo: false -# Must set language to python so we can install custom python pacakges in -# docker-based travis builds -language: python -python: -- "3.7" -services: -- mysql -compiler: -- gcc -addons: - apt: - packages: - - valac - - uuid-dev - - libevent-dev - - libarchive-dev - - intltool - - libjansson-dev - - libonig-dev - - libfuse-dev - - net-tools -cache: - directories: - - "$HOME/.cache/pip" - - "$HOME/.ccache" -before_install: -- ccache -s -- export PATH=/usr/lib/ccache:${PATH} -install: -- "./ci/install-deps.sh" -- pip install future -script: -- "./ci/run.py" -notifications: - slack: - rooms: - secure: 3H6mh5PPPKo0wuwzZybDwnHOya0/IiW8jn/g9ZUFna5P5IqmuuFacZi+lS5Ffgrv/vRYbv9ebjDvIApk2CDc0KzA2vUwr79BjlfPqm1buf75dPf1aINhNjMT1g16afyxciMbdV5QtzSoiyYn+P4026SU40jmJXGL2u/O01HH/dF8Aw8/rpWjhZp1PjhRC40iilVe/q38E9biGsi9lKzJVXumhm3IYyZLsH7aqr2rTg67U1j2bB8OwTaJx4vZdpf6gxKLpwrumkLT1lNFvhOYieuxqNvBw752bB++FImswCwZ2t9ejX2jW1GjTdIJ1FpkHEVF2cz9AeRL5xeBz4bHtG3490PpfqcPLjQ39MI/FP6QRupAi0EUufbHpfx30kdqqBEyztcF66vR4hA42uDopIoF0HIIFyzgTnmN5SKmyhmOaE+hmfgWNtCm79ZYEx/PB8BvUyR2IV6UvQy2kHznNk8UnDnO2shP/2sOn3IUvZQ99y0UUk5LmJMQNOCiB31N1AFESbVKzAqR4ZKN+5K7CwEUQ1uaJgMmwuutrpgR+x6QvN3+zPHiLLunx6zTAJW6PWiHx5+Gxzt2Xi8iEtsmBOWu4o5kvAkjFMtYlzgd+12waQm4HpZaJ+xMbnZEG0jR3CUn7pXjKZhTxiFgXunYkalKWIIITFF5YUWgQJVrfng= - on_success: change - on_failure: always diff --git a/ci/install-deps.sh b/ci/install-deps.sh index 7953e5d..d45f8d5 100755 --- a/ci/install-deps.sh +++ b/ci/install-deps.sh @@ -8,11 +8,9 @@ SETUP_DIR=${TESTS_DIR}/ci cd $SETUP_DIR -pip install -r requirements.txt +sudo apt-get update +sudo apt-get install -y intltool libarchive-dev libcurl4-openssl-dev libevent-dev \ +libfuse-dev libglib2.0-dev libjansson-dev libmysqlclient-dev libonig-dev \ +sqlite3 libsqlite3-dev libtool net-tools uuid-dev valac mysql-client -# download precompiled libevhtp -# TODO(lins05): we should consider build from source with https://github.com/criticalstack/libevhtp in the future -libevhtp_bin=libevhtp-bin_1.2.0.tar.gz -wget https://dl.bintray.com/lins05/generic/libevhtp-bin/$libevhtp_bin -# tar xvf $libevhtp_bin --strip-components=3 -C /usr -tar xf $libevhtp_bin -C $HOME +pip install -r requirements.txt diff --git a/ci/requirements.txt b/ci/requirements.txt index 5a09c3e..a33b658 100644 --- a/ci/requirements.txt +++ b/ci/requirements.txt @@ -3,3 +3,4 @@ requests>=2.8.0 pytest>=3.3.2 backports.functools_lru_cache>=1.4 tenacity>=4.8.0 +future diff --git a/ci/run.py b/ci/run.py index d1cf1f0..ab412f8 100755 --- a/ci/run.py +++ b/ci/run.py @@ -18,14 +18,14 @@ import termcolor from serverctl import ServerCtl from utils import ( - cd, chdir, debug, green, info, lru_cache, mkdirs, on_travis, red, + cd, chdir, debug, green, info, lru_cache, mkdirs, on_github_actions, red, setup_logging, shell, warning ) logger = logging.getLogger(__name__) TOPDIR = abspath(join(os.getcwd(), '..')) -if on_travis(): +if on_github_actions(): PREFIX = expanduser('~/opt/local') else: PREFIX = os.environ.get('SEAFILE_INSTALL_PREFIX', '/usr/local') @@ -53,7 +53,9 @@ def make_build_env(): _env_add('LDFLAGS', '-L%s' % join(PREFIX, 'lib64'), seperator=' ') _env_add('PATH', join(PREFIX, 'bin')) - _env_add('PYTHONPATH', join(PREFIX, 'lib/python3.7/site-packages')) + if on_github_actions(): + _env_add('PYTHONPATH', join(os.environ.get('RUNNER_TOOL_CACHE'), 'Python/3.6.9/x64/lib/python3.6/site-packages')) + _env_add('PYTHONPATH', join(PREFIX, 'lib/python3.6/site-packages')) _env_add('PKG_CONFIG_PATH', join(PREFIX, 'lib', 'pkgconfig')) _env_add('PKG_CONFIG_PATH', join(PREFIX, 'lib64', 'pkgconfig')) _env_add('PKG_CONFIG_PATH', libsearpc_dir) @@ -157,18 +159,38 @@ class SeafileServer(Project): def __init__(self): super(SeafileServer, self).__init__('seafile-server') +class Libevhtp(Project): + def __init__(self): + super(Libevhtp, self).__init__('libevhtp') + + def branch(self): + return 'master' + + @chdir + def compile_and_install(self): + cmds = [ + 'cmake -DEVHTP_DISABLE_SSL=ON -DEVHTP_BUILD_SHARED=OFF', + 'make', + 'sudo make install', + 'sudo ldconfig', + ] + + for cmd in cmds: + shell(cmd) def fetch_and_build(): libsearpc = Libsearpc() + libevhtp = Libevhtp() ccnet = CcnetServer() seafile = SeafileServer() libsearpc.clone() - libsearpc.compile_and_install() - + libevhtp.clone() ccnet.clone() - ccnet.compile_and_install() + libsearpc.compile_and_install() + libevhtp.compile_and_install() + ccnet.compile_and_install() seafile.compile_and_install() @@ -184,9 +206,9 @@ def main(): mkdirs(INSTALLDIR) os.environ.update(make_build_env()) args = parse_args() - if on_travis() and not args.test_only: + if on_github_actions() and not args.test_only: fetch_and_build() - if on_travis(): + if on_github_actions(): dbs = ('sqlite3', 'mysql') else: dbs = ('sqlite3',) diff --git a/ci/serverctl.py b/ci/serverctl.py index 1d18084..91983b3 100755 --- a/ci/serverctl.py +++ b/ci/serverctl.py @@ -167,7 +167,7 @@ connection_charset = utf8 ccnet_sql_path = join(self.sql_dir, 'mysql', 'ccnet.sql') seafile_sql_path = join(self.sql_dir, 'mysql', 'seafile.sql') sql = f'USE ccnet; source {ccnet_sql_path}; USE seafile; source {seafile_sql_path};'.encode() - shell('mysql -u root', inputdata=sql, wait=False) + shell('sudo mysql -u root -proot', inputdata=sql, wait=False) else: config_sql_path = join(self.sql_dir, 'sqlite', 'config.sql') groupmgr_sql_path = join(self.sql_dir, 'sqlite', 'groupmgr.sql') @@ -257,4 +257,4 @@ GRANT ALL PRIVILEGES ON `ccnet`.* to `seafile`@localhost; GRANT ALL PRIVILEGES ON `seafile`.* to `seafile`@localhost; ''' - shell('mysql -u root', inputdata=sql) + shell('sudo mysql -u root -proot', inputdata=sql) diff --git a/ci/utils.py b/ci/utils.py index 0e908c5..f9e0fb5 100644 --- a/ci/utils.py +++ b/ci/utils.py @@ -95,8 +95,8 @@ def mkdirs(*paths): if not exists(path): os.mkdir(path) -def on_travis(): - return 'TRAVIS_BUILD_NUMBER' in os.environ +def on_github_actions(): + return 'GITHUB_ACTIONS' in os.environ @contextmanager def cd(path):