Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci/gha: add go 1.16; run as root; fix some tests; add fedora #65

Merged
merged 8 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/Vagrantfile.fedora32 → .ci/Vagrantfile.fedora33
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Vagrant.configure("2") do |config|
# Fedora box is used for testing cgroup v2 support
config.vm.box = "fedora/32-cloud-base"
config.vm.box = "fedora/33-cloud-base"
config.vm.provider :virtualbox do |v|
v.memory = 2048
v.cpus = 2
Expand Down
20 changes: 0 additions & 20 deletions .ci/install-vagrant.sh

This file was deleted.

29 changes: 24 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,39 @@ jobs:
test:
strategy:
matrix:
go-version: [1.14.x, 1.15.x]
platform: [ubuntu-latest, windows-latest]
go-version: [1.14.x, 1.15.x, 1.16.x]
platform: [ubuntu-20.04, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v1
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Test
run: make test
- name: Lint
run: make lint
- name: Cross build
if: ${{ runner.os == 'Linux' }}
run: make cross
- name: Test
run: make test

# some features, like openat2, require a newer kernel
fedora:
# nested virtualization is only available on macOS hosts
runs-on: macos-10.15
steps:
- uses: actions/checkout@v2
- name: prepare vagrant
run: |
ln -sf .ci/Vagrantfile.fedora33 Vagrantfile
# Retry if it fails (download.fedoraproject.org returns 404 sometimes)
vagrant up || vagrant up
vagrant ssh-config >> ~/.ssh/config

- name: system info
run: ssh default 'sh -exc "uname -a && df -T"'

- name: tests
run: ssh default 'cd /vagrant && make test'
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ PACKAGES ?= mountinfo mount symlink
BINDIR ?= _build/bin
CROSS ?= linux/arm linux/arm64 linux/ppc64le linux/s390x \
freebsd/amd64 openbsd/amd64 darwin/amd64 darwin/arm64 windows/amd64
SUDO ?= sudo -n

.PHONY: all
all: lint test cross

.PHONY: test
test: RUN_VIA_SUDO = $(shell $(SUDO) true && echo -exec \"$(SUDO)\")
test:
for p in $(PACKAGES); do \
(cd $$p && go test -v .); \
(cd $$p && go test $(RUN_VIA_SUDO) -v .); \
done

.PHONY: lint
Expand Down
4 changes: 3 additions & 1 deletion mount/mounter_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ func validateMount(t *testing.T, mnt string, opts, optional, vfs string) {
if mi.VFSOptions != "" {
for _, opt := range strings.Split(mi.VFSOptions, ",") {
opt = clean(opt)
if !has(wantedVFS, opt) && opt != "seclabel" { // can be added by selinux
if !has(wantedVFS, opt) &&
opt != "seclabel" && // can be added by selinux
opt != "inode64" && opt != "inode32" { // can be added by kernel 5.9+
t.Errorf("unexpected vfs option %q, expected %q", opt, vfs)
}
delete(wantedVFS, opt)
Expand Down
18 changes: 12 additions & 6 deletions mountinfo/mounted_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,20 @@ func cleanupMounts(t *testing.T, dir string, mounts []string) {
}
}

func TestMountedBy(t *testing.T) {
func requireOpenat2(t *testing.T) {
t.Helper()
if os.Getuid() != 0 {
t.Skip("requires root")
}
fd, err := unix.Openat2(unix.AT_FDCWD, ".", &unix.OpenHow{Flags: unix.O_RDONLY})
if err != nil {
t.Skipf("openat2: %v (old kernel? need Linux 5.6+)", err)
}
unix.Close(fd)
}

func TestMountedBy(t *testing.T) {
requireOpenat2(t)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it would make sense to only skip the parts that require openat2, instead of the whole test? #67

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely had openat2 way in mind when writing this, mostly added mountinfo to test my test :)

But yeah, when I look at it, it makes some sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But as we already test in on an openat2-capable system that should be sufficient.

IOW it's up to you whether you want to update #67 to run this test partially or just close it.


dir, mounts, err := prepareMounts(t)
defer cleanupMounts(t, dir, mounts)
Expand Down Expand Up @@ -224,11 +234,7 @@ func TestMountedBy(t *testing.T) {
}

func TestMountedByOpenat2VsMountinfo(t *testing.T) {
fd, err := unix.Openat2(unix.AT_FDCWD, ".", &unix.OpenHow{Flags: unix.O_RDONLY})
if err != nil {
t.Skipf("openat2: %v (old kernel? need Linux 5.6+)", err)
}
unix.Close(fd)
requireOpenat2(t)

mounts, err := GetMounts(nil)
if err != nil {
Expand Down