Skip to content

Commit d419ec0

Browse files
author
Apache Mynewt Bot
committed
Add module update CI
1 parent 62a8136 commit d419ec0

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: go
2+
go:
3+
- '1.13'
4+
git:
5+
depth: false
6+
before_install:
7+
- export GOPATH=$HOME/gopath
8+
script:
9+
- cp update_modules.sh $HOME
10+
- "$HOME/update_modules.sh"
11+
env:
12+
global:
13+
secure: p06m+f+nGdq92hO4J/PZJCPAKmKIlrqXdx7qBAGiNgAmUor46alZz85oqief9MEtBKVvBqGXkPTLVQY4Qpqp90pO8FcE6EsT4B/461sLL7aHdj+RD8x9rlL3KB1qggQrCx4Q+DZgCg0lFeNW55ViDQkT/PwYvJJ4a6HBoMeyLmHWipHLXJB4h8GYK/FCtK2s7Lb/HOAg+pUQu9iS8dTt4TjmzrIjkF6MHoxkUHs/AOKcKlZtSp2TiT18b2Gu1UYPyoZyCIe6Z8HZssQ1lTES0aN0ObS89/IWWvH/YKf8XkRDt8zBEpx4Slcv4aa96BCRlZZ8/xlb/hAXYoB7tGkbLSHhup4UQbe3wZ/sdhlffJBG9BaKjPsDFzXAztFzQIWd9Mj7/16b2oisq39H9H9vL7j3/S7wtfAopkyWrjr98k3WHSWEWgRI5+qBtCajDERpeeUuq/5CG8VOEkMCokklija/ZPoEJEs5ekwObvPARCSfcFW5QdnOhijf8Wz8nPWSoZ65YbhiZk/DTBvbahDjR8IxcfudYI5/oxAyAAVmji4bPOP03cCAwwQ7Z4TKvtrLeUNj8K37wtT6MWunVNprSinUCx2alAEK7H58Ed7I7RxDTENbs/Y13sF6AhlGqO1kDO7Xj7wRGXqo28msAcrV96QPwavSKW0oay8PtN3W6D4=

update_modules.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
BRANCH="update-modules"
19+
20+
pushd $TRAVIS_BUILD_DIR
21+
22+
#debug
23+
pwd
24+
ls
25+
26+
# remove any update-modules branch
27+
git branch -D "${BRANCH}" 2>/dev/null
28+
29+
git remote add upstream https://github.com/apache/mynewt-mcumgr-cli
30+
[[ $? -ne 0 ]] && exit 1
31+
32+
git fetch upstream
33+
[[ $? -ne 0 ]] && exit 1
34+
35+
# must be running on master to find modules that were updated!
36+
git reset --hard upstream/master
37+
38+
is_mod=0
39+
modules=()
40+
while read line; do
41+
if [[ "${line}" == "require (" ]]; then
42+
is_mod=1
43+
elif [[ $is_mod -eq 1 && "${line}" == ")" ]]; then
44+
is_mod=0
45+
break
46+
elif [[ $is_mod -eq 1 ]]; then
47+
module="$(echo ${line} | cut -d' ' -f1)"
48+
modules[${#modules[*]}]=$module
49+
fi
50+
done <go.mod
51+
52+
pushd mcumgr
53+
for module in ${modules[*]}; do
54+
go get -v -u $module
55+
done
56+
popd
57+
58+
git diff --quiet
59+
if [[ $? -eq 0 ]]; then
60+
echo "No changes detected."
61+
exit 0
62+
fi
63+
64+
# Check that still builds...
65+
pushd mcumgr
66+
go build -v
67+
[[ $? -ne 0 ]] && exit 1
68+
popd
69+
70+
git checkout -b "${BRANCH}"
71+
[[ $? -ne 0 ]] && exit 1
72+
73+
git commit -m "Update dependencies (automated)" go.mod go.sum
74+
75+
# Add new repo that has a valid write permission token
76+
git remote add writable https://${GH_TOKEN}@github.com/apache-mynewt-bot/mynewt-mcumgr-cli.git
77+
git push writable ${BRANCH} --force
78+
[[ $? -ne 0 ]] && exit 1
79+
80+
# Create PR through GH API
81+
curl -H "Content-Type: application/json" \
82+
-H "authToken: ${GH_TOKEN}" \
83+
--data '{"title":"Update dependencies","body":"New dependencies found!","head":"apache-mynewt-bot:update-modules","base":"master"}' \
84+
https://api.github.com/repos/apache/mynewt-mcumgr-cli/pulls

0 commit comments

Comments
 (0)