Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Store build binary in S3.
Browse files Browse the repository at this point in the history
Store snap travici linux builds in a s3 repository.

* Upload build directory to AWS s3.
* Update DNS build.ci.snap-telemtry.io -> s3 repo.
  • Loading branch information
nanliu committed Jul 20, 2016
1 parent 5137f6c commit b8304e2
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 8 deletions.
31 changes: 26 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ before_install:
- if [ ! -d $SNAP_SOURCE ]; then mkdir -p $HOME/gopath/src/github.com/intelsdi-x; ln -s $TRAVIS_BUILD_DIR $SNAP_SOURCE; fi # CI for forks not from intelsdi-x
env:
global:
- SNAP_SOURCE=/home/travis/gopath/src/github.com/intelsdi-x/snap
- GO15VENDOREXPERIMENT=1
- SNAP_SOURCE=/home/travis/gopath/src/github.com/intelsdi-x/snap
- GO15VENDOREXPERIMENT=1
- secure: kSsbBOCrSRyWx6yhSwhTYIWRId4WNMkO9OhMphBPXb5kDEd+asanCybuBKdOSgzuqrzBbQsuQjzhw+iZwdiPoQInZyDxeVl7frroNvg94n+q4tpPQOPzJ6gN15MCHSq3m1lCk3XVrESGEBTqmdmUtZhY+RfxSXuq1xkDMesst2f+gONd5Bl+QFiboRqvjUXwGC+e3JnZI2LxWjYZspNh2ZS6c5mvbhufDPV5MD6+jlZppzHcNkHAtHOt3KNoTFai8X0U8MYiEax3mSIAHjYzQQayS5al54MfgcVo1r4gWmPOybkyb5+/DyNSUT4KY+XVIrxV68fSOuCnLxLEaQZ9W0c0WuetmUU1fOT8Iy9q0qLQq9IknXNnfsCEGdwB2XKfyNvKEtkWbi6b6idrok5d1y7b8Qt5olveczGx0cRbpXQ0BTZ/bnQMhL9tpUeRltbDey6dsSsTJjnatqH7CdeEAV0ZeY+LjBgTukps4TlEHTn0ddEzhR1rrRsQ3OB0kT59Y3BCJ4kstzpMsTFWKUTMr/75UR1g5XETfOt0BtXkM3I343AIjJt+MQg/bW26ZOTbqPbqVO3Z7eDf0MaRC4Mugm809ekMZARTLAmq4FMIutDsTTT741IgWZQrMDI37WUztDUE1WFDzcTkAk99yc6gBjZ+0dZd1Qc7RQR0RMBi4M4=
matrix:
- SNAP_TEST_TYPE=legacy
- SNAP_TEST_TYPE=small
- SNAP_TEST_TYPE=medium
- SNAP_TEST_TYPE=legacy
- SNAP_TEST_TYPE=small
- SNAP_TEST_TYPE=medium
install:
- export TMPDIR=$HOME/tmp
- mkdir -p $TMPDIR
Expand All @@ -23,5 +24,25 @@ install:
script:
- make check 2>&1 # Run test suite
notifications:
email: false
slack:
secure: VkbZLIc2RH8yf3PtIAxUNPdAu3rQQ7yQx0GcK124JhbEnZGaHyK615V0rbG7HcVmYKGPdB0cXqZiLBDKGqGKb2zR1NepOe1nF03jxGSpPq8jIFeEXSJGEYGL34ScDzZZGuG6qwbjFcXiW5lqn6t8igzp7v2+URYBaZo5ktCS2xY=
before_deploy:
- "./scripts/pre_deploy.sh"
deploy:
provider: s3
access_key_id: AKIAINMB43VSSPFZISAA
secret_access_key:
secure: vEWq7ImahLeJ3n+RsazhuCuzRV5b8biZRy3HpqJlNasSAqUPvugGD8TrhaK/3fru931flVLsLdFJObG3cIHmJrJDaLS+Zv7707+yAPHOLrATedO530P89CPlJpDmbPNuqU2e+6NfCu7DZQdceXF5hSQRIVeVloHcsnoo7XG4VFHPrIOCB+JbWnVquH7wtOn3h0RcOtzQQgdehqKB2c6Yi68wFkgKIEyIQHL63m28biMn1nMH1i0lYCN4rk8kxhPWar6e86JPeDvyhUbXixokXsy0H3J819yWwZIejb0UCucJmXMG+m9jMNXwh1DoC4+HMvFnzUdB61G6nYCPFz0GRyw363sXCg2rBizkTyhVF1Bd039gWgGFm6rb5cUKTlvNuvWe+x1E0lX8G3pPa8ZFX7/i2P9GPJCt8LHnZnskIHv0Yic/+6Kt89veS0YWgQRUuSGDnhaMuJHeyZppiFr4ALUi032/qTCuTj6z/v7UMpDSkPGpCh4505mMVsx11lT7zoZnK5/1Qxfd8ysJgfPKcptJXMfYjX/8QFT9EPok4KMx6E2k8hS82rT5i1pjjE9Kw18xqJNlWOUatfX5jzzoCYxuj/d99Zu4gD0n7UUN5rcNY7xrrBwYPmPaIKOTp+k+RdwlRIhxaXr2j5GFCaSPrtDobULioJIHfdbxVjrThQY=
bucket: intelsdi-x
region: us-west-2
skip_cleanup: true
local-dir: build
upload-dir: snap
acl: public_read
on:
repo: intelsdi-x/snap
branch: master
condition: $SNAP_TEST_TYPE = medium && $TRAVIS_GO_VERSION = "1.6.2"
after_deploy:
- "./scripts/post_deploy.sh"
2 changes: 1 addition & 1 deletion scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ _notice () { [ "${LOG_LEVEL}" -ge 5 ] && echo "$(_fmt notice) ${*}" 1>&2 || tru
_warning () { [ "${LOG_LEVEL}" -ge 4 ] && echo "$(_fmt warning) ${*}" 1>&2 || true; }
_error () { [ "${LOG_LEVEL}" -ge 3 ] && echo "$(_fmt error) ${*}" 1>&2 || true; exit 1; }

test_dirs=$(find . -type f -name '*.go' -not -path "./.*" -not -path "*/_*" -not -path "./Godeps/*" -not -path "./vendor/*" -print0 | xargs -0 -n1 dirname| sort -u)
test_dirs=$(find . -type f -name '*.go' -not -path "./.*" -not -path "*/_*" -not -path "./Godeps/*" -not -path "./vendor/*" -not -path "./scripts/*" -print0 | xargs -0 -n1 dirname | sort -u)

_debug "go code directories:
${test_dirs}"
Expand Down
40 changes: 40 additions & 0 deletions scripts/post_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

#http://www.apache.org/licenses/LICENSE-2.0.txt
#
#
#Copyright 2016 Intel Corporation
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.

git_branch=$(git symbolic-ref HEAD 2> /dev/null | cut -b 12-)
git_branch="${git_branch:-snap}"
git_sha=$(git log --pretty=format:"%h" -1)
git_version=$(git describe --always --exact-match 2> /dev/null || echo "${git_branch}-${git_sha}")

set -e
set -u
set -o pipefail

__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__proj_dir="$(dirname "$__dir")"

# shellcheck source=scripts/common.sh
. "${__dir}/common.sh"

SNAP_BUILD_URL="https://s3-us-west-2.amazonaws.com/intelsdi-x/snap/${git_version}"
export SNAP_BUILD_URL

_info "updating package URL: ${SNAP_BUILD_URL}"
go get github.com/dnsimple/dnsimple-go/dnsimple
go run "${__proj_dir}/scripts/update_dns.go"
41 changes: 41 additions & 0 deletions scripts/pre_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

#http://www.apache.org/licenses/LICENSE-2.0.txt
#
#
#Copyright 2016 Intel Corporation
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.

git_branch=$(git symbolic-ref HEAD 2> /dev/null | cut -b 12-)
git_branch="${git_branch:-snap}"
git_sha=$(git log --pretty=format:"%h" -1)
git_version=$(git describe --always --exact-match 2> /dev/null || echo "${git_branch}-${git_sha}")

set -e
set -u
set -o pipefail

__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__proj_dir="$(dirname "$__dir")"

# shellcheck source=scripts/common.sh
. "${__dir}/common.sh"

build_path="${SNAP_PATH:-"${__proj_dir}/build"}"
git_path="${build_path}/${git_version}"

mkdir -p "${git_path}"
_info "copying snap binaries to ${git_path}"
mv "${build_path}/bin/"* "${git_path}"
mv "${build_path}/plugin/"* "${git_path}"
2 changes: 0 additions & 2 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ __proj_dir="$(dirname "$__dir")"

SNAP_PATH="${SNAP_PATH:-"${__proj_dir}/build"}"
export SNAP_PATH
test_dirs=$(find . -type f -name '*.go' -not -path "./.*" -not -path "*/_*" -not -path "./Godeps/*" -not -path "./vendor/*" -print0 | xargs -0 -n1 dirname| sort -u)
export test_dirs

# shellcheck source=scripts/common.sh
. "${__dir}/common.sh"
Expand Down
46 changes: 46 additions & 0 deletions scripts/update_dns.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package main

import (
"fmt"
"os"
"strconv"

"github.com/dnsimple/dnsimple-go/dnsimple"
)

func main() {
url := os.Getenv("SNAP_BUILD_URL")
if len(url) == 0 {
fmt.Printf("Must provide SNAP_BUILD_URL")
os.Exit(1)
}

oauthToken := os.Getenv("DNSIMPLE_TOKEN")
if len(oauthToken) == 0 {
fmt.Printf("Must provide DNSIMPLE_TOKEN")
os.Exit(1)
}

client := dnsimple.NewClient(dnsimple.NewOauthTokenCredentials(oauthToken))

// get DNSimple client accountID
whoamiResponse, err := client.Identity.Whoami()
if err != nil {
fmt.Printf("Whoami() returned error: %v\n", err)
os.Exit(1)
}
accountID := strconv.Itoa(whoamiResponse.Data.Account.ID)
zoneID := "snap-telemetry.io"

result, err := client.Zones.ListRecords(accountID, zoneID, &dnsimple.ZoneRecordListOptions{Name: "build.ci"})
if err != nil {
fmt.Printf("build.ci.snap-telemetry.io DNS record not found: %v\n", err)
os.Exit(1)
}

record := result.Data[0]

// replace build.ci.snap-telemtry.io URL record with new s3 folder
record.Content = url
client.Zones.UpdateRecord(accountID, zoneID, record.ID, record)
}

0 comments on commit b8304e2

Please sign in to comment.