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

Commit b8304e2

Browse files
committed
Store build binary in S3.
Store snap travici linux builds in a s3 repository. * Upload build directory to AWS s3. * Update DNS build.ci.snap-telemtry.io -> s3 repo.
1 parent 5137f6c commit b8304e2

6 files changed

Lines changed: 154 additions & 8 deletions

File tree

.travis.yml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ before_install:
99
- 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
1010
env:
1111
global:
12-
- SNAP_SOURCE=/home/travis/gopath/src/github.com/intelsdi-x/snap
13-
- GO15VENDOREXPERIMENT=1
12+
- SNAP_SOURCE=/home/travis/gopath/src/github.com/intelsdi-x/snap
13+
- GO15VENDOREXPERIMENT=1
14+
- secure: kSsbBOCrSRyWx6yhSwhTYIWRId4WNMkO9OhMphBPXb5kDEd+asanCybuBKdOSgzuqrzBbQsuQjzhw+iZwdiPoQInZyDxeVl7frroNvg94n+q4tpPQOPzJ6gN15MCHSq3m1lCk3XVrESGEBTqmdmUtZhY+RfxSXuq1xkDMesst2f+gONd5Bl+QFiboRqvjUXwGC+e3JnZI2LxWjYZspNh2ZS6c5mvbhufDPV5MD6+jlZppzHcNkHAtHOt3KNoTFai8X0U8MYiEax3mSIAHjYzQQayS5al54MfgcVo1r4gWmPOybkyb5+/DyNSUT4KY+XVIrxV68fSOuCnLxLEaQZ9W0c0WuetmUU1fOT8Iy9q0qLQq9IknXNnfsCEGdwB2XKfyNvKEtkWbi6b6idrok5d1y7b8Qt5olveczGx0cRbpXQ0BTZ/bnQMhL9tpUeRltbDey6dsSsTJjnatqH7CdeEAV0ZeY+LjBgTukps4TlEHTn0ddEzhR1rrRsQ3OB0kT59Y3BCJ4kstzpMsTFWKUTMr/75UR1g5XETfOt0BtXkM3I343AIjJt+MQg/bW26ZOTbqPbqVO3Z7eDf0MaRC4Mugm809ekMZARTLAmq4FMIutDsTTT741IgWZQrMDI37WUztDUE1WFDzcTkAk99yc6gBjZ+0dZd1Qc7RQR0RMBi4M4=
1415
matrix:
15-
- SNAP_TEST_TYPE=legacy
16-
- SNAP_TEST_TYPE=small
17-
- SNAP_TEST_TYPE=medium
16+
- SNAP_TEST_TYPE=legacy
17+
- SNAP_TEST_TYPE=small
18+
- SNAP_TEST_TYPE=medium
1819
install:
1920
- export TMPDIR=$HOME/tmp
2021
- mkdir -p $TMPDIR
@@ -23,5 +24,25 @@ install:
2324
script:
2425
- make check 2>&1 # Run test suite
2526
notifications:
27+
email: false
2628
slack:
2729
secure: VkbZLIc2RH8yf3PtIAxUNPdAu3rQQ7yQx0GcK124JhbEnZGaHyK615V0rbG7HcVmYKGPdB0cXqZiLBDKGqGKb2zR1NepOe1nF03jxGSpPq8jIFeEXSJGEYGL34ScDzZZGuG6qwbjFcXiW5lqn6t8igzp7v2+URYBaZo5ktCS2xY=
30+
before_deploy:
31+
- "./scripts/pre_deploy.sh"
32+
deploy:
33+
provider: s3
34+
access_key_id: AKIAINMB43VSSPFZISAA
35+
secret_access_key:
36+
secure: vEWq7ImahLeJ3n+RsazhuCuzRV5b8biZRy3HpqJlNasSAqUPvugGD8TrhaK/3fru931flVLsLdFJObG3cIHmJrJDaLS+Zv7707+yAPHOLrATedO530P89CPlJpDmbPNuqU2e+6NfCu7DZQdceXF5hSQRIVeVloHcsnoo7XG4VFHPrIOCB+JbWnVquH7wtOn3h0RcOtzQQgdehqKB2c6Yi68wFkgKIEyIQHL63m28biMn1nMH1i0lYCN4rk8kxhPWar6e86JPeDvyhUbXixokXsy0H3J819yWwZIejb0UCucJmXMG+m9jMNXwh1DoC4+HMvFnzUdB61G6nYCPFz0GRyw363sXCg2rBizkTyhVF1Bd039gWgGFm6rb5cUKTlvNuvWe+x1E0lX8G3pPa8ZFX7/i2P9GPJCt8LHnZnskIHv0Yic/+6Kt89veS0YWgQRUuSGDnhaMuJHeyZppiFr4ALUi032/qTCuTj6z/v7UMpDSkPGpCh4505mMVsx11lT7zoZnK5/1Qxfd8ysJgfPKcptJXMfYjX/8QFT9EPok4KMx6E2k8hS82rT5i1pjjE9Kw18xqJNlWOUatfX5jzzoCYxuj/d99Zu4gD0n7UUN5rcNY7xrrBwYPmPaIKOTp+k+RdwlRIhxaXr2j5GFCaSPrtDobULioJIHfdbxVjrThQY=
37+
bucket: intelsdi-x
38+
region: us-west-2
39+
skip_cleanup: true
40+
local-dir: build
41+
upload-dir: snap
42+
acl: public_read
43+
on:
44+
repo: intelsdi-x/snap
45+
branch: master
46+
condition: $SNAP_TEST_TYPE = medium && $TRAVIS_GO_VERSION = "1.6.2"
47+
after_deploy:
48+
- "./scripts/post_deploy.sh"

