Skip to content
Snippets Groups Projects
Unverified Commit 4d5c6d17 authored by Marcin Ślusarz's avatar Marcin Ślusarz Committed by GitHub
Browse files

Merge pull request #3595 from marcinslusarz/travis-envs

common: introduce GITHUB_REPO and DOCKERHUB_REPO on Travis
parents 6e27815f 8f921da2
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,8 @@ env:
before_install:
- echo $TRAVIS_COMMIT_RANGE
- export HOST_WORKDIR=`pwd`
- export GITHUB_REPO=pmem/pmdk
- export DOCKERHUB_REPO=pmem/pmdk
- cd utils/docker
- ./pull-or-rebuild-image.sh
- if [[ -f push_image_to_repo_flag ]]; then PUSH_THE_IMAGE=1; fi
......
#!/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
# modification, are permitted provided that the following conditions
......@@ -38,10 +38,10 @@
# usage: ./check-commit.sh
#
if [[ $TRAVIS_REPO_SLUG != "pmem/pmdk" \
if [[ $TRAVIS_REPO_SLUG != "$GITHUB_REPO" \
|| $TRAVIS_EVENT_TYPE != "pull_request" ]];
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
fi
......
#!/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
# modification, are permitted provided that the following conditions
......@@ -46,10 +46,10 @@ if [[ -z "$TRAVIS" ]]; then
exit 1
fi
if [[ $TRAVIS_REPO_SLUG != "pmem/pmdk" \
if [[ $TRAVIS_REPO_SLUG != "$GITHUB_REPO" \
|| $TRAVIS_EVENT_TYPE != "pull_request" ]];
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
fi
......
......@@ -62,7 +62,8 @@ export PMDK_CC=${PMDK_CC:-gcc}
export PMDK_CXX=${PMDK_CXX:-g++}
export EXPERIMENTAL=${EXPERIMENTAL:-n}
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
echo "ERROR: The variables OS and OS_VER have to be set " \
......@@ -78,7 +79,7 @@ if [[ "$KEEP_CONTAINER" != "1" ]]; then
RM_SETTING=" --rm"
fi
imageName=pmem/pmdk:1.5-${OS}-${OS_VER}
imageName=${DOCKERHUB_REPO}:1.5-${OS}-${OS_VER}
containerName=pmdk-${OS}-${OS_VER}
if [[ $MAKE_PKG -eq 1 ]] ; then
......
......@@ -69,7 +69,7 @@ if [[ -z "$TEST_BUILD" ]]; then
TEST_BUILD=all
fi
imageName=pmem/pmdk:1.5-${OS}-${OS_VER}
imageName=${DOCKERHUB_REPO}:1.5-${OS}-${OS_VER}
containerName=pmdk-${OS}-${OS_VER}
if [[ $MAKE_PKG -eq 0 ]] ; then command="./run-build.sh"; fi
......@@ -116,6 +116,7 @@ docker run --rm --privileged=true --name=$containerName -ti \
--env TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \
--env COVERITY_SCAN_TOKEN=$COVERITY_SCAN_TOKEN \
--env COVERITY_SCAN_NOTIFICATION_EMAIL=$COVERITY_SCAN_NOTIFICATION_EMAIL \
--env GITHUB_REPO=$GITHUB_REPO \
$ndctl_enable \
-v $HOST_WORKDIR:$WORKDIR \
-v /etc/localtime:/etc/localtime \
......
#!/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
# modification, are permitted provided that the following conditions
......@@ -62,8 +62,13 @@ if [[ ! -f "Dockerfile.$1" ]]; then
exit 1
fi
# Build a Docker image tagged with pmem/pmdk:OS-VER
tag=pmem/pmdk:1.5-$1
if [[ -z "${DOCKERHUB_REPO}" ]]; then
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 \
--build-arg http_proxy=$http_proxy \
--build-arg https_proxy=$https_proxy \
......
#!/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
# modification, are permitted provided that the following conditions
......@@ -45,7 +45,7 @@ function usage {
echo "Usage:"
echo " push-image.sh <OS-VER>"
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."
}
......@@ -55,8 +55,13 @@ if [[ -z "$1" ]]; then
exit 1
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
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') ]]
then
echo "ERROR: wrong argument."
......@@ -68,4 +73,4 @@ fi
docker login -u="$DOCKER_USER" -p="$DOCKER_PASSWORD"
# Push the image to the repository
docker push pmem/pmdk:1.5-$1
docker push ${DOCKERHUB_REPO}:1.5-$1
#!/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
# modification, are permitted provided that the following conditions
......@@ -77,7 +77,7 @@ fi
# TRAVIS_COMMIT_RANGE is usually invalid for force pushes - ignore such values
# 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
TRAVIS_COMMIT_RANGE=
fi
......@@ -115,11 +115,11 @@ for file in $files; do
popd
# 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
# of the "pull_request" type). In that case, create the empty
# file.
if [[ $TRAVIS_REPO_SLUG == "pmem/pmdk" \
if [[ $TRAVIS_REPO_SLUG == "$GITHUB_REPO" \
&& $TRAVIS_BRANCH == "stable-1.5" \
&& $TRAVIS_EVENT_TYPE != "pull_request"
&& $PUSH_IMAGE == "1" ]]
......@@ -141,4 +141,4 @@ done
# Getting here means rebuilding the Docker image is not required.
# 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