Skip to contentSkip to conversation

Migrate CI to GH Actions

PATCH In review Ondrej Mosnacek 2 participants 5 messages Jan 22, 2021 – Jan 23, 2021 SELinux security module

lore
Share & tools
lore
#0 lore raw

cover Migrate CI to GH Actions

See individual patches for more details.

Special thanks to Nicholas Iooss, who figured out this approach.

Note: I plan to merge this tomorrow (along with the userfaultfd test) so that we have working CI again. I might do that also earlier if someone acks it fast ;)

Ondrej Mosnacek (2):
check-syntax: use 'command -v' instead of 'which' Migrate CI to GH Actions

 .github/workflows/checks.yml |  27 +++++++
 .travis.yml                  |  40 ----------
 Vagrantfile                  |  65 ++++++++++++++++
 tools/check-syntax           |   2 +-
 travis-ci/LICENSE            |   5 --
 travis-ci/run-kvm-test.sh    | 141 -----------------------------------
 travis-ci/run-testsuite.sh   |  58 --------------
 7 files changed, 93 insertions(+), 245 deletions(-)
 create mode 100644 .github/workflows/checks.yml
 delete mode 100644 .travis.yml
 create mode 100644 Vagrantfile
 delete mode 100644 travis-ci/LICENSE
 delete mode 100755 travis-ci/run-kvm-test.sh
 delete mode 100755 travis-ci/run-testsuite.sh
Signature · 1 line
2.29.2
#1 lore raw

PATCH 1/2 check-syntax: use 'command -v' instead of 'which'

In minimal environments (e.g. Fedora container image) 'which' is not installed by default. To avoid the need to install an additional dependency, use 'command -v', which also does the trick and is a shell builtin.

---
 tools/check-syntax | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/check-syntax +1 -1