scripts/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ _notice () { [ "${LOG_LEVEL}" -ge 5 ] && echo "$(_fmt notice) ${*}" 1>&2 || tru
4545
_warning () { [ "${LOG_LEVEL}" -ge 4 ] && echo "$(_fmt warning) ${*}" 1>&2 || true; }
4646
_error () { [ "${LOG_LEVEL}" -ge 3 ] && echo "$(_fmt error) ${*}" 1>&2 || true; exit 1; }
4747

48-
test_dirs=$(find . -type f -name '*.go' -not -path "./.*" -not -path "*/_*" -not -path "./Godeps/*" -not -path "./vendor/*" -print0 | xargs -0 -n1 dirname| sort -u)
48+
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)
4949

5050
_debug "go code directories:
5151
${test_dirs}"

scripts/post_deploy.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
#http://www.apache.org/licenses/LICENSE-2.0.txt
4+
#
5+
#
6+
#Copyright 2016 Intel Corporation
7+
#
8+
#Licensed under the Apache License, Version 2.0 (the "License");
9+
#you may not use this file except in compliance with the License.
10+
#You may obtain a copy of the License at
11+
#
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
#Unless required by applicable law or agreed to in writing, software
15+
#distributed under the License is distributed on an "AS IS" BASIS,
16+
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
#See the License for the specific language governing permissions and
18+
#limitations under the License.
19+
20+
git_branch=$(git symbolic-ref HEAD 2> /dev/null | cut -b 12-)
21+
git_branch="${git_branch:-snap}"
22+
git_sha=$(git log --pretty=format:"%h" -1)
23+
git_version=$(git describe --always --exact-match 2> /dev/null || echo "${git_branch}-${git_sha}")
24+
25+
set -e
26+
set -u
27+
set -o pipefail
28+
29+
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
30+
__proj_dir="$(dirname "$__dir")"
31+
32+
# shellcheck source=scripts/common.sh
33+
. "${__dir}/common.sh"
34+
35+
SNAP_BUILD_URL="https://s3-us-west-2.amazonaws.com/intelsdi-x/snap/${git_version}"
36+
export SNAP_BUILD_URL
37+
38+
_info "updating package URL: ${SNAP_BUILD_URL}"
39+
go get github.com/dnsimple/dnsimple-go/dnsimple
40+
go run "${__proj_dir}/scripts/update_dns.go"

scripts/pre_deploy.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
#http://www.apache.org/licenses/LICENSE-2.0.txt
4+
#
5+
#
6+
#Copyright 2016 Intel Corporation
7+
#
8+
#Licensed under the Apache License, Version 2.0 (the "License");
9+
#you may not use this file except in compliance with the License.
10+
#You may obtain a copy of the License at
11+
#
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
#Unless required by applicable law or agreed to in writing, software
15+
#distributed under the License is distributed on an "AS IS" BASIS,
16+
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
#See the License for the specific language governing permissions and
18+
#limitations under the License.
19+
20+
git_branch=$(git symbolic-ref HEAD 2> /dev/null | cut -b 12-)
21+
git_branch="${git_branch:-snap}"
22+
git_sha=$(git log --pretty=format:"%h" -1)
23+
git_version=$(git describe --always --exact-match 2> /dev/null || echo "${git_branch}-${git_sha}")
24+
25+
set -e
26+
set -u
27+
set -o pipefail
28+
29+
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
30+
__proj_dir="$(dirname "$__dir")"
31+
32+
# shellcheck source=scripts/common.sh
33+
. "${__dir}/common.sh"
34+
35+
build_path="${SNAP_PATH:-"${__proj_dir}/build"}"
36+
git_path="${build_path}/${git_version}"
37+
38+
mkdir -p "${git_path}"
39+
_info "copying snap binaries to ${git_path}"
40+
mv "${build_path}/bin/"* "${git_path}"
41+
mv "${build_path}/plugin/"* "${git_path}"

scripts/test.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ __proj_dir="$(dirname "$__dir")"
3131

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

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

scripts/update_dns.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"strconv"
7+
8+
"github.com/dnsimple/dnsimple-go/dnsimple"
9+
)
10+
11+
func main() {
12+
url := os.Getenv("SNAP_BUILD_URL")
13+
if len(url) == 0 {
14+
fmt.Printf("Must provide SNAP_BUILD_URL")
15+
os.Exit(1)
16+
}
17+
18+
oauthToken := os.Getenv("DNSIMPLE_TOKEN")
19+
if len(oauthToken) == 0 {
20+
fmt.Printf("Must provide DNSIMPLE_TOKEN")
21+
os.Exit(1)
22+
}
23+
24+
client := dnsimple.NewClient(dnsimple.NewOauthTokenCredentials(oauthToken))
25+
26+
// get DNSimple client accountID
27+
whoamiResponse, err := client.Identity.Whoami()
28+
if err != nil {
29+
fmt.Printf("Whoami() returned error: %v\n", err)
30+
os.Exit(1)
31+
}
32+
accountID := strconv.Itoa(whoamiResponse.Data.Account.ID)
33+
zoneID := "snap-telemetry.io"
34+
35+
result, err := client.Zones.ListRecords(accountID, zoneID, &dnsimple.ZoneRecordListOptions{Name: "build.ci"})
36+
if err != nil {
37+
fmt.Printf("build.ci.snap-telemetry.io DNS record not found: %v\n", err)
38+
os.Exit(1)
39+
}
40+
41+
record := result.Data[0]
42+
43+
// replace build.ci.snap-telemtry.io URL record with new s3 folder
44+
record.Content = url
45+
client.Zones.UpdateRecord(accountID, zoneID, record.ID, record)
46+
}

0 commit comments

Comments
 (0)