Merge ~morphis/snappy-hwe-snaps/+git/build-scripts:f/allow-snap-snapcraft-yaml into ~snappy-hwe-team/snappy-hwe-snaps/+git/build-scripts:master

Proposed by Simon Fels
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: 30aa87a83a61c3a5df11fedc204e58623e7f9418
Merged at revision: 1ca967bf2c0140b012625bf5cd31a9e7d3e4320f
Proposed branch: ~morphis/snappy-hwe-snaps/+git/build-scripts:f/allow-snap-snapcraft-yaml
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/build-scripts:master
Diff against target: 97 lines (+30/-10)
2 files modified
jobs/generic-build-snap-worker (+13/-3)
jobs/generic-release-snap (+17/-7)
Reviewer Review Type Date Requested Status
Alfonso Sanchez-Beato Approve
Roberto Mier Escandon (community) Approve
System Enablement Bot continuous-integration Approve
Review via email: mp+325241@code.launchpad.net

Description of the change

Allow snap/snapcraft.yaml next to a top level snapcraft.yaml

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

lgtm

review: Approve
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Looks good, just a couple of nitpiks

review: Needs Fixing
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/jobs/generic-build-snap-worker b/jobs/generic-build-snap-worker
2index 81a7709..bb72cee 100755
3--- a/jobs/generic-build-snap-worker
4+++ b/jobs/generic-build-snap-worker
5@@ -40,9 +40,17 @@ fi
6 # $SOURCE_GIT_REPO_BRANCH points us to an upstream component branch we
7 # will take master as the next suitable candidate.
8 CI_BRANCH=
9+SNAPCRAFT_YAML_PATH=
10 for branch in $SOURCE_GIT_REPO_BRANCH master ; do
11 git checkout $branch
12+
13 if [ -e snapcraft.yaml ]; then
14+ SNAPCRAFT_YAML_PATH=snapcraft.yaml
15+ elif [ -e snap/snapcraft.yaml ]; then
16+ SNAPCRAFT_YAML_PATH=snap/snapcraft.yaml
17+ fi
18+
19+ if [ -n "$SNAPCRAFT_YAML_PATH" ]; then
20 CI_BRANCH=$branch
21 break
22 fi
23@@ -57,15 +65,17 @@ REPO_NAME=$(awk -v a="$TARGET_GIT_REPO" 'BEGIN{print substr(a, index(a, "+git/")
24 # We rely on the snapcraft.yaml to have the snap name in the first five lines
25 # which is the case for all our snaps. This is a bit lazy but the best way to
26 # ensure we don't fetch any other name: fields which might be present in the file.
27-SNAP_NAME=$(cat snapcraft.yaml | grep -v ^\# | head -n 5 | grep "^name:" | awk '{print $2}')
28+SNAP_NAME=$(cat $SNAPCRAFT_YAML_PATH | grep -v ^\# | head -n 5 | grep "^name:" | awk '{print $2}')
29 SNAP_REV=$(git rev-parse --short HEAD)
30 CI_REPO=$REPO_NAME-$BUILD_ID-$SNAP_REV
31
32-sed -i "s/~snappy-hwe-team\/snappy-hwe-snaps\/+git\/$REPO_NAME/~snappy-hwe-team\/snappy-hwe-snaps\/+git\/$CI_REPO/g" snapcraft.yaml
33+sed -i "s/~snappy-hwe-team\/snappy-hwe-snaps\/+git\/$REPO_NAME/~snappy-hwe-team\/snappy-hwe-snaps\/+git\/$CI_REPO/g" \
34+ $SNAPCRAFT_YAML_PATH
35+
36 # Commit only when anything has been changed as otherwise the whole
37 # job will be marked as failed
38 if ! git diff --exit-code &>/dev/null; then
39- git add snapcraft.yaml
40+ git add $SNAPCRAFT_YAML_PATH
41 git commit -m "jenkins-ci: Fix paths"
42 fi
43
44diff --git a/jobs/generic-release-snap b/jobs/generic-release-snap
45index 2ca6a04..a6f5908 100755
46--- a/jobs/generic-release-snap
47+++ b/jobs/generic-release-snap
48@@ -37,9 +37,12 @@ set_git_identity() {
49 git config user.email "ce-system-enablement@lists.canonical.com"
50 }
51
52+# Arguments are:
53+# $1 Version to be set in the snapcraft.yaml file
54+# $2 Path to the snapcraft.yaml file
55 bump_version_and_tag() {
56- sed -i -e "s/^version:\ .*/version: $1/g" snapcraft.yaml
57- git add snapcraft.yaml
58+ sed -i -e "s/^version:\ .*/version: $1/g" $2
59+ git add $2
60 git commit -m "Bump version to $1"
61 git tag -a -m "$1" $1 HEAD
62 }
63@@ -52,13 +55,20 @@ fi
64 git clone -b $RELEASE_BASE_BRANCH $REPOSITORY_URL $SNAP_NAME
65 cd $SNAP_NAME
66
67-if [ ! -e snapcraft.yaml ]; then
68- echo "ERROR: No top-level snapcraft.yaml file!"
69+SNAPCRAFT_YAML_PATH=
70+if [ -e snapcraft.yaml ]; then
71+ SNAPCRAFT_YAML_PATH=snapcraft.yaml
72+elif [ -e snap/snapcraft.yaml ]; then
73+ SNAPCRAFT_YAML_PATH=snap/snapcraft.yaml
74+fi
75+
76+if [ -z "$SNAPCRAFT_YAML_PATH" ]; then
77+ echo "ERROR: No snapcraft.yaml or snap/snapcraft.yaml file!"
78 exit 1
79 fi
80
81 set_git_identity
82-bump_version_and_tag $VERSION
83+bump_version_and_tag $VERSION $SNAPCRAFT_YAML_PATH
84
85 if [ "$RELEASE_FROM_STABLE" -eq 1 ]; then
86 git push origin $RELEASE_BASE_BRANCH
87@@ -87,8 +97,8 @@ else
88 $WORKSPACE/build-scripts/scripts/trigger-lp-build.py -s $SNAP_NAME -p
89
90 git checkout $RELEASE_BASE_BRANCH
91- sed -i -e "s/^version:\ .*/version: ${NEXT_VERSION}-dev/g" snapcraft.yaml
92- git add snapcraft.yaml
93+ sed -i -e "s/^version:\ .*/version: ${NEXT_VERSION}-dev/g" $SNAPCRAFT_YAML_PATH
94+ git add $SNAPCRAFT_YAML_PATH
95 git commit -m "Open development for ${NEXT_VERSION}-dev"
96 git push origin $RELEASE_BASE_BRANCH
97 fi

Subscribers

People subscribed via source and target branches

to all changes: