Merge ~kzapalowicz/snappy-hwe-snaps/+git/se-dev-tools:feature/add-tools into ~snappy-hwe-team/snappy-hwe-snaps/+git/se-dev-tools:master

Proposed by Konrad Zapałowicz
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: 7c61c2c9d8c1102813c43a2eae7ae8520cc2b999
Merged at revision: 7b8db785c91fa29c24b02d658b759fd5047c6859
Proposed branch: ~kzapalowicz/snappy-hwe-snaps/+git/se-dev-tools:feature/add-tools
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/se-dev-tools:master
Diff against target: 542 lines (+430/-53)
3 files modified
README.md (+53/-41)
bin/setup-snap-repo.sh (+357/-0)
snapcraft.yaml (+20/-12)
Reviewer Review Type Date Requested Status
System Enablement Bot continuous-integration Approve
Alfonso Sanchez-Beato Approve
Review via email: mp+325151@code.launchpad.net

Description of the change

Add additional tools such as:
  * flightschedule
  * bugsurfer
  * snap-revision

Reference: https://github.com/canonical-system-enablement/se-dev-tools

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
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Looks good, although I have some comments.

Also, a couple general things:

1. Not that I have used it a lot, but, which is the reason for dropping snap-release-email?

2. Please update README.md with usage of the newly included commands, or some link that describes that

review: Needs Fixing
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) :
Revision history for this message
Konrad Zapałowicz (kzapalowicz) wrote :

> Looks good, although I have some comments.
>
> Also, a couple general things:
>
> 1. Not that I have used it a lot, but, which is the reason for dropping snap-
> release-email?

With the current way of how we use the "Snaps to Release" list it became not useful.
I am however updating it to be smarter and much more helpful and that will come in
the future. For now I decided to get rid of a tool that might create confusion.

One can still use it though by cloning the repo manually & building.

>
> 2. Please update README.md with usage of the newly included commands, or some
> link that describes that

Revision history for this message
Konrad Zapałowicz (kzapalowicz) :
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

LGTM

