Codebase list golang-gopkg-lxc-go-lxc.v2 / f7d0f5c
Switch to Github actions Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Stéphane Graber 3 years ago
4 changed file(s) with 110 addition(s) and 59 deletion(s). Raw diff Collapse all Expand all
0 name: Static analysis
1 on:
2 - push
3 - pull_request
4
5 jobs:
6 test:
7 runs-on: ubuntu-20.04
8 steps:
9 - name: Install Go
10 uses: actions/setup-go@v2
11 with:
12 go-version: 1.16.x
13
14 - name: Checkout code
15 uses: actions/checkout@v2
16
17 - name: Validate Go modules
18 run: |
19 make update-gomod
20 git diff --exit-code
21
22 - name: Install dependencies
23 run: |
24 sudo add-apt-repository ppa:ubuntu-lxc/daily -y
25 sudo apt-get install -qq lxc-dev pkg-config
26 go get golang.org/x/lint/golint
27 go get golang.org/x/tools/cmd/goimports
28
29 - name: Static analysis
30 run: make all
0 name: CI tests
1 on:
2 - push
3 - pull_request
4
5 jobs:
6 test:
7 strategy:
8 fail-fast: false
9 matrix:
10 go:
11 - 1.13.x
12 - 1.14.x
13 - 1.15.x
14 - 1.16.x
15 os:
16 - ubuntu-18.04
17 - ubuntu-20.04
18 runs-on: ${{ matrix.os }}
19 steps:
20 - name: Install Go
21 uses: actions/setup-go@v2
22 with:
23 go-version: ${{ matrix.go }}
24
25 - name: Checkout code
26 uses: actions/checkout@v2
27
28 - name: Install dependencies
29 run: |
30 sudo add-apt-repository ppa:ubuntu-lxc/daily -y
31 sudo apt-get install -qq lxc lxc-dev pkg-config uidmap busybox
32
33 - name: Setup test environment
34 run: |
35 # Setup uid/gid and veth allocations
36 echo "${USER}:100000:65536" | sudo tee /etc/subuid
37 echo "${USER}:100000:65536" | sudo tee /etc/subgid
38 echo "${USER} veth lxcbr0 10" | sudo tee -a /etc/lxc/lxc-usernet
39
40 # Local user configuration for userns
41 mkdir -p ~/.config/lxc/
42 cp /etc/lxc/default.conf ~/.config/lxc/default.conf
43 echo "lxc.idmap = u 0 100000 65536" | tee -a ~/.config/lxc/default.conf
44 echo "lxc.idmap = g 0 100000 65536" | tee -a ~/.config/lxc/default.conf
45
46 # Allow traversal to the containers
47 mkdir -p ~/.local/share/lxc
48 chmod +x ~/ ~/.local ~/.local/share ~/.local/share/lxc
49
50 - name: Build the test
51 run:
52 go test -c -coverprofile=profile
53
54 - name: Unprivileged tests
55 env:
56 DOWNLOAD_KEYSERVER: keyserver.ubuntu.com
57 run: |
58 # Make all cgroups writable
59 for d in /sys/fs/cgroup/*; do
60 [ -f $d/cgroup.clone_children ] && echo 1 | sudo tee $d/cgroup.clone_children
61 [ -f $d/cgroup.use_hierarchy ] && echo 1 | sudo tee $d/cgroup.use_hierarchy
62
63 sudo mkdir -p $d/lxc-test
64 sudo chown -R $USER: $d/lxc-test
65 echo $$ | sudo tee $d/lxc-test/cgroup.procs
66 done
67
68 # Run the unprivileged tests
69 ./go-lxc.test -test.v -test.coverprofile=/tmp/unpriv.out
70
71 - name: Privileged tests
72 env:
73 DOWNLOAD_KEYSERVER: keyserver.ubuntu.com
74 run:
75 sudo -E ./go-lxc.test -test.v -test.coverprofile=/tmp/priv.out
76
77 - name: Code coverage
78 run: make cover
+0
-51
.travis.yml less more
0 language: go
1
2 os:
3 - linux
4
5 go:
6 - 1.10.x
7 - 1.11.x
8 - 1.12.x
9 - 1.13.x
10 - 1.14.x
11 - tip
12
13 matrix:
14 fast_finish: true
15 allow_failures:
16 - go: tip
17
18 before_install:
19 - sudo add-apt-repository ppa:ubuntu-lxc/daily -y
20 - sudo apt-get update
21 - sudo apt-get install -qq lxc lxc-dev uidmap busybox
22 - echo "${USER}:100000:65536" | sudo tee /etc/subuid
23 - echo "${USER}:100000:65536" | sudo tee /etc/subgid
24 - echo "${USER} veth lxcbr0 10" | sudo tee -a /etc/lxc/lxc-usernet
25 - mkdir -p ${HOME}/.config/lxc/
26 - cp /etc/lxc/default.conf ${HOME}/.config/lxc/default.conf
27 - echo "lxc.id_map = u 0 100000 65536" | sudo tee -a ${HOME}/.config/lxc/default.conf
28 - echo "lxc.id_map = g 0 100000 65536" | sudo tee -a ${HOME}/.config/lxc/default.conf
29 - "make setup-test-cgroup"
30 - mkdir -p ${HOME}/.local/share/lxc
31 - chmod +x ${HOME}
32 - chmod +x ${HOME}/.local
33 - chmod +x ${HOME}/.local/share
34 - chmod +x ${HOME}/.local/share/lxc
35
36 install:
37 - go get golang.org/x/tools/cmd/goimports
38 - go get golang.org/x/sys/unix
39 - go get gopkg.in/lxc/go-lxc.v2
40
41 script:
42 - "make all"
43 - "make test"
44 - "make test-race"
45 - "make test-privileged"
46 - "make test-privileged-race"
47 - "make cover"
48
49 notifications:
50 webhooks: https://linuxcontainers.org/webhook-lxcbot/
5858 @echo "$(OK_COLOR)==> Exported container calls in container.go $(NO_COLOR)"
5959 @/bin/grep -E "\bc+\.([A-Z])\w+" container.go || true
6060
61 setup-test-cgroup:
62 for d in /sys/fs/cgroup/*; do \
63 [ -f $$d/cgroup.clone_children ] && echo 1 | sudo tee $$d/cgroup.clone_children; \
64 [ -f $$d/cgroup.use_hierarchy ] && echo 1 | sudo tee $$d/cgroup.use_hierarchy; \
65 sudo mkdir -p $$d/lxc; \
66 sudo chown -R $$USER: $$d/lxc; \
67 done
68
6961 .PHONY: all format test doc vet lint ctags