From 227e3ad0a8f12c0f769ed47b21e834dedbe4fb5e Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Sat, 11 May 2019 08:24:17 +0200 Subject: [PATCH] Simplify travis setup even more: deploy in gocd Fixes https://github.com/openSUSE/openSUSE-release-tools/pull/2000 --- .travis.yml | 52 ++++-------------------------- dist/ci/Dockerfile | 29 ----------------- dist/ci/docker-compose-obs | 53 ------------------------------- dist/ci/docker-run | 17 ---------- dist/ci/obs-build-target | 26 --------------- dist/ci/obs-deploy | 22 +++++++++---- dist/ci/osc-credentials-throwaway | 4 --- gocd/update.osrt.gocd.yaml | 19 +++++++++++ 8 files changed, 41 insertions(+), 181 deletions(-) delete mode 100644 dist/ci/Dockerfile delete mode 100755 dist/ci/docker-compose-obs delete mode 100755 dist/ci/docker-run delete mode 100755 dist/ci/obs-build-target delete mode 100755 dist/ci/osc-credentials-throwaway create mode 100644 gocd/update.osrt.gocd.yaml diff --git a/.travis.yml b/.travis.yml index 45147c31..01f066f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,49 +1,11 @@ -addons: - apt: - packages: - # Used by dist/ci/docker-run. - - realpath +language: bash +services: + - docker -env: - global: - - OBS_PACKAGE="openSUSE:Tools/openSUSE-release-tools" - - OBS_USER="jberry" - # OBS_PASS - - secure: "0MI2ZbJ+C1FoOa+rBYq3+NQBoQzE528B1mNacZx5xaH6IipFklW9TlCUSO91Pgf2l72HzNL5GhBbYGtAO9og0tyJO9Vm+7F+AUNQHQjfD46r1MyxBlACi6FGwuR+E32OIFilekJCnNKp55Cl5O2wGWUcRRVlM6/+k24dt3lkIoY=" - - OBS_EMAIL="opensuse-releaseteam@opensuse.org" - -matrix: - include: - - env: TEST_SUITE=nosetests - language: bash - services: - - docker - script: - - docker-compose -f dist/ci/docker-compose.yml run flaker - - for var in TRAVIS_BRANCH TRAVIS_JOB_ID TRAVIS_PULL_REQUEST; do echo "$var=${!var}"; done > travis.settings - - docker-compose -f dist/ci/docker-compose.yml run test - after_success: - - coveralls - -deploy: - provider: script - script: ./dist/ci/docker-run obs-deploy - on: - branch: master - condition: $TEST_SUITE = nosetests - -cache: - directories: - # obs_clone.py - - ~/.cache/openSUSE-release-tools/request/clone - # distribution jobs `osc build` - - .docker-tmp - pip: true - # 7 days - timeout: 604800 -before_cache: - - sudo rm -rf .docker-tmp/build-root - - sudo chmod -R o+rw .docker-tmp +script: + - docker-compose -f dist/ci/docker-compose.yml run flaker + - for var in TRAVIS_BRANCH TRAVIS_JOB_ID TRAVIS_PULL_REQUEST; do echo "$var=${!var}"; done > travis.settings + - docker-compose -f dist/ci/docker-compose.yml run test notifications: email: diff --git a/dist/ci/Dockerfile b/dist/ci/Dockerfile deleted file mode 100644 index 13ae0bf2..00000000 --- a/dist/ci/Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -# https://docs.docker.com/engine/reference/builder/ -# Used for TEST_SUITE=distribution and deployment to OBS. - -FROM opensuse/leap -MAINTAINER Jimmy Berry - -# https://github.com/openSUSE/obs-service-set_version/issues/44 python-packaging -# git for extracting remote, but a more generalized approach would be nice -RUN zypper -n ref && zypper -n dup && zypper -n install \ - build \ - git \ - obs-service-* \ - osc \ - python-packaging \ - sudo - -# `osc build` directories that are effective to cache: -# - /var/tmp/build-root -# - /var/tmp/osbuild-packagecache -VOLUME /var/tmp - -WORKDIR /usr/src -RUN mkdir -p /usr/src/target -COPY . /usr/src/target - -# Already included in target, but simulate separate container image. -ADD dist/ci/obs-build-target /usr/bin/ -ADD dist/ci/obs-deploy /usr/bin/ -ADD dist/ci/osc-init /usr/bin/ diff --git a/dist/ci/docker-compose-obs b/dist/ci/docker-compose-obs deleted file mode 100755 index 0706a71f..00000000 --- a/dist/ci/docker-compose-obs +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -set -e - -OBS_DIRECTORY=${OBS_DIRECTORY:-.open-build-service} - -if [ ! -d "$OBS_DIRECTORY" ] ; then - git clone --depth 1 https://github.com/openSUSE/open-build-service.git "$OBS_DIRECTORY" - - if [ ! -f ~/.oscrc ] ; then - # openSUSE/open-build-service#3946: would elevate the need, but rejected. - eval $(./dist/ci/osc-credentials-throwaway) - OBS_USER="$user" OBS_PASS="$pass" ./dist/ci/osc-init - fi - -cat <> ~/.oscrc - -[http://0.0.0.0:3000] -user = Admin -pass = opensuse -aliases = local -EOF -fi - -cd "$OBS_DIRECTORY" - -git pull origin master - -# https://github.com/openSUSE/open-build-service/blob/master/CONTRIBUTING.md -git submodule init -git submodule update - -rake docker:build - -# See `docker-compose logs` instead of changing output redirection. -docker-compose up -d --remove-orphans - -osc='osc' -if ! which osc &> /dev/null ; then - # Workaround for pip install that occurs on travis. - osc='osc-wrapper.py' -fi - -until $osc -q -A local api /about 2> /dev/null ; do - echo "waiting for OBS to be responsive..." - # Print osc output incase of failure and container logs for debugging. - ((c++)) && ((c==60)) && ( - docker-compose logs - $osc -q -A local api /about - exit 1 - ) - sleep 1 -done diff --git a/dist/ci/docker-run b/dist/ci/docker-run deleted file mode 100755 index 357ef65f..00000000 --- a/dist/ci/docker-run +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -if [ "$TRAVIS_PULL_REQUEST" == "false" ] ; then - eval $(./dist/ci/osc-credentials) -else - # openSUSE/open-build-service#3946: would elevate the need, but rejected. - eval $(./dist/ci/osc-credentials-throwaway) -fi - -docker run --privileged --rm -it \ - -v "$(realpath .)/.docker-tmp:/var/tmp" \ - -e OBS_API="${apiurl:-$OBS_API}" \ - -e OBS_USER="${user:-$OBS_USER}" \ - -e OBS_PASS="${pass:-$OBS_PASS}" \ - -e OBS_EMAIL="${email:-$OBS_EMAIL}" \ - -e OBS_PACKAGE="${OBS_PACKAGE:-openSUSE:Tools/openSUSE-release-tools}" \ - spec "${1:-obs-build-target}" "${2:-openSUSE_Factory}" diff --git a/dist/ci/obs-build-target b/dist/ci/obs-build-target deleted file mode 100755 index 8e0208b6..00000000 --- a/dist/ci/obs-build-target +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -set -ex - -SOURCE_DIR="${SOURCE_DIR:-/usr/src/target}" - -repo="${1:-openSUSE_Tumbleweed}" -arch="${2:-x86_64}" - -osc-init - -osc checkout "$OBS_PACKAGE" -cd "$OBS_PACKAGE" - -# point _service file to SOURCE_DIR instead of remote -sed -i "s|$(cd "$SOURCE_DIR" && git remote get-url origin)|$SOURCE_DIR|" _service -sed -i "s|git|git$(cd "$SOURCE_DIR" && git describe --all --always)|" _service - -rm *.obscpio -# ugly, but upstream not interested in making this process clean -export TAR_SCM_TESTMODE=1 -osc service disabledrun - -# skip interactive -osc diff | cat - -osc build --trust-all-projects --no-verify "$repo" "$arch" diff --git a/dist/ci/obs-deploy b/dist/ci/obs-deploy index 57198c72..4c6054e7 100755 --- a/dist/ci/obs-deploy +++ b/dist/ci/obs-deploy @@ -1,9 +1,9 @@ #!/bin/bash -osc-init +set -ex -osc checkout "$OBS_PACKAGE" -cd "$OBS_PACKAGE" +osc checkout "$OBS_PROJECT" "$OBS_PACKAGE" +cd "$OBS_PROJECT/$OBS_PACKAGE" rm *.obscpio osc service disabledrun @@ -22,9 +22,17 @@ else osc revert . fi +if test -z "$OBS_TARGET_PROJECT"; then + OBS_TARGET_PROJECT="$(osc info | grep -oP "Link info:.*?project \K[^\s,]+")" +fi +if test -z "$OBS_TARGET_PACKAGE"; then + OBS_TARGET_PACKAGE="$(osc info | grep -oP "Link info:.*?, package \K[^\s,]+")" + if test -z "$OBS_TARGET_PACKAGE"; then + OBS_TARGET_PACKAGE=$OBS_PACKAGE + fi +fi + # Create submit request if none currently exists. -OBS_TARGET_PROJECT="$(osc info | grep -oP "Link info:.*?project \K[^\s,]+")" -OBS_TARGET_PACKAGE="$(osc info | grep -oP "Link info:.*?, package \K[^\s,]+")" echo "checking for existing requests to $OBS_TARGET_PROJECT/$OBS_TARGET_PACKAGE..." # `osc request list` is wholly inadequate for the task. :( if osc api "/search/request?match=(state/@name='declined'+or+state/@name='new'+or+state/@name='review')+and+action/target/@project='$OBS_TARGET_PROJECT'+and+action/target/@package='$OBS_TARGET_PACKAGE'" | @@ -32,11 +40,11 @@ if osc api "/search/request?match=(state/@name='declined'+or+state/@name='new'+o osc service wait # Only bother making a request if there is a diff (always 6 lines since # binary source tarball dates changed after local run). - if [ "$(osc sr --diff | tee temp.diff | wc -l)" -gt 6 ] ; then + if [ "$(osc sr --diff $OBS_TARGET_PROJECT $OBS_TARGET_PACKAGE | tee temp.diff | wc -l)" -gt 6 ] ; then echo "-> creating request" cat temp.diff rm temp.diff - osc sr --yes -m "automatic update" + osc sr --yes -m "automatic update" $OBS_TARGET_PROJECT $OBS_TARGET_PACKAGE else echo "-> no difference (likely cron job)" fi diff --git a/dist/ci/osc-credentials-throwaway b/dist/ci/osc-credentials-throwaway deleted file mode 100755 index ba59936d..00000000 --- a/dist/ci/osc-credentials-throwaway +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -echo 'user="opensuse-releaseteam-travis"' -echo 'pass="G1fggGJLsVGPZMLTq0ht0Bqh7wEIAXkSZWcHkRIP"' diff --git a/gocd/update.osrt.gocd.yaml b/gocd/update.osrt.gocd.yaml new file mode 100644 index 00000000..a87800d5 --- /dev/null +++ b/gocd/update.osrt.gocd.yaml @@ -0,0 +1,19 @@ +format_version: 3 +pipelines: + Update.Package.OSRT: + group: Admin + environment_variables: + OSC_CONFIG: /home/go/config/oscrc-staging-bot + OBS_PROJECT: openSUSE:Tools + OBS_PACKAGE: openSUSE-release-tools + OBS_TARGET_PROJECT: openSUSE:Factory + OBS_TARGET_PACKAGE: openSUSE-release-tools + materials: + git: + git: https://github.com/openSUSE/opensuse-release-tools.git + stages: + - obs-deploy: + resources: + - leaper + tasks: + - script: ./dist/ci/obs-deploy