index 0ca79e2..2115a79 100755
@@ -27,7 +27,7 @@ CHK_PERL_EXCLUDE=""
 #
 function verify_deps() {
 	[[ -z "$1" ]] && return
-	if ! which "$1" >& /dev/null; then
+	if ! command -v "$1" >& /dev/null; then
 		echo "error: install \"$1\" and include it in your \$PATH"
 		exit 1
 	fi
Signature · 1 line
2.29.2
maintainer Acked-by on v1 1/2
#2 lore raw

Re: [PATCH testsuite 1/2] check-syntax: use 'command -v' instead of 'which'

Quoted 10 lines · Ondrej Mosnacek

In minimal environments (e.g. Fedora container image) 'which' is not installed by default. To avoid the need to install an additional dependency, use 'command -v', which also does the trick and is a shell builtin.

---
 tools/check-syntax | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Nice.

Signature · 2 lines
paul moore
www.paul-moore.com
#3 lore raw

PATCH 2/2 Migrate CI to GH Actions

In reply to Ondrej Mosnacek

As discovered by Nicholas Iooss [1], GH Actions now supports HW-accelerated Linux VMs at least on macOS runners [2], so we can finally migrate the CI away from Travis.

The new check uses Vagrant to provision the Fedora VM, as this is the simplest way to get it to work on macOS. Unfortunately there is no Rawhide image provided in the official Vagrant repos, so for now the testsuite is run only on Fedora 33. I'd like to add Rawhide in the future, but let's start with the low-hanging fruit.

[1] https://github.com/SELinuxProject/selinux/commit/316a4f89dd502d6f2b072f76af16de320c1cf673
[2] https://github.com/actions/virtual-environments/issues/433#issuecomment-618872784

---
 .github/workflows/checks.yml |  27 +++++++
 .travis.yml                  |  40 ----------
 Vagrantfile                  |  65 ++++++++++++++++
 travis-ci/LICENSE            |   5 --
 travis-ci/run-kvm-test.sh    | 141 -----------------------------------
 travis-ci/run-testsuite.sh   |  58 --------------
 6 files changed, 92 insertions(+), 244 deletions(-)
 create mode 100644 .github/workflows/checks.yml
 delete mode 100644 .travis.yml
 create mode 100644 Vagrantfile
 delete mode 100644 travis-ci/LICENSE
 delete mode 100755 travis-ci/run-kvm-test.sh
 delete mode 100755 travis-ci/run-testsuite.sh
.github/workflows/checks.yml new file +27 -0
new file mode 100644
index 0000000..e1e383f
@@ -0,0 +1,27 @@
+name: checks
+on: [push, pull_request]
+jobs:
+  style-check:
+    runs-on: ubuntu-latest
+    container:
+      image: fedora:latest
+    steps:
+      - run: sudo dnf install -y astyle perltidy findutils git-core
+      - uses: actions/checkout@v2
+      - run: tools/check-syntax -f && git diff --exit-code
+  fedora-test:
+    runs-on: macos-latest
+    env:
+      FEDORA_VERSION: 33
+    steps:
+      - uses: actions/checkout@v2
+      # macOS sometimes allows symlinks to have permissions other than 777,
+      # so change all symlink perms to match the Linux convention. Otherwise
+      # the rsync run by Vagrant will complain that it can't copy over the
+      # perms.
+      - name: Fix symlink permissions
+        run: find . -type link -exec chmod -h 777 \{\} \;
+      - name: Create a Vagrant VM
+        run: vagrant up
+      - name: Run SELinux testsuite
+        run: vagrant ssh -- sudo make -C /root/testsuite test
.travis.yml deleted +0 -40
deleted file mode 100644
index cba7462..0000000
@@ -1,40 +0,0 @@
-language: c
-
-dist: bionic
-
-env:
-  matrix:
-    - FEDORA_KIND="releases" FEDORA_MAJOR="33"
-    - FEDORA_KIND="development" FEDORA_MAJOR="rawhide"
-
-addons:
-  apt:
-    packages:
-      - astyle
-      - qemu-kvm
-      - libvirt-bin
-      - virtinst
-      - bridge-utils
-      - libguestfs-tools
-      - cpu-checker
-      - netcat
-
-before_install:
-  # FYI: known good with HEAD at 8551fc60fc515cd290ba38ee8c758c1f4df52b56
-  - git clone https://github.com/perltidy/perltidy.git perltidy
-  - |
-    (cd perltidy &&
-     perl Makefile.PL &&
-     make PREFIX=/usr/local &&
-     sudo make install PREFIX=/usr/local)
-  - sudo usermod -a -G kvm,libvirt,libvirt-qemu "$USER"
-  # Verify that KVM is working, useful if Travis ever changes anything.
-  - kvm-ok
-  - sudo systemctl enable libvirtd
-  - sudo systemctl start libvirtd
-  # Set up a key so we can ssh into the VM
-  - ssh-keygen -N "" -f "$HOME/.ssh/id_rsa"
-
-script:
-  - tools/check-syntax -f && git diff --exit-code
-  - bash travis-ci/run-kvm-test.sh travis-ci/run-testsuite.sh
Vagrantfile new file +65 -0

65 lines not on this page · raw message

travis-ci/LICENSE deleted +0 -5
deleted file mode 100644
index 1f95d26..0000000
@@ -1,5 +0,0 @@
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
travis-ci/run-kvm-test.sh deleted +0 -141

141 lines not on this page · raw message

travis-ci/run-testsuite.sh deleted +0 -58

58 lines not on this page · raw message

Signature · 1 line
2.29.2
#4 lore raw
In reply to Ondrej Mosnacek
Quoted 27 lines · Ondrej Mosnacek

See individual patches for more details.

Special thanks to Nicholas Iooss, who figured out this approach.

Note: I plan to merge this tomorrow (along with the userfaultfd test) so that we have working CI again. I might do that also earlier if someone acks it fast ;)

Ondrej Mosnacek (2):
check-syntax: use 'command -v' instead of 'which' Migrate CI to GH Actions

 .github/workflows/checks.yml |  27 +++++++
 .travis.yml                  |  40 ----------
 Vagrantfile                  |  65 ++++++++++++++++
 tools/check-syntax           |   2 +-
 travis-ci/LICENSE            |   5 --
 travis-ci/run-kvm-test.sh    | 141 -----------------------------------
 travis-ci/run-testsuite.sh   |  58 --------------
 7 files changed, 93 insertions(+), 245 deletions(-)
 create mode 100644 .github/workflows/checks.yml
 delete mode 100644 .travis.yml
 create mode 100644 Vagrantfile
 delete mode 100644 travis-ci/LICENSE
 delete mode 100755 travis-ci/run-kvm-test.sh
 delete mode 100755 travis-ci/run-testsuite.sh
Quoted 2 lines

--
2.29.2

Merged and passing:
https://github.com/SELinuxProject/selinux-testsuite/actions/runs/505560875

--
Ondrej Mosnacek
Software Engineer, Platform Security - SELinux kernel Red Hat, Inc.