Skip to content
Snippets Groups Projects
Commit 8f921da2 authored by Marcin Ślusarz's avatar Marcin Ślusarz
Browse files

common: introduce GITHUB_REPO and DOCKERHUB_REPO on Travis

Will be needed by #3436.
parent 8abded23
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,8 @@ env: ...@@ -35,6 +35,8 @@ env:
before_install: before_install:
- echo $TRAVIS_COMMIT_RANGE - echo $TRAVIS_COMMIT_RANGE
- export HOST_WORKDIR=`pwd` - export HOST_WORKDIR=`pwd`
- export GITHUB_REPO=pmem/pmdk
- export DOCKERHUB_REPO=pmem/pmdk
- cd utils/docker - cd utils/docker
- ./pull-or-rebuild-image.sh - ./pull-or-rebuild-image.sh
- if [[ -f push_image_to_repo_flag ]]; then PUSH_THE_IMAGE=1; fi - if [[ -f push_image_to_repo_flag ]]; then PUSH_THE_IMAGE=1; fi
......
#!/usr/bin/env bash #!/usr/bin/env bash
# #
# Copyright 2016-2018, Intel Corporation # Copyright 2016-2019, Intel Corporation
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
...@@ -38,10 +38,10 @@ ...@@ -38,10 +38,10 @@
# usage: ./check-commit.sh # usage: ./check-commit.sh
# #
if [[ $TRAVIS_REPO_SLUG != "pmem/pmdk" \ if [[ $TRAVIS_REPO_SLUG != "$GITHUB_REPO" \
|| $TRAVIS_EVENT_TYPE != "pull_request" ]]; || $TRAVIS_EVENT_TYPE != "pull_request" ]];
then then
echo "SKIP: $0 can only be executed for pull requests to pmem/pmdk" echo "SKIP: $0 can only be executed for pull requests to $GITHUB_REPO"
exit 0 exit 0
fi fi
......
#!/usr/bin/env bash #!/usr/bin/env bash
# #
# Copyright 2016-2017, Intel Corporation # Copyright 2016-2019, Intel Corporation
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
...@@ -46,10 +46,10 @@ if [[ -z "$TRAVIS" ]]; then ...@@ -46,10 +46,10 @@ if [[ -z "$TRAVIS" ]]; then
exit 1 exit 1
fi fi
if [[ $TRAVIS_REPO_SLUG != "pmem/pmdk" \ if [[ $TRAVIS_REPO_SLUG != "$GITHUB_REPO" \
|| $TRAVIS_EVENT_TYPE != "pull_request" ]]; || $TRAVIS_EVENT_TYPE != "pull_request" ]];
then then
echo "SKIP: $0 can only be executed for pull requests to pmem/pmdk" echo "SKIP: $0 can only be executed for pull requests to ${GITHUB_REPO}"
exit 0 exit 0
fi fi
......
...@@ -62,7 +62,8 @@ export PMDK_CC=${PMDK_CC:-gcc} ...@@ -62,7 +62,8 @@ export PMDK_CC=${PMDK_CC:-gcc}
export PMDK_CXX=${PMDK_CXX:-g++} export PMDK_CXX=${PMDK_CXX:-g++}
export EXPERIMENTAL=${EXPERIMENTAL:-n} export EXPERIMENTAL=${EXPERIMENTAL:-n}
export VALGRIND=${VALGRIND:-1} export VALGRIND=${VALGRIND:-1}
export DOCKERHUB_REPO=${DOCKERHUB_REPO:-pmem/pmdk}
export GITHUB_REPO=${GITHUB_REPO:-pmem/pmdk}
if [[ -z "$OS" || -z "$OS_VER" ]]; then if [[ -z "$OS" || -z "$OS_VER" ]]; then
echo "ERROR: The variables OS and OS_VER have to be set " \ echo "ERROR: The variables OS and OS_VER have to be set " \
...@@ -78,7 +79,7 @@ if [[ "$KEEP_CONTAINER" != "1" ]]; then ...@@ -78,7 +79,7 @@ if [[ "$KEEP_CONTAINER" != "1" ]]; then
RM_SETTING=" --rm" RM_SETTING=" --rm"
fi fi
imageName=pmem/pmdk:1.5-${OS}-${OS_VER} imageName=${DOCKERHUB_REPO}:1.5-${OS}-${OS_VER}
containerName=pmdk-${OS}-${OS_VER} containerName=pmdk-${OS}-${OS_VER}
if [[ $MAKE_PKG -eq 1 ]] ; then if [[ $MAKE_PKG -eq 1 ]] ; then
......
...@@ -69,7 +69,7 @@ if [[ -z "$TEST_BUILD" ]]; then ...@@ -69,7 +69,7 @@ if [[ -z "$TEST_BUILD" ]]; then
TEST_BUILD=all TEST_BUILD=all
fi fi
imageName=pmem/pmdk:1.5-${OS}-${OS_VER} imageName=${DOCKERHUB_REPO}:1.5-${OS}-${OS_VER}
containerName=pmdk-${OS}-${OS_VER} containerName=pmdk-${OS}-${OS_VER}
if [[ $MAKE_PKG -eq 0 ]] ; then command="./run-build.sh"; fi if [[ $MAKE_PKG -eq 0 ]] ; then command="./run-build.sh"; fi
...@@ -116,6 +116,7 @@ docker run --rm --privileged=true --name=$containerName -ti \ ...@@ -116,6 +116,7 @@ docker run --rm --privileged=true --name=$containerName -ti \
--env TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \ --env TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \
--env COVERITY_SCAN_TOKEN=$COVERITY_SCAN_TOKEN \ --env COVERITY_SCAN_TOKEN=$COVERITY_SCAN_TOKEN \
--env COVERITY_SCAN_NOTIFICATION_EMAIL=$COVERITY_SCAN_NOTIFICATION_EMAIL \ --env COVERITY_SCAN_NOTIFICATION_EMAIL=$COVERITY_SCAN_NOTIFICATION_EMAIL \
--env GITHUB_REPO=$GITHUB_REPO \
$ndctl_enable \ $ndctl_enable \
-v $HOST_WORKDIR:$WORKDIR \ -v $HOST_WORKDIR:$WORKDIR \
-v /etc/localtime:/etc/localtime \ -v /etc/localtime:/etc/localtime \
......
#!/usr/bin/env bash #!/usr/bin/env bash
# #
# Copyright 2016-2018, Intel Corporation # Copyright 2016-2019, Intel Corporation
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
...@@ -62,8 +62,13 @@ if [[ ! -f "Dockerfile.$1" ]]; then ...@@ -62,8 +62,13 @@ if [[ ! -f "Dockerfile.$1" ]]; then
exit 1 exit 1
fi fi
# Build a Docker image tagged with pmem/pmdk:OS-VER if [[ -z "${DOCKERHUB_REPO}" ]]; then
tag=pmem/pmdk:1.5-$1 echo "DOCKERHUB_REPO environment variable is not set"
exit 1
fi
# Build a Docker image tagged with ${DOCKERHUB_REPO}:OS-VER
tag=${DOCKERHUB_REPO}:1.5-$1
docker build -t $tag \ docker build -t $tag \
--build-arg http_proxy=$http_proxy \ --build-arg http_proxy=$http_proxy \
--build-arg https_proxy=$https_proxy \ --build-arg https_proxy=$https_proxy \
......
#!/usr/bin/env bash #!/usr/bin/env bash
# #
# Copyright 2016-2018, Intel Corporation # Copyright 2016-2019, Intel Corporation
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
...@@ -45,7 +45,7 @@ function usage { ...@@ -45,7 +45,7 @@ function usage {
echo "Usage:" echo "Usage:"
echo " push-image.sh <OS-VER>" echo " push-image.sh <OS-VER>"
echo "where <OS-VER>, for example, can be 'ubuntu-16.04', provided " \ echo "where <OS-VER>, for example, can be 'ubuntu-16.04', provided " \
"a Docker image tagged with pmem/pmdk:ubuntu-16.04 exists " \ "a Docker image tagged with ${DOCKERHUB_REPO}:ubuntu-16.04 exists " \
"locally." "locally."
} }
...@@ -55,8 +55,13 @@ if [[ -z "$1" ]]; then ...@@ -55,8 +55,13 @@ if [[ -z "$1" ]]; then
exit 1 exit 1
fi fi
if [[ -z "${DOCKERHUB_REPO}" ]]; then
echo "DOCKERHUB_REPO environment variable is not set"
exit 1
fi
# Check if the image tagged with pmdk/OS-VER exists locally # Check if the image tagged with pmdk/OS-VER exists locally
if [[ ! $(docker images -a | awk -v pattern="^pmem/pmdk:1.5-$1\$" \ if [[ ! $(docker images -a | awk -v pattern="^${DOCKERHUB_REPO}:1.5-$1\$" \
'$1":"$2 ~ pattern') ]] '$1":"$2 ~ pattern') ]]
then then
echo "ERROR: wrong argument." echo "ERROR: wrong argument."
...@@ -68,4 +73,4 @@ fi ...@@ -68,4 +73,4 @@ fi
docker login -u="$DOCKER_USER" -p="$DOCKER_PASSWORD" docker login -u="$DOCKER_USER" -p="$DOCKER_PASSWORD"
# Push the image to the repository # Push the image to the repository
docker push pmem/pmdk:1.5-$1 docker push ${DOCKERHUB_REPO}:1.5-$1
#!/usr/bin/env bash #!/usr/bin/env bash
# #
# Copyright 2016-2018, Intel Corporation # Copyright 2016-2019, Intel Corporation
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
...@@ -77,7 +77,7 @@ fi ...@@ -77,7 +77,7 @@ fi
# TRAVIS_COMMIT_RANGE is usually invalid for force pushes - ignore such values # TRAVIS_COMMIT_RANGE is usually invalid for force pushes - ignore such values
# when used with non-upstream repository # when used with non-upstream repository
if [ -n "$TRAVIS_COMMIT_RANGE" -a $TRAVIS_REPO_SLUG != "pmem/pmdk" ]; then if [ -n "$TRAVIS_COMMIT_RANGE" -a $TRAVIS_REPO_SLUG != "$GITHUB_REPO" ]; then
if ! git rev-list $TRAVIS_COMMIT_RANGE; then if ! git rev-list $TRAVIS_COMMIT_RANGE; then
TRAVIS_COMMIT_RANGE= TRAVIS_COMMIT_RANGE=
fi fi
...@@ -115,11 +115,11 @@ for file in $files; do ...@@ -115,11 +115,11 @@ for file in $files; do
popd popd
# Check if the image has to be pushed to Docker Hub # Check if the image has to be pushed to Docker Hub
# (i.e. the build is triggered by commits to the pmem/pmdk # (i.e. the build is triggered by commits to the $GITHUB_REPO
# repository's stable-1.5 branch, and the Travis build is not # repository's stable-1.5 branch, and the Travis build is not
# of the "pull_request" type). In that case, create the empty # of the "pull_request" type). In that case, create the empty
# file. # file.
if [[ $TRAVIS_REPO_SLUG == "pmem/pmdk" \ if [[ $TRAVIS_REPO_SLUG == "$GITHUB_REPO" \
&& $TRAVIS_BRANCH == "stable-1.5" \ && $TRAVIS_BRANCH == "stable-1.5" \
&& $TRAVIS_EVENT_TYPE != "pull_request" && $TRAVIS_EVENT_TYPE != "pull_request"
&& $PUSH_IMAGE == "1" ]] && $PUSH_IMAGE == "1" ]]
...@@ -141,4 +141,4 @@ done ...@@ -141,4 +141,4 @@ done
# Getting here means rebuilding the Docker image is not required. # Getting here means rebuilding the Docker image is not required.
# Pull the image from Docker Hub. # Pull the image from Docker Hub.
docker pull pmem/pmdk:1.5-${OS}-${OS_VER} docker pull ${DOCKERHUB_REPO}:1.5-${OS}-${OS_VER}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment