aboutsummaryrefslogtreecommitdiffstats
path: root/.gitlab-ci.yml
blob: 9694cf0141805ac70b8aac67989315c1cfe478dd (plain)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
.build: &build
  stage: build
  after_script:
    - for builddir in build/packaging/rpm/BUILD/wireshark-*/build build/packaging/rpm/BUILD/wireshark-* build obj-*; do [ ! -d "$builddir/run" ] || break; done
    - if [[ "$CI_JOB_NAME" == "build:rpm-opensuse-"* ]]; then export LD_LIBRARY_PATH=$builddir/run; fi
    - if [ -f $builddir/run/tshark ]; then $builddir/run/tshark --version; fi

# The custom Ubuntu image pre-installs dependencies and compilers to speed up the build:
# https://hub.docker.com/r/wireshark/wireshark-ubuntu-dev
# https://github.com/wireshark/wireshark-ubuntu-dev-docker
# XXX - We might be able to speed things up using ccache:
# https://gould.cx/ted/blog/2017/06/10/ccache-for-Gitlab-CI/
.build-ubuntu: &build-ubuntu
  <<: *build
  image: wireshark/wireshark-ubuntu-dev
  retry: 1
  # https://gould.cx/ted/blog/2017/06/10/ccache-for-Gitlab-CI/
  cache:
    # XXX Use ${CI_JOB_NAME}-${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} instead?
    key: ${CI_JOB_NAME}-master
    paths:
      - ccache/
  before_script:
    - apt-get update -qq
    - ./tools/debian-setup.sh --install-optional --install-test-deps -y
    - useradd user
    - locale-gen en_US.UTF-8
    - export LANG=en_US.UTF-8
    - export PYTEST_ADDOPTS=--skip-missing-programs=dumpcap,rawshark
    - mkdir -p ccache
    - apt-get install -y ccache
    - export CCACHE_BASEDIR=${PWD}
    - export CCACHE_DIR=${PWD}/ccache
    - ccache --show-stats
    - export DEB_BUILD_OPTIONS=nocheck
    - mkdir build
    - cd build
  script:
    - cmake -GNinja $CMAKE_ARGS ..
    - ninja
    - ninja test-programs
    - chown -R user .
    - if [ -f run/dumpcap ]; then setcap cap_net_raw,cap_net_admin+eip run/dumpcap; fi
    - su user -c pytest-3

.build-rpm: &build-rpm
  <<: *build
  artifacts:
    paths:
      - build/packaging/rpm/RPMS
    expire_in: 3 days

# Rely on fedora:latest and debian-stable jobs for testing a recent GCC version.
clang-10: &clang-10
  <<: *build-ubuntu
  variables:
    CC: clang-10
    CXX: clang++-10

build:rpm-centos-7:
  <<: *build-rpm
  image: centos:7
  script:
    - yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    - tools/rpm-setup.sh --install-optional -y
    - mkdir build
    - cd build
    - cmake3 -GNinja ..
    - ninja-build rpm-package
test:rpm-centos-7:
  stage: test
  image: centos:7
  script:
    - yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    - yum --nogpgcheck localinstall -y build/packaging/rpm/RPMS/x86_64/*.rpm
    - tshark --version
  dependencies:
    - build:rpm-centos-7
  variables:
    GIT_STRATEGY: none
build:rpm-opensuse-15.1:
  image: opensuse/leap:15.1
  <<: *build-rpm
  script:
    - zypper --non-interactive install update-desktop-files
    - tools/rpm-setup.sh --install-optional ruby
    - gem install asciidoctor -v 1.5.8 --no-ri --no-rdoc
    - mkdir build
    - cd build
    - cmake -GNinja ..
    - ninja rpm-package
test:rpm-opensuse-15.1:
  image: opensuse/leap:15.1
  stage: test
  script:
    - zypper --no-gpg-checks install -y build/packaging/rpm/RPMS/x86_64/*.rpm
    - tshark --version
  variables:
    GIT_STRATEGY: none
  dependencies:
    - build:rpm-opensuse-15.1
build:rpm-fedora:
  <<: *build-rpm
  image: fedora
  script:
    - dnf upgrade -y
    - tools/rpm-setup.sh --install-optional -y
    - mkdir build
    - cd build
    - cmake3 -GNinja ..
    - ninja-build rpm-package
test:rpm-fedora:
  image: fedora
  stage: test
  script:
    - dnf install -y build/packaging/rpm/RPMS/x86_64/*.rpm
    - tshark --version
  variables:
    GIT_STRATEGY: none
  dependencies:
    - build:rpm-fedora

# Job to generate packages for Debian stable
build:debian-stable:
  <<: *build
  image: debian:stable
  before_script:
    - ./tools/debian-setup.sh --install-optional --install-test-deps -y --install-deb-deps
  script:
    # Shared GitLab runners limit the log size to 4M, so reduce verbosity. See
    # https://gitlab.com/gitlab-com/support-forum/issues/2790
    - DH_QUIET=1 dpkg-buildpackage -b --no-sign -jauto
    - mkdir debian-packages
    - mv ../*.deb debian-packages/
  artifacts:
    paths:
      - debian-packages/*.deb
    expire_in: 3 days
test:debian-stable:
  image: debian:stable
  stage: test
  script:
    - apt-get update
    - DEBIAN_FRONTEND=noninteractive apt-get install ./debian-packages/*.deb -y
    - tshark --version
  variables:
    GIT_STRATEGY: none
  dependencies:
    - build:debian-stable

# https://docs.gitlab.com/ee/user/gitlab_com/index.html#linux-shared-runners
merge-request:ubuntu-dpkg:
  <<: *build-ubuntu
  tags:
    - docker
  only:
    - merge_requests
  script:
    - apt-get install -y lintian
    # build-ubuntu puts us in `build`.
    - cd ..
    # From the Buildbot Petri Dish. We might want to spread these across different builders.
    - bash ./tools/pre-commit 'HEAD^1'
    - sh -c '[ ! -e tools/validate-commit.py ] || tools/validate-commit.py'
    - DH_QUIET=1 CC=/usr/lib/ccache/gcc CXX=/usr/lib/ccache/g++ dpkg-buildpackage -us -uc -rfakeroot -jauto -Zgzip -zfast
    - lintian --suppress-tags library-not-linked-against-libc --display-experimental --display-info --pedantic --profile debian

merge-request:ubuntu-gcc-ctest:
  <<: *build-ubuntu
  tags:
    - docker
  only:
   - merge_requests
  script:
    # build-ubuntu puts us in `build`.
    - perl ../tools/make-version.pl --set-release || ../perl make-version.pl --set-release
    - CC=gcc CXX=g++ cmake -DENABLE_EXTRA_COMPILER_WARNINGS=on -DCMAKE_EXPORT_COMPILE_COMMANDS=on -DENABLE_CCACHE=ON -G Ninja ..
    - ninja
    - ninja test-programs
    - chown -R user .
    - su user -c "ctest --parallel 3 --force-new-ctest-process --verbose"

merge-request:ubuntu-clang-other-tests:
  extends: clang-10
  tags:
    - docker
  only:
    - merge_requests
  script:
    - apt-get install -y cppcheck clang-tools
    # build-ubuntu puts us in `build`.
    - cd ..
    - python3 tools/checklicenses.py
    - ./tools/cppcheck/cppcheck.sh -l 1
    - cd build
    - cmake -DENABLE_EXTRA_COMPILER_WARNINGS=on -DENABLE_CHECKHF_CONFLICT=on -DCMAKE_EXPORT_COMPILE_COMMANDS=on -DENABLE_CCACHE=ON -G Ninja ..
    - ninja
    - ./run/tshark -v
    - sh -c '[ ! -e ../tools/validate-clang-check.sh ] || ../tools/validate-clang-check.sh'
    - ninja checkAPI

# XXX This is still beta:
# https://docs.gitlab.com/ee/user/gitlab_com/index.html#windows-shared-runners-beta
# Dockerfile at https://github.com/wireshark/wireshark-windows-dev-docker.
# XXX We currently depend on Qt being installed in C:\Qt on the host. We should
# find a more independent way of installing Qt, e.g. via a download+cache.
merge-request:windows:
  tags:
    - wireshark-windows-dev
  stage: build
  only:
   - merge_requests
  before_script:
    # XXX Find a better location.
    - mkdir c:\Development
    - $env:WIRESHARK_BASE_DIR = "C:\Development"
    - $env:Configuration = "RelWithDebInfo"
    - $env:Path += ";C:\Program Files\CMake\bin"
    - $env:Path += ";C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin"
    - $env:Path += ";C:\qt\5.12.8\msvc2017_64\bin"
    # https://help.appveyor.com/discussions/questions/18777-how-to-use-vcvars64bat-from-powershell
    - cmd.exe /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%\vcvars.txt"
    - Get-Content "$env:temp\vcvars.txt" | Foreach-Object { if ($_ -match "^(.*?)=(.*)$") { Set-Content "env:\$($matches[1])" $matches[2] } }
    # Testing / debugging only.
    #- dir c:\
    #- dir c:\qt
    #- $env:path.split(";")
    #- cmd.exe /c "set"
    #- Get-Location
  script:
    - perl tools/make-version.pl --set-release
    - mkdir build
    - cd build
    - cmake -G "Visual Studio 16 2019" -A x64 ..
    - msbuild "/consoleloggerparameters:PerformanceSummary;NoSummary" /maxcpucount Wireshark.sln
    - msbuild "/consoleloggerparameters:PerformanceSummary;NoSummary" test-programs.vcxproj
    - ctest -C RelWithDebInfo --parallel 3 --force-new-ctest-process --verbose