From 4c3d90d3b3a3d6f40358ecdceca001b31b9f4d99 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 26 Jan 2021 05:25:40 +0100 Subject: [PATCH] Run tests on Cirrus CI, drop Travis (#416) Travis stopped handing out free credits since their plan changes last November, so tests have not run since then. Cirrus CI offers an API similar to Travis, and also explicitly supports /dev/kvm access. Eventually we want to use the cockpit/tasks container directly. But we can't fix the /dev/kvm permissions inside that as `sudo` does not work in that. Once we fix that, the setup will become much cheaper and simpler. --- .cirrus.yml | 23 +++++++++++++++++++++++ .travis.yml | 31 ------------------------------- README.md | 20 +++++++++++++------- 3 files changed, 36 insertions(+), 38 deletions(-) create mode 100644 .cirrus.yml delete mode 100644 .travis.yml diff --git a/.cirrus.yml b/.cirrus.yml new file mode 100644 index 0000000..df2a5d6 --- /dev/null +++ b/.cirrus.yml @@ -0,0 +1,23 @@ +container: + # We should use quay.io/cockpit/tasks here and avoid package installation, but we can't currently run sudo in that container to fix /dev/kvm permissions + image: docker.io/fedora + kvm: true + # increase this if you have many tests that benefit from parallelism + cpu: 1 + +test_task: + env: + matrix: + - TEST_OS: fedora-33 + - TEST_OS: centos-8-stream + + setup_script: + - chmod 666 /dev/kvm + - dnf install -y chromium-headless curl git libappstream-glib libvirt-daemon-kvm libvirt-client libvirt-python3 make npm rpm-build rpmdevtools sassc tar + - useradd build + - chown -R build:build . + + # test PO template generation + pot_build_script: su -c 'make po/starter-kit.pot' build + + check_script: su -c "TEST_JOBS=$(nproc) TEST_OS=$TEST_OS make check" build diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3527496..0000000 --- a/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -dist: focal -sudo: true -language: minimal -addons: - apt: - packages: - - appstream-util - - chromium-browser - - curl - - git - - libvirt-daemon-system - - npm - - python3-libvirt - - qemu-kvm - - qemu-utils - - rpm - - sassc -env: - - TEST_OS=fedora-33 - - TEST_OS=centos-8-stream -script: - # HACK: /dev/kvm is root:kvm 0660 by default - - sudo chmod 666 /dev/kvm - - # test PO template generation - - make po/starter-kit.pot - - # FIXME: build rpm inside VM; no installed rpms on Travis Ubuntu environment - - sed -i '/^BuildRequires:/d' *.spec.in - - - TEST_JOBS=$(nproc) make check diff --git a/README.md b/README.md index 5f191b6..33bd097 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Violations of some rules can be fixed automatically by: Rules configuration can be found in the `.eslintrc.json` file. -# Automated Testing +# Running tests locally Run `make check` to build an RPM, install it into a standard Cockpit test VM (centos-7 by default), and run the test/check-application integration test on @@ -80,12 +80,18 @@ You can also run the test against a different Cockpit image, for example: TEST_OS=fedora-32 make check -These tests can be run in [Travis CI](https://travis-ci.com/). The included -[travis.yml](./.travis.yml) runs the integration tests for two operating -systems (Fedora and CentOS 8). Note that if/once your project grows bigger, or -gets frequent changes, you likely need to move to a paid account, or different -infrastructure with more capacity. Talk to the -[Cockpit developers](https://cockpit-project.org/) if you are interested in that. +# Running tests in CI + +These tests can be run in [Cirrus CI](https://cirrus-ci.org/), on their free +[Linux Containers](https://cirrus-ci.org/guide/linux/) environment which +explicitly supports `/dev/kvm`. Please see [Quick +Start](https://cirrus-ci.org/guide/quick-start/) how to set up Cirrus CI for +your project after forking from starter-kit. + +The included [.cirrus.yml](./.cirrus.yml) runs the integration tests for two +operating systems (Fedora and CentOS 8). Note that if/once your project grows +bigger, or gets frequent changes, you may need to move to a paid account, or +different infrastructure with more capacity. # Customizing