.gitlab-ci.yml 4.67 KB
Newer Older
Guillaume Desmottes's avatar
Guillaume Desmottes committed
1
2
3
4
5
6
7
8
.templates_sha: &templates_sha 79c325922670137e8f0a4dc5f6f097e0eb57c1af

include:
  - project: 'freedesktop/ci-templates'
    ref: *templates_sha
    file: '/templates/debian.yml'

variables:
Zeeshan Ali's avatar
Zeeshan Ali committed
9
  FDO_UPSTREAM_REPO: dbus/zbus
Guillaume Desmottes's avatar
Guillaume Desmottes committed
10

Zeeshan Ali's avatar
Add CI  
Zeeshan Ali committed
11
stages:
Guillaume Desmottes's avatar
Guillaume Desmottes committed
12
  - container
Zeeshan Ali's avatar
Zeeshan Ali committed
13
  - lint
Zeeshan Ali's avatar
Add CI  
Zeeshan Ali committed
14
  - test
Guillaume Desmottes's avatar
Guillaume Desmottes committed
15
  - extras
16
  - crosscheck
17
  - pages
Zeeshan Ali's avatar
Add CI  
Zeeshan Ali committed
18

Guillaume Desmottes's avatar
Guillaume Desmottes committed
19
20
21
.debian:
  variables:
    # Update this tag when you want to trigger a rebuild
Marc-André Lureau's avatar
Marc-André Lureau committed
22
    FDO_DISTRIBUTION_TAG: '2021-06-07.2'
Guillaume Desmottes's avatar
Guillaume Desmottes committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
    # Uncomment if you want to always rebuild the container, useful when hacking on it
    #FDO_FORCE_REBUILD: 1
    FDO_DISTRIBUTION_VERSION: 10
    FDO_DISTRIBUTION_PACKAGES: >-
      git
      wget
      ca-certificates
      build-essential
      libssl-dev
      dbus
      libglib2.0-dev
      pkg-config
      lcov
      python3-pip
      python3-setuptools
    FDO_DISTRIBUTION_EXEC: >-
      gitlab/install-rust.sh stable &&
Marc-André Lureau's avatar
Marc-André Lureau committed
40
41
      pip3 install lcov_cobertura &&
      pip3 install codespell
Guillaume Desmottes's avatar
Guillaume Desmottes committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  before_script:
    - source ./gitlab/env.sh
    - mkdir .cargo && echo -e "[net]\ngit-fetch-with-cli = true" > .cargo/config
    # If cargo exists assume we probably will want to update
    # the lockfile
    - |
      if command -v cargo; then
        cargo generate-lockfile --color=always
        cargo update --color=always
      fi

container:
  extends:
    - .debian
    - .fdo.container-build@debian
  stage: container

.debian_img:
  extends:
    - .debian
    - .fdo.distribution-image@debian
Zeeshan Ali's avatar
Add CI  
Zeeshan Ali committed
63

Zeeshan Ali's avatar
Zeeshan Ali committed
64
check:
Guillaume Desmottes's avatar
Guillaume Desmottes committed
65
  extends: .debian_img
Zeeshan Ali's avatar
Zeeshan Ali committed
66
  stage: "lint"
67
68
  variables:
    RUSTFLAGS: "-D warnings"
Zeeshan Ali's avatar
Zeeshan Ali committed
69
70
71
72
  script:
    - rustc --version
    - cargo --version
    - cargo fmt --all -- --check
73
    - cargo clippy -- -D warnings -Aclippy::upper_case_acronyms
74
    - cargo audit
Marc-André Lureau's avatar
Marc-André Lureau committed
75
    - codespell
Zeeshan Ali's avatar
Zeeshan Ali committed
76

Guillaume Desmottes's avatar
Guillaume Desmottes committed
77
.cargo_test_var: &cargo_test
Zeeshan Ali's avatar
Add CI  
Zeeshan Ali committed
78
79
80
    - rustc --version
    - cargo --version
    - mkdir -p /run/user/$UID
81
82
    - sed -e s/UID/$UID/ -e s/PATH/path/ gitlab/dbus-session.conf > /tmp/dbus-session.conf
    - sed -e s/UID/$UID/ -e s/PATH/abstract/ gitlab/dbus-session.conf > /tmp/dbus-session-abstract.conf
83
    - dbus-run-session --config-file /tmp/dbus-session-abstract.conf -- cargo test --verbose -- basic_connection
