File: task.yaml

package info (click to toggle)
snapd 2.72-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80,412 kB
  • sloc: sh: 16,506; ansic: 16,211; python: 11,213; makefile: 1,919; exp: 190; awk: 58; xml: 22
file content (131 lines) | stat: -rw-r--r-- 5,400 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
summary: Run project static and unit tests

details: |
    Most of snapd is implemented in Go. Some Go programs use elements of C that
    are sensitive to the specific C compiler used. We want to make sure that Go
    unit tests pass when executed as a non-root user. The test has three
    variants: one that uses GCC as the C compiler, one that uses Clang and one
    that only runs static analysis checks. That last variant is particularly
    used by ancient versions of Ubuntu, such as Ubuntu 14.04, which is too old
    to provide an adequate toolchain and lacks systemd running as session
    manager, which is needed by the session test tool.

# Start before anything else as it takes a long time.
priority: 1000

# tests.session requires busctl, which is not available on 14.04, but we still
# want to run the tests there at the same time, we should not run into problems
# with delayed session cleanup on this system

environment:
    VARIANT/clang: clang
    VARIANT/gcc: gcc
    VARIANT/static: static
    SNAP_REEXEC: 1

prepare: |
    if not os.query is-trusty; then
        tests.session -u test prepare
    fi

restore: |
    if not os.query is-trusty; then
        tests.session -u test restore
    fi
    rm -rf /tmp/static-unit-tests

execute: |
    mkdir -p /tmp/static-unit-tests/src/github.com/snapcore
    cp -ar "$PROJECT_PATH" /tmp/static-unit-tests/src/github.com/snapcore
    chown -R test:12345 /tmp/static-unit-tests

    # remove leftovers
    rm -r /tmp/static-unit-tests/src/github.com/snapcore/snapd/vendor/*/
    rm -rf /tmp/static-unit-tests/src/github.com/snapcore/snapd/cmd/{autom4te.cache,configure,test-driver,config.status,config.guess,config.sub,config.h.in,compile,install-sh,depcomp,build,missing,aclocal.m4,Makefile,Makefile.in}

    # The format of code produced by "gofmt" drifts over time. Perform checks
    # only on a fixed version to avoid hair-pulling annoyance every six months.
    if not os.query is-xenial; then
        skip='SKIP_GOFMT=1'
    fi

    if os.query is-xenial || os.query is-trusty || os.query is-bionic || os.query is-focal || ! os.query is-ubuntu; then
        skip="${skip:-} SKIP_MISSPELL=1 SKIP_INEFFASSIGN=1"
    fi

    if [[ -n "${SKIP_NAKEDRET:-}" ]]; then
        skip="${skip:-} SKIP_NAKEDRET=1"
    fi

    # golangci-lint checks are system agnostic and were already checked in the github
    # test workflow static checks. They can therefore be safely skipped here.
    skip="${skip:-} SKIP_GOLANGCI_LINT=1"

    PROXY_PARAM=""
    if [ -n "${http_proxy:-}" ]; then
        PROXY_PARAM="HTTP_PROXY=$http_proxy"
    fi
    if [ -n "${https_proxy:-}" ]; then
        PROXY_PARAM="$PROXY_PARAM HTTPS_PROXY=$https_proxy"
    fi

    export SKIP_MODERNIZE_LINT=y

    if not os.query is-trusty; then
        if [ "$VARIANT" = "static" ] ; then
            tests.session -u test exec sh -c "cd /tmp/static-unit-tests/src/github.com/snapcore/snapd && \
                PATH=$PATH \
                GOPATH=/tmp/static-unit-tests \
                $PROXY_PARAM \
                ${skip:-} \
                SKIP_TESTS_FORMAT_CHECK=1 \
                IGNORE_MISSING=1 \
                ./run-checks --static"
        else
            tests.session -u test exec sh -c "cd /tmp/static-unit-tests/src/github.com/snapcore/snapd && \
                PATH=$PATH \
                GOPATH=/tmp/static-unit-tests \
                $PROXY_PARAM \
                SKIP_COVERAGE=1 \
                CC=$VARIANT \
                IGNORE_MISSING=1 \
                ./run-checks --unit"
        fi
    else
        # on 14.04 we need to use a fork of libseccomp-golang
        sed -i 's|\"github.com/seccomp/libseccomp-golang\"|\"github.com/mvo5/libseccomp-golang\"|' \
            /tmp/static-unit-tests/src/github.com/snapcore/snapd/cmd/snap-seccomp/*.go

        if [ "$VARIANT" = "clang" ]; then
            # clang is more picky about duplicate values in switch statements,
            # and the fork has some unresolved issues which fail the build with like so:
            #
            # ../../../../pkg/mod/github.com/mvo5/libseccomp-golang@v0.9.1-0.20180308152521-f4de83b52afb/seccomp_internal.go:404:2: duplicate case _Ciconst_C_ARCH_MIPS (value 4294967295) in switch
            # 	previous case at $WORK/b338/_cgo_gotypes.go:75:7
            # ../../../../pkg/mod/github.com/mvo5/libseccomp-golang@v0.9.1-0.20180308152521-f4de83b52afb/seccomp_internal.go:406:2: duplicate case _Ciconst_C_ARCH_MIPS64 (value 4294967295) in switch
            # 	previous case at $WORK/b338/_cgo_gotypes.go:75:7
            echo "skipping"
            exit 0
        fi

        if [ "$VARIANT" = "static" ] ; then
            # 14.04 only
            su -l -c "cd /tmp/static-unit-tests/src/github.com/snapcore/snapd && \
                PATH=$PATH \
                GOPATH=/tmp/static-unit-tests \
                $PROXY_PARAM \
                ${skip:-} \
                SKIP_TESTS_FORMAT_CHECK=1 \
                IGNORE_MISSING=1 \
                ./run-checks --static" test
        else
            su -l -c "cd /tmp/static-unit-tests/src/github.com/snapcore/snapd && \
                PATH=$PATH \
                GOPATH=/tmp/static-unit-tests \
                $PROXY_PARAM \
                SKIP_COVERAGE=1 \
                CC=$VARIANT \
                IGNORE_MISSING=1 \
                ./run-checks --unit" test
        fi
    fi