gr-satnogs/.gitlab-ci.yml

112 lines
3.7 KiB
YAML

variables:
GITLAB_CI_IMAGE_DEBIAN: 'debian:bullseye'
stages:
- style
- test
- build
- deploy
style:
image: ${GITLAB_CI_IMAGE_DEBIAN}
stage: style
before_script:
- apt-get update -qq && apt-get install -y -qq astyle git
script:
- if (test $(astyle --dry-run --options=.astylerc --formatted lib/*.cc | wc -l) -eq 0); then (exit 0); else (exit 1); fi
- if (test $(astyle --dry-run --options=.astylerc --formatted lib/*.h | wc -l) -eq 0); then (exit 0); else (exit 1); fi
- if (test $(astyle --dry-run --options=.astylerc --formatted include/satnogs/*.h | wc -l) -eq 0); then (exit 0); else (exit 1); fi
test:
image: ${GITLAB_CI_IMAGE_DEBIAN}
stage: test
before_script:
- apt-get update -qq && apt-get install -y -qq gnuradio-dev libboost-program-options-dev libjsoncpp-dev libpng++-dev libvorbis-dev cmake swig pkg-config build-essential git
script:
- mkdir -p build
- cd build
- cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr ..
- make
- make CTEST_OUTPUT_ON_FAILURE=1 test
- make install
- ldconfig
- python3 -c "import satnogs"
- rm -rf *
- cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DINCLUDE_DEBUG_BLOCKS=OFF -DCMAKE_INSTALL_PREFIX=/usr ..
- make
- make CTEST_OUTPUT_ON_FAILURE=1 test
- make install
- ldconfig
- python3 -c "import satnogs"
debian:
stage: build
image: ${GITLAB_CI_IMAGE_DEBIAN}
before_script:
- apt-get update
- apt-get install -y devscripts git-buildpackage
script:
- mk-build-deps -i -r -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y"
- PACKAGE_VERSION="$CI_COMMIT_TAG"
# Workaround for GitLab CI bug (see https://gitlab.com/gitlab-org/gitlab-ce/issues/61007)
# On issue fix, replace with:
# - PACKAGE_VERSION="${PACKAGE_VERSION:-$(git describe --abbrev=8 2>/dev/null | tr '-' '+' | cut -c '2-' || true)}"
- PACKAGE_VERSION="${PACKAGE_VERSION:-0.0+1+g$CI_COMMIT_SHORT_SHA}"
- PACKAGE_VERSION="${PACKAGE_VERSION#v}"
- |
[ -z "$PACKAGE_VERSION" ] || {
dch -b -M -v "${PACKAGE_VERSION}-1" "Bump to version '${PACKAGE_VERSION}-1'"
dch -r -m ""
}
- |
[ -n "$CI_COMMIT_TAG" ] || sed -i '/0001-remove-git-maint-version.patch/ d' debian/patches/series
- gbp buildpackage -us -uc --git-upstream-tag='HEAD' --git-ignore-branch --git-ignore-new
- mkdir artifacts
- cp -a ../*.{deb,debian.tar.xz,dsc,build,buildinfo,changes,orig.tar.gz} artifacts/
artifacts:
expire_in: 1 week
when: always
paths:
- artifacts
deploy:
stage: deploy
image: ${GITLAB_CI_IMAGE_DEBIAN}
before_script:
- apt-get update
- apt-get install -y osc
script:
- |
cat <<-EOF > ~/.oscrc
[general]
apiurl = https://api.opensuse.org
[https://api.opensuse.org]
user = $OBS_USER
pass = $OBS_PASS
EOF
- |
PROJECT="${CI_COMMIT_TAG:+home:librespace:satnogs}"
PROJECT="${PROJECT:-home:librespace:satnogs-unstable}"
BASE_DIR="$(pwd)"
OSC_WORKDIR="$BASE_DIR/osc_workdir"
ARTIFACTS_DIR="$BASE_DIR/artifacts"
DSC_FILENAME=$(basename $(ls "$ARTIFACTS_DIR"/*.dsc))
PACKAGE="${CI_COMMIT_TAG:+${DSC_FILENAME%.dsc}}"
PACKAGE="${PACKAGE:-${DSC_FILENAME%%_*}}"
mkdir -p "$OSC_WORKDIR"
cd "$OSC_WORKDIR"
[ -d "$PROJECT" ] || osc co "$PROJECT"
cd "$PROJECT"
[ -d "$PACKAGE" ] || osc mkpac "$PACKAGE"
rm -f "$PACKAGE"/*.{dsc,debian.tar.xz,orig.tar.gz}
cp -a "$ARTIFACTS_DIR"/*.{dsc,debian.tar.xz,orig.tar.gz} "$PACKAGE"
osc addremove -r
osc ci -m "$DSC_FILENAME"
cd "$BASE_DIR"
rm -r "$OSC_WORKDIR"
only:
refs:
- master
- tags
variables:
- $OBS_USER
- $OBS_PASS