Simplify travis setup even more: deploy in gocd
Fixes https://github.com/openSUSE/openSUSE-release-tools/pull/2000
This commit is contained in:
parent
fbd1bbd4e2
commit
227e3ad0a8
46
.travis.yml
46
.travis.yml
@ -1,49 +1,11 @@
|
|||||||
addons:
|
language: bash
|
||||||
apt:
|
services:
|
||||||
packages:
|
|
||||||
# Used by dist/ci/docker-run.
|
|
||||||
- realpath
|
|
||||||
|
|
||||||
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
|
- docker
|
||||||
script:
|
|
||||||
|
script:
|
||||||
- docker-compose -f dist/ci/docker-compose.yml run flaker
|
- 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
|
- 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
|
- 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
|
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email:
|
email:
|
||||||
|
29
dist/ci/Dockerfile
vendored
29
dist/ci/Dockerfile
vendored
@ -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 <jberry@suse.com>
|
|
||||||
|
|
||||||
# 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/
|
|
53
dist/ci/docker-compose-obs
vendored
53
dist/ci/docker-compose-obs
vendored
@ -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 <<EOF >> ~/.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
|
|
17
dist/ci/docker-run
vendored
17
dist/ci/docker-run
vendored
@ -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}"
|
|
26
dist/ci/obs-build-target
vendored
26
dist/ci/obs-build-target
vendored
@ -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|<param name=\"scm\">git</param>|<param name=\"scm\">git</param><param name=\"revision\">$(cd "$SOURCE_DIR" && git describe --all --always)</param>|" _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"
|
|
22
dist/ci/obs-deploy
vendored
22
dist/ci/obs-deploy
vendored
@ -1,9 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
osc-init
|
set -ex
|
||||||
|
|
||||||
osc checkout "$OBS_PACKAGE"
|
osc checkout "$OBS_PROJECT" "$OBS_PACKAGE"
|
||||||
cd "$OBS_PACKAGE"
|
cd "$OBS_PROJECT/$OBS_PACKAGE"
|
||||||
|
|
||||||
rm *.obscpio
|
rm *.obscpio
|
||||||
osc service disabledrun
|
osc service disabledrun
|
||||||
@ -22,9 +22,17 @@ else
|
|||||||
osc revert .
|
osc revert .
|
||||||
fi
|
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.
|
# 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..."
|
echo "checking for existing requests to $OBS_TARGET_PROJECT/$OBS_TARGET_PACKAGE..."
|
||||||
# `osc request list` is wholly inadequate for the task. :(
|
# `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'" |
|
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
|
osc service wait
|
||||||
# Only bother making a request if there is a diff (always 6 lines since
|
# Only bother making a request if there is a diff (always 6 lines since
|
||||||
# binary source tarball dates changed after local run).
|
# 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"
|
echo "-> creating request"
|
||||||
cat temp.diff
|
cat temp.diff
|
||||||
rm temp.diff
|
rm temp.diff
|
||||||
osc sr --yes -m "automatic update"
|
osc sr --yes -m "automatic update" $OBS_TARGET_PROJECT $OBS_TARGET_PACKAGE
|
||||||
else
|
else
|
||||||
echo "-> no difference (likely cron job)"
|
echo "-> no difference (likely cron job)"
|
||||||
fi
|
fi
|
||||||
|
4
dist/ci/osc-credentials-throwaway
vendored
4
dist/ci/osc-credentials-throwaway
vendored
@ -1,4 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
echo 'user="opensuse-releaseteam-travis"'
|
|
||||||
echo 'pass="G1fggGJLsVGPZMLTq0ht0Bqh7wEIAXkSZWcHkRIP"'
|
|
19
gocd/update.osrt.gocd.yaml
Normal file
19
gocd/update.osrt.gocd.yaml
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user