Skip to content

Commit a8aa18b

Browse files
committed
travis: automatically build csdiff in Fedora Copr
Builds after pushes go to [1], builds for pull-request to [2]. [1] https://copr.fedorainfracloud.org/coprs/g/codescan/csdiff/ [2] https://copr.fedorainfracloud.org/coprs/g/codescan/csdiff-pull-requests/
1 parent d9b4cee commit a8aa18b

File tree

5 files changed

+107
-1
lines changed

5 files changed

+107
-1
lines changed

.travis.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ matrix:
1515
- name: "Ubuntu LTS 2020 (focal)"
1616
dist: focal
1717

18+
- name: "Fedora Copr build"
19+
dist: focal
20+
env:
21+
- COPR_BUILD=yes
22+
1823
install:
1924
- sudo apt-get install cmake help2man libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev
2025

2126
script:
22-
- make distcheck
27+
- if test -z "$COPR_BUILD"; then make distcheck; else ./.travis/copr-build ; fi

.travis/README

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Scripts in this directory
2+
-------------------------
3+
4+
copr-build
5+
This script is executed from the .travis.yml 'script' statement.
6+
7+
copr-build-setup
8+
Use this script to configure the remote copr project, it uploads the
9+
'copr-custom-script' to appropriate Copr project. Execute it like:
10+
$ ./copr-custom-script PR
11+
$ ./copr-custom-script PUSH
12+
.. depending on which webhook/project you want to setup.
13+
14+
copr-custom-script
15+
This script is used in Copr to build the package from the remote git
16+
repository.

.travis/copr-build

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#! /bin/bash -x
2+
3+
# Trigger the build in Copr (from .travis.yml)
4+
5+
set -e
6+
curl -o copr-build https://raw.githubusercontent.com/praiskup/copr-ci-tooling/master/copr-travis-submit
7+
export COPR_PR_WEBHOOK="https://copr.fedorainfracloud.org/webhooks/custom/46962/a72fe511-c141-4f27-b7cf-de03c065e64e/csdiff/"
8+
exec bash copr-build

.travis/copr-build-setup

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#! /bin/bash -x
2+
3+
# Helper script to update CI scripting on Copr side
4+
5+
script=$(readlink -f "$(dirname "$0")")/copr-custom-script
6+
7+
PROJECT_PR=@codescan/csdiff-pull-requests
8+
PROJECT_PUSH=@codescan/csdiff
9+
10+
project=
11+
case $1 in
12+
PR|'') project=$PROJECT_PR ;;
13+
PUSH) project=$PROJECT_PUSH ;;
14+
esac
15+
16+
build_deps=(
17+
boost-devel
18+
boost-python3-devel
19+
bsdtar
20+
cmake
21+
coreutils
22+
gcc-c++
23+
git
24+
help2man
25+
make
26+
python3-devel
27+
)
28+
29+
copr_cmd=(
30+
copr edit-package-custom "$project" \
31+
--webhook-rebuild on \
32+
--script "$script" \
33+
--script-chroot "fedora-latest-x86_64" \
34+
--script-builddeps "${build_deps[*]}"
35+
)
36+
37+
if test "$1" != PUSH; then
38+
copr_cmd+=( --max-builds 10 )
39+
fi
40+
41+
42+
"${copr_cmd[@]}" --name csdiff --script-resultdir srpm_results

.travis/copr-custom-script

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#! /bin/bash -x
2+
3+
set -e
4+
set -o pipefail
5+
6+
clone_url_parent=https://github.com/kdudka/csdiff.git
7+
8+
workdir=$(basename "$clone_url_parent")
9+
workdir=${workdir%%.git}
10+
11+
hook_payload=$(readlink -f "${HOOK_PAYLOAD-hook_payload}")
12+
13+
mkdir -p "$COPR_RESULTDIR"
14+
resultdir=$(readlink -f "$COPR_RESULTDIR")
15+
16+
# clone the helper scripts when needed, and add to PATH
17+
test -d copr-ci-tooling \
18+
|| git clone --depth 1 https://github.com/praiskup/copr-ci-tooling.git
19+
export PATH="$PWD/copr-ci-tooling:$PATH"
20+
21+
# clone the tested project
22+
git clone \
23+
--recursive \
24+
--no-single-branch \
25+
"$clone_url_parent"
26+
27+
# checkout requested revision
28+
cd "$workdir"
29+
30+
copr-travis-checkout "$hook_payload"
31+
32+
./make-srpm.sh |& tee srpm-build.log
33+
srpm=$(grep Wrote: srpm-build.log | cut -d' ' -f2)
34+
cd "$resultdir"
35+
bsdtar -xf "$srpm"

0 commit comments

Comments
 (0)