review: Approve
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/README.md b/README.md
2index a6c1e19..d1571e5 100644
3--- a/README.md
4+++ b/README.md
5@@ -3,8 +3,9 @@
6 This is the snap to package se-dev-tools
7
8 This snap contains various utilities that help the SE team work with snaps:
9- - release email generator
10 - snap revision provider
11+ - flightschedule
12+ - bugsurfer
13
14 ### Snap revision provider
15
16@@ -16,11 +17,9 @@ https://github.com/canonical-system-enablement/snap-revision-provider
17 #### Usage
18
19 ```
20-Usage of ./snap-revision-provider:
21- -channel <channel name>
22- Channel from which the snap version is queried (default "candidate")
23- -snap <snap name>
24- Snap to query (default "bluez")
25+Usage: ./snap-revision-provider [snap]
26+ [snap]
27+ Snap to query
28 ```
29
30 #### Output
31@@ -28,47 +27,60 @@ Usage of ./snap-revision-provider:
32 Similar to rmadison:
33
34 ```
35-% ./snap-revision-provider -channel candidate -snap bluez
36- bluez | candidate | 5.37-2 | 13 | arm64
37- bluez | candidate | 5.37-2 | 12 | armhf
38- bluez | candidate | 5.37-2 | 15 | amd64
39- bluez | candidate | 5.37-2 | 10 | i386
40-
41+% ./snap-revision-provider udisks2
42+ udisks2 | stable | 2.1.7-8 | 81 | i386
43+ udisks2 | stable | 2.1.7-8 | 80 | amd64
44+ udisks2 | stable | 2.1.7-8 | 82 | arm64
45+ udisks2 | stable | 2.1.7-8 | 83 | armhf
46+ udisks2 | candidate | 2.6.4-2 | 102 | arm64
47+ udisks2 | candidate | 2.6.4-2 | 103 | armhf
48+ udisks2 | candidate | 2.6.4-2 | 100 | amd64
49+ udisks2 | candidate | 2.6.4-2 | 101 | i386
50+ udisks2 | beta | 2.6.4-2 | 101 | i386
51+ udisks2 | beta | 2.6.4-2 | 102 | arm64
52+ udisks2 | beta | 2.6.4-2 | 100 | amd64
53+ udisks2 | beta | 2.6.4-2 | 103 | armhf
54+ udisks2 | edge | 2.6.4-3-dev | 104 | amd64
55+ udisks2 | edge | 2.6.4-3-dev | 105 | i386
56+ udisks2 | edge | 2.6.4-3-dev | 106 | arm64
57+ udisks2 | edge | 2.6.4-3-dev | 107 | armhf
58 ```
59
60-### Release email generator
61-
62-This small utility helps to generate the release emails for snaps. It
63-uses the Trello board to retrieve the currently released snaps and
64-construct an email message.
65-
66-https://github.com/canonical-system-enablement/snap-release-email-generator
67-
68-#### Requirements
69-
70-trello_secrets.json file that contains the Application Key and Token.
71+### Flight Schedule
72
73-Follow the instructions here https://trello.com/app-key to obtain an API
74-key and token.
75-
76-```
77-konrad at annapurna in snap-release-email-generator (master) % cat trello_secrets.json
78-{"app_id":"APP ID","token":"TOKEN"}
79-
80-```
81+This tool queries the Launchpad and returns the list of the merge proposals
82+currently in motion for the [snappy-hwe-team](https://launchpad.net/~snappy-hwe-team)
83
84 #### Usage
85
86 ```
87-Usage of ./snap-release-email-generator:
88- -publisher <publisher name>
89- Snap publisher's name (default "Simon")
90- -secrets <trello_secrets.json>
91- Trello Secrets configuration (default "trello_secrets.json")
92+$ ./flightschedule
93 ```
94
95-#### Constraints
96-
97-Right now the app examines the contents of the "Snaps to Release" column.
98-If the card title changes and/or it's state is not accurate the release
99-email will contain inaccurate info. Make sure to read it before sending.
100+### Bug Surfer
101+
102+This tool queries the Launchpad and returns the list of 10 recently updated bugs
103+for a person who is logged in. Additionally it can read a config file named
104+*bugsurfer.config* from:
105+
106+* ~/.go-launchpad/
107+* * $SNAP_DATA/.go-launchpad
108+*
109+* for additional bug lists to provide.
110+*
111+* #### Config file format
112+*
113+* Each line shall contain either $DISTRIBUTION or $DISTRIBUTION/$PACKAGE. The
114+* Distribution is for example 'ubuntu', a package can be 'bluez'. It can be easily
115+* read from the bug url: https://bugs.launchpad.net/ubuntu/+source/bluez/+bug/1221524
116+* The pattern is: $DISTRIBUTION/+source/$PACKAGE
117+*
118+* For example a config file for including all bugs for ubuntu and for bluez
119+* separately would look like:
120+*
121+* ```
122+* $ cat ~/.go-launchpad/bugsurfer.config
123+* ubuntu
124+* ubuntu/bluez
125+* $
126+* ```
127diff --git a/bin/setup-snap-repo.sh b/bin/setup-snap-repo.sh
128new file mode 100755
129index 0000000..486d769
130--- /dev/null
131+++ b/bin/setup-snap-repo.sh
132@@ -0,0 +1,357 @@
133+#!/bin/sh -e
134+#
135+# Copyright (C) 2017 Canonical Ltd
136+#
137+# This program is free software: you can redistribute it and/or modify
138+# it under the terms of the GNU General Public License version 3 as
139+# published by the Free Software Foundation.
140+#
141+# This program is distributed in the hope that it will be useful,
142+# but WITHOUT ANY WARRANTY; without even the implied warranty of
143+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
144+# GNU General Public License for more details.
145+#
146+# You should have received a copy of the GNU General Public License
147+# along with this program. If not, see <http://www.gnu.org/licenses/>.
148+
149+# This function just displays help
150+show_help() {
151+ cat << EOF
152+Usage: ${0##*/} [OPTIONS] DIRECTORY
153+
154+This is a utility script that aids in creating a new snap. It creates the
155+necessary files. The snap name is deducted from the current working dir
156+
157+mandatory arguments:
158+ DIRECTORY The directory to where the snap should be initialized
159+ If does not exist, it will be created.
160+
161+optional arguments:
162+ --help Show this help and exit
163+ --no-tests Do not create spread tests templates
164+EOF
165+}
166+
167+snap_name=${PWD##*/}
168+skip_tests="no"
169+maintainer="$(git config user.name) <$(git config user.email)>"
170+
171+COLOR='\033[0;32m'
172+NC='\033[0m' # No Color
173+
174+TESTS_EXTRAS_URL="https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/tests-extras"
175+TESTS_EXTRAS_PATH=".tests-extras"
176+
177+
178+clone_tests_extras() {
179+ echo "INFO: Fetching tests-extras scripts into $TESTS_EXTRAS_PATH ..."
180+ git clone -b master $TESTS_EXTRAS_URL $TESTS_EXTRAS_PATH >/dev/null 2>&1
181+ if [ $? -ne 0 ]; then
182+ echo "ERROR: Failed to fetch the $TESTS_EXTRAS_URL repo, exiting.."
183+ exit 1
184+ fi
185+}
186+
187+create_run_tests() {
188+ if [ "$skip_tests" = "yes" ]; then
189+ touch .ci_tests_disabled
190+ git add .ci_tests_disabled
191+ else
192+ cp $TESTS_EXTRAS_PATH/templates/run-tests.sh .
193+ git add run-tests.sh
194+ fi
195+}
196+
197+create_file_changelog() {
198+ echo "<DATE> $maintainer - <VERSION>" > ChangeLog
199+ git add ChangeLog
200+}
201+
202+create_file_snapcraftyaml() {
203+ cat << EOF > snapcraft.yaml
204+name: $snap_name
205+version: <VERSION>
206+summary: <TODO>
207+description: |
208+ <ADD YOUR CONTENT HERE>
209+ Please find the source code at https://code.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/$snap_name
210+confinement: strict
211+grade: stable
212+
213+slots:
214+
215+plugs:
216+
217+apps:
218+
219+parts:
220+EOF
221+ git add snapcraft.yaml
222+}
223+
224+create_file_spreadyaml() {
225+ if [ "$skip_tests" = "yes" ]; then
226+ exit
227+ fi
228+
229+cat << 'EOF' > spread.yaml
230+#
231+# Copyright (C) 2015, 2016 Canonical Ltd
232+#
233+# This program is free software: you can redistribute it and/or modify
234+# it under the terms of the GNU General Public License version 3 as
235+# published by the Free Software Foundation.
236+#
237+# This program is distributed in the hope that it will be useful,
238+# but WITHOUT ANY WARRANTY; without even the implied warranty of
239+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
240+# GNU General Public License for more details.
241+#
242+# You should have received a copy of the GNU General Public License
243+# along with this program. If not, see <http://www.gnu.org/licenses/>.
244+
245+
246+project: <SNAPNAME>
247+
248+environment:
249+ PROJECT_PATH: /home/<SNAPNAME>
250+ TESTSLIB: $PROJECT_PATH/tests/lib
251+ SNAP_NAME: <SNAPNAME>
252+ # Allow the host to pass the channel to use for the test run
253+ SNAP_CHANNEL: $(HOST:echo $SNAP_CHANNEL)
254+
255+backends:
256+ qemu:
257+ systems:
258+ - ubuntu-core-16:
259+ username: test
260+ password: test
261+
262+# Put this somewhere where we have read-write access
263+path: /home/<SNAPNAME>
264+
265+exclude:
266+ - .git
267+
268+prepare: |
269+ . $TESTSLIB/prepare-all.sh
270+
271+suites:
272+ tests/main/:
273+ summary: Full-system tests for <SNAPNAME>
274+ systems:
275+ - ubuntu-core-16
276+ prepare: |
277+ . $TESTSLIB/prepare.sh
278+ restore-each: |
279+ . $TESTSLIB/restore-each.sh
280+EOF
281+ git add spread.yaml
282+}
283+
284+create_file_gitignore() {
285+ cat << 'EOF' > .gitignore
286+.tests-extras
287+EOF
288+ git add .gitignore
289+}
290+
291+create_file_maintainers() {
292+ echo $maintainer > MAINTAINERS
293+ git add MAINTAINERS
294+}
295+
296+create_file_readme() {
297+ cat << EOF > ./README.md
298+## $snap_name
299+
300+This is the snap to package $snap_name
301+EOF
302+
303+ if [ "$skip_tests" = "yes" ]; then
304+ cat << 'EOF' >> README.md
305+
306+## Running tests
307+
308+We have a set of spread (https://github.com/snapcore/spread) tests which
309+can be executed on a virtual machine or real hardware.
310+
311+In order to run those tests you need the follow things
312+
313+ * ubuntu-image
314+ * spread
315+
316+ You can install both as a snap
317+
318+```
319+ $ snap install --edge --devmode ubuntu-image
320+ $ snap install --devmode spread
321+```
322+
323+NOTE: As of today the version of spread in the store misses support for qemu so
324+you have to build your own one for now:
325+
326+```
327+ $ WORKDIR=`mktemp -d`
328+ $ export GOPATH=$WORKDIR
329+ $ go get -d -v github.com/snapcore/spread/...
330+ $ go build github.com/snapcore/spread/cmd/spread
331+ $ sudo cp spread /usr/local/bin
332+```
333+
334+Make sure /usr/local/bin is in your path and is used as default:
335+
336+```
337+ $ which spread
338+ /usr/local/bin/spread
339+```
340+
341+Now you have everything to run the test suite.
342+
343+```
344+ $ ./run-tests
345+```
346+
347+The script will reach out to tests-extras repository and download the helper
348+scripts: image creator and test runner. Next it will execute the test runner
349+passing the arguments as-is.
350+
351+The helper scripts are tracked here:
352+https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/tests-extras
353+
354+The test runner script will create an image via ubuntu-image and make it available
355+to spread by copying it to ~/.spread/qemu or ~/snap/spread/<version>/.spread/qemu
356+depending on if you're using a local spread version or the one from the
357+snap.
358+
359+If you want to see more verbose debugging output of spread run
360+
361+```
362+ $ ./run-tests --debug
363+```
364+
365+If you do not want to build the network-manager snap from source but test one
366+from a specific channel start testing with
367+
368+```
369+ $ ./run-tests --channel=beta --test-from-channel
370+```
371+
372+You can also run spread directly which allows you run just specific tests
373+
374+```
375+ $ spread tests/main/installation
376+```
377+
378+This will by default build the network-manager snap from source. If you
379+want it to test it from a specific channel run
380+
381+```
382+ $ SNAP_CHANNEL=candidate spread tests/main/installation
383+```
384+
385+And if you want to run an entire suite
386+
387+```
388+ $ spread tests/main/
389+```
390+
391+## Available test suites
392+
393+<ADD YOUR CONTENT HERE>
394+
395+EOF
396+ fi
397+ git add README.md
398+}
399+
400+# Here it starts
401+
402+# Check if the scrips has been properly called, if not show help and exit.
403+if [ $# -eq 0 ]; then
404+ echo "No arguments were specified"
405+ echo ""
406+ show_help
407+ exit 1
408+fi
409+
410+# Parse the arguments
411+while [ -n "$1" ]; do
412+ case "$1" in
413+ --help)
414+ show_help
415+ exit
416+ ;;
417+ --no-tests)
418+ skip_tests="yes"
419+ shift
420+ ;;
421+ *)
422+ if [ -d $1 ]; then
423+ cd $1
424+ snap_name=${PWD##*/}
425+ shift
426+ else
427+ echo "Directory $1 does not exists, creating"
428+ mkdir -p $1
429+ cd $1
430+ snap_name=${PWD##*/}
431+ shift
432+ fi
433+ ;;
434+ esac
435+done
436+
437+# If this is not a git repository
438+# then initialize it
439+if [ -d .git ]; then
440+ echo "${COLOR}Good, this is git repo${NC}"
441+else
442+ echo "${COLOR}This is not git repo, initializing${NC}"
443+ git init
444+fi
445+
446+# Add remote
447+echo "${COLOR}Adding remote origin git://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/$snap_name${NC}"
448+git remote add origin git://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/$snap_name
449+
450+# On branch master add empty README.md and commit
451+echo "${COLOR}Making an initial commit with empty README.md${NC}"
452+echo "# $snap_name" > README.md
453+git add README.md && git commit -m "Initial import"
454+
455+# From now-on everything happens on feature/new-snap branch
456+echo "${COLOR}Creating feature/new-snap branch for development${NC}"
457+git checkout -b feature/new-snap
458+
459+echo "${COLOR}Now adding necessary files${NC}"
460+clone_tests_extras
461+
462+create_file_gitignore
463+create_file_maintainers
464+create_run_tests
465+create_file_readme
466+create_file_snapcraftyaml
467+create_file_spreadyaml
468+create_file_changelog
469+
470+echo "${COLOR}Making an initial commit${NC}"
471+git commit -m "add templates for snap development"
472+
473+echo ""
474+echo "At this point you are on a feature/new-snap branch with all the"
475+echo "necessary files created and commited. Your job now is to fill them"
476+echo "with valid data."
477+echo ""
478+echo "There is also 'master' branch available with an empty README.md"
479+echo "commited (but not pushed) there."
480+echo ""
481+echo "I have not pushed anything and it is your job to do so. Make sure"
482+echo "that you follow the way-of-working that is:"
483+echo " - First git push origin master"
484+echo " - Add your own remote pointing to your repository and push"
485+echo " feature/new-snap there."
486+echo " - Submit your snap as a MP against master branch that you just have"
487+echo " pushed directly"
488+echo ""
489+echo "Have fun!"
490diff --git a/snapcraft.yaml b/snapcraft.yaml
491index 1e8e505..b677374 100644
492--- a/snapcraft.yaml
493+++ b/snapcraft.yaml
494@@ -9,28 +9,36 @@ confinement: strict
495 grade: stable
496
497 apps:
498- snap-revision:
499- command: snap-revision-provider.git
500+ bugsurfer:
501+ command: "bin/bugsurfer"
502 plugs:
503 - network
504- snap-release-email:
505- command: snap-release-email-generator.git
506+ flightschedule:
507+ command: "bin/flightschedule"
508+ plugs:
509+ - network
510+ snap-revision:
511+ command: "bin/snap-revision-provider"
512 plugs:
513 - network
514- - home
515 shyaml:
516 command: bin/shyaml
517+ setup-snap-repo:
518+ command: "bin/setup-snap-repo.sh"
519+ plugs:
520+ - home
521
522 parts:
523- snap-revision:
524- plugin: go
525- source: https://github.com/canonical-system-enablement/snap-revision-provider.git
526- source-type: git
527- snap-release-email-generator:
528+ se-dev-tools:
529 plugin: go
530- source: https://github.com/canonical-system-enablement/snap-release-email-generator.git
531- source-type: git
532+ go-importpath: github.com/canonical-system-enablement/se-dev-tools
533+ source: https://github.com/canonical-system-enablement/se-dev-tools.git
534 shyaml:
535 plugin: python
536 python-packages:
537 - shyaml
538+ setup-snap-repo:
539+ source: bin/
540+ plugin: dump
541+ organize:
542+ setup-snap-repo.sh: bin/setup-snap-repo.sh

Subscribers

People subscribed via source and target branches