summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: 1ef0ce30b51f8ba29555f7254fe7cce6cbbd7b66 (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
include:
  - project: 'freedesktop/ci-templates'
    ref: master
    file: '/templates/fedora.yml'

variables:
  FDO_DISTRIBUTION_TAG: latest
  FDO_DISTRIBUTION_VERSION: rawhide
  FDO_UPSTREAM_REPO: "upower/$CI_PROJECT_NAME"
  FEDORA_IMAGE: "$CI_REGISTRY/upower/$CI_PROJECT_NAME/fedora/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG"
  DEPENDENCIES:
    gtk-doc
    meson
    gettext-devel
    gcc
    redhat-rpm-config
    gcc-c++
    glibc-devel
    systemd
    sqlite-devel
    gobject-introspection-devel
    libgudev-devel
    libimobiledevice-devel
    glib2-devel
    libplist-devel
    umockdev
    dbus-x11
    python3-gobject
    python3-dbusmock
    python3-pip
    python3-packaging
    git
    clang
  LAST_ABI_BREAK: "9058d45685d1c7c08d52fb64c393fed9eeed542b"

workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
    - if: $CI_PIPELINE_SOURCE == 'push'

stages:
  - check-source
  - build
  - test
  - deploy

image: $FEDORA_IMAGE

test_nut_hwdb:
  stage: check-source
  except:
    variables:
      - $CI_PIPELINE_SOURCE == "schedule"
  allow_failure: true
  script:
    - curl https://raw.githubusercontent.com/networkupstools/nut/master/scripts/upower/95-upower-hid.hwdb >rules/95-upower-hid.hwdb
    - git diff
    - "! git status -s | grep -q ."

build:
  stage: build
  script:
    - meson _build -Dintrospection=enabled -Dman=true -Dgtk-doc=true -Didevice=enabled
    - ninja -C _build
  except:
    variables:
      - $CI_PIPELINE_SOURCE == "schedule"
  # avoid recompiling in test stage
  artifacts:
    name: untracked
    paths:
     - "${CI_PROJECT_DIR}"
    expire_in: 3h30min


# Compile test the other backends (they don't have extra dependencies currently)
.build_backend_template: &build_backend
  stage: build
  script:
    - CFLAGS=-DUPOWER_CI_DISABLE_PLATFORM_CODE=1 meson _build -Dos_backend=$backend
    - ninja -C _build
  except:
    variables:
      - $CI_PIPELINE_SOURCE == "schedule"

build_dummy:
  variables:
    backend: dummy
  <<: *build_backend

build_freebsd:
  variables:
    backend: freebsd
  <<: *build_backend

build_openbsd:
  variables:
    backend: openbsd
  <<: *build_backend

test:
  stage: test
  dependencies:
   - build
  before_script:
    - git clone https://github.com/zatrazz/glibc-tools.git
    - cd glibc-tools
    - ./configure
    - make install
    - cd ..
    - git clone https://github.com/martinpitt/umockdev.git
    - cd umockdev
    - dnf install -y 'dnf-command(builddep)'
    - dnf builddep -y umockdev
    - meson _build -Dprefix=/usr
    - ninja -C _build install
    - cd ..
  script:
    - meson _build -Dintrospection=enabled -Dman=true -Dgtk-doc=true -Didevice=enabled
    - ninja -C _build
    - catchsegv meson test -C _build --print-errorlogs --no-stdsplit
    - .ci/fail_skipped_tests.py _build/meson-logs/testlog.junit.xml

  artifacts:
    when: always
    expire_in: 1 week
    paths:
      - "${CI_PROJECT_DIR}/_build/meson-logs/"
  except:
    variables:
      - $CI_PIPELINE_SOURCE == "schedule"

check_abi:
  stage: test
  script:
    - check-abi --suppr .ci/upower.suppr --parameters="-Dman=false -Dgtk-doc=false -Didevice=enabled"  ${LAST_ABI_BREAK} $(git rev-parse HEAD)
  except:
    variables:
      - $CI_PIPELINE_SOURCE == "schedule"

# Create docs artifact for the website.
# Note that the last successful artifact build is always kept, so 1 day as
# expiry is completely fine.
docs:
  stage: deploy
  dependencies:
   - build
  script:
    - meson _build -Dintrospection=enabled -Dman=true -Dgtk-doc=true -Didevice=enabled
    - ninja -C _build/ UPower-doc
  artifacts:
    name: "docs"
    when: always
    expire_in: 1 day
    paths:
      - "_build/doc/html"
  only:
    - master
  except:
    variables:
      - $CI_PIPELINE_SOURCE == "schedule"

# CONTAINERS creation stage
container_fedora_build:
  extends: .fdo.container-build@fedora
  only:
    variables:
      - $CI_PIPELINE_SOURCE == "schedule" && $CRON_TASK == "BUILD_CI_IMAGES"
  variables:
    GIT_STRATEGY: none # no need to pull the whole tree for rebuilding the image
    FDO_FORCE_REBUILD: 1
    # a list of packages to install
    FDO_DISTRIBUTION_PACKAGES:
      $DEPENDENCIES
    FDO_DISTRIBUTION_EXEC: |
      curl https://gitlab.freedesktop.org/hadess/check-abi/-/raw/main/contrib/check-abi-fedora.sh | bash