84
    - dbus-run-session --config-file /tmp/dbus-session.conf -- cargo test --verbose --all-features -- --skip fdpass_systemd
85
86
87
    # check cookie-sha1 auth against dbus-daemon
    - sed -i s/EXTERNAL/DBUS_COOKIE_SHA1/g /tmp/dbus-session.conf
    - dbus-run-session --config-file /tmp/dbus-session.conf -- cargo test --verbose -- basic_connection
Zeeshan Ali's avatar
Zeeshan Ali committed
88
89
90
    # Test external executor (currently only 2 tests can handle it so only run those)
    - dbus-run-session --config-file /tmp/dbus-session.conf -- cargo test --verbose --package zbus --no-default-features fdo::tests::signal_stream
    - dbus-run-session --config-file /tmp/dbus-session.conf -- cargo test --verbose --doc --no-default-features azync::connection::Connection::executor
Zeeshan Ali's avatar
Add CI  
Zeeshan Ali committed
91

Guillaume Desmottes's avatar
Guillaume Desmottes committed
92
test:
Guillaume Desmottes's avatar
Guillaume Desmottes committed
93
  extends: .debian_img
Guillaume Desmottes's avatar
Guillaume Desmottes committed
94
  stage: test
95
96
  variables:
    RUSTFLAGS: "-D warnings"
Guillaume Desmottes's avatar
Guillaume Desmottes committed
97
  script:
Guillaume Desmottes's avatar
Guillaume Desmottes committed
98
    - rustup override set stable
Guillaume Desmottes's avatar
Guillaume Desmottes committed
99
100
    - *cargo_test

101
102
103
104
105
106
107
108
109
110
nightly:
  extends: .debian_img
  stage: test
  allow_failure: true
  variables:
    RUSTFLAGS: "-D warnings"
  script:
    - rustup override set nightly
    - *cargo_test
    - cargo fmt --all -- --check
Jonas Platte's avatar
Jonas Platte committed
111
    - cargo clippy --tests -- -D warnings -Aclippy::upper_case_acronyms
112

Guillaume Desmottes's avatar
Guillaume Desmottes committed
113
coverage:
Guillaume Desmottes's avatar
Guillaume Desmottes committed
114
  extends: .debian_img
Guillaume Desmottes's avatar
Guillaume Desmottes committed
115
116
117
118
119
  stage: extras
  variables:
    RUSTFLAGS: "-Zinstrument-coverage"
    LLVM_PROFILE_FILE: "zbus-%p-%m.profraw"
  script:
Guillaume Desmottes's avatar
Guillaume Desmottes committed
120
    - rustup override set nightly
Guillaume Desmottes's avatar
Guillaume Desmottes committed
121
122
123
124
125
126
127
128
129
    - *cargo_test
    # generate html report
    - grcov . --binary-path ./target/debug/ -s . -t html --branch --ignore-not-existing --ignore "*cargo*" -o ./coverage/
    # generate cobertura report for gitlab integration
    - grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "*cargo*" -o coverage.lcov
    - python3 /usr/local/lib/python3.5/dist-packages/lcov_cobertura.py coverage.lcov
    # output coverage summary for gitlab parsing
    - lcov -l coverage.lcov
    - lcov --summary coverage.lcov
130
  when: manual
Guillaume Desmottes's avatar
Guillaume Desmottes committed
131
132
133
134
135
136
  artifacts:
    paths:
      - 'coverage'
    reports:
      cobertura: coverage.xml

137
crosscheck:
138
  extends: .debian_img
139
140
141
142
143
144
  stage: crosscheck
  script:
    - cargo check --target x86_64-apple-darwin
    - cargo check --target x86_64-unknown-freebsd
    - cargo check --target x86_64-unknown-netbsd

145
pages:
146
  image: "hrektts/mdbook"
147
  stage: pages
148
149
150
  before_script:
    - export PATH="$PATH:$CARGO_HOME/bin"
    - mdbook --version || cargo install --debug mdbook
151
  script:
152
    - mkdir -p public/1.0
153
    - mdbook build book
154
    - mdbook build book-1.0
155
    - cp -r ./book/book/* ./public
156
    - cp -r ./book-1.0/book/* ./public/1.0/
157
158
159
160
161
162
163
    - find $PWD/public | grep "\.html\$"

  artifacts:
    paths:
      - public

  only:
164
    refs:
165
      - main
166
167
    changes:
      - book/**/*