gitlab CI: use the ci-templates FreeBSD templates
[platform/upstream/libinput.git] / .gitlab-ci / meson-build.sh
1 #!/usr/bin/env bash
2
3 if [[ -f .meson_environment ]]; then
4         . .meson_environment
5 fi
6
7 if [[ -z "$MESON_BUILDDIR" ]]; then
8         echo "\$MESON_BUILDDIR undefined."
9         exit 1
10 fi
11
12 # emulate a few gitlab variables to make it easier to
13 # run and debug locally.
14 if [[ -z "$CI_JOB_ID" ]] || [[ -z "$CI_JOB_NAME" ]]; then
15         echo "Missing \$CI_JOB_ID or \$CI_JOB_NAME".
16         CI_JOB_ID=$(date +%s)
17         CI_JOB_NAME='libinput-job-local'
18         echo "Simulating gitlab environment: "
19         echo " CI_JOB_ID=$CI_JOB_ID"
20         echo " CI_JOB_NAME=$CI_JOB_NAME"
21 fi
22
23 if [[ -n "$FDO_CI_CONCURRENT" ]]; then
24         NINJA_ARGS="-j${FDO_CI_CONCURRENT} $NINJA_ARGS"
25 fi
26
27 echo "*************************************************"
28 echo "builddir: $MESON_BUILDDIR"
29 echo "meson args: $MESON_ARGS"
30 echo "ninja args: $NINJA_ARGS"
31 echo "meson test args: $MESON_TEST_ARGS"
32 echo "*************************************************"
33
34 set -e
35
36 rm -rf "$MESON_BUILDDIR"
37 meson "$MESON_BUILDDIR" $MESON_ARGS
38 meson configure "$MESON_BUILDDIR"
39 ninja -C "$MESON_BUILDDIR" $NINJA_ARGS
40
41 if [[ -z "$MESON_TEST_ARGS" ]]; then
42     exit 0
43 fi
44
45 # we still want to generate the reports, even if meson test fails
46 set +e
47 meson test -C "$MESON_BUILDDIR" $MESON_TEST_ARGS --print-errorlogs
48 exit_code=$?
49 set -e
50
51 # We need the glob for the testlog so that it picks up those suffixed by a
52 # suite (e.g. testlog-valgrind.json)
53 ./.gitlab-ci/meson-junit-report.py \
54         --project-name=libinput \
55         --job-id="$CI_JOB_ID" \
56         --output="$MESON_BUILDDIR/junit-$CI_JOB_NAME-report.xml" \
57         "$MESON_BUILDDIR"/meson-logs/testlog*.json; \
58
59 exit $exit_code