Skip to content

Commit 9581cb1

Browse files
authored
Modernize things a bit. (#3)
1 parent b8d3cbc commit 9581cb1

File tree

9 files changed

+97
-40
lines changed

9 files changed

+97
-40
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
push:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v1
16+
- name: Set up Python 3.7
17+
uses: actions/setup-python@v1
18+
with:
19+
python-version: 3.7
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
python -m pip install flake8
24+
- name: Lint with flake8
25+
run: |
26+
python -m flake8 . --count --max-line-length=79 --statistics

.github/workflows/pythonapp.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v1
13+
- name: Set up Python 3.7
14+
uses: actions/setup-python@v1
15+
with:
16+
python-version: 3.7
17+
- name: Set env
18+
run: echo ::set-env name=RELEASE_VERSION::$(echo ${GITHUB_REF:11})
19+
- name: Package project
20+
run: |
21+
./package.sh
22+
- name: Create Release
23+
id: create_release
24+
uses: actions/create-release@v1.0.0
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
with:
28+
tag_name: ${{ github.ref }}
29+
release_name: Release ${{ env.RELEASE_VERSION }}
30+
draft: false
31+
prerelease: false
32+
- name: Upload Release Asset
33+
id: upload-release-asset
34+
uses: actions/upload-release-asset@v1.0.1
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
with:
38+
upload_url: ${{ steps.create_release.outputs.upload_url }}
39+
asset_path: tide-calendar-adapter-${{ env.RELEASE_VERSION }}.tgz
40+
asset_name: tide-calendar-adapter-${{ env.RELEASE_VERSION }}.tgz
41+
asset_content_type: application/gnutar
42+
- name: Upload Release Asset Checksum
43+
id: upload-release-asset-checksum
44+
uses: actions/upload-release-asset@v1.0.1
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
with:
48+
upload_url: ${{ steps.create_release.outputs.upload_url }}
49+
asset_path: tide-calendar-adapter-${{ env.RELEASE_VERSION }}.tgz.sha256sum
50+
asset_name: tide-calendar-adapter-${{ env.RELEASE_VERSION }}.tgz.sha256sum
51+
asset_content_type: text/plain

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.pyc
2+
*.sha256sum
23
*.swp
34
*.tgz
45
lib/

main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from pkg.tide_calendar_adapter import TideCalendarAdapter # noqa
1212

1313

14+
_DEBUG = False
1415
_ADAPTER = None
1516

1617
print = functools.partial(print, flush=True)
@@ -27,7 +28,7 @@ def cleanup(signum, frame):
2728
if __name__ == '__main__':
2829
signal.signal(signal.SIGINT, cleanup)
2930
signal.signal(signal.SIGTERM, cleanup)
30-
_ADAPTER = TideCalendarAdapter(verbose=True)
31+
_ADAPTER = TideCalendarAdapter(verbose=_DEBUG)
3132

3233
# Wait until the proxy stops running, indicating that the gateway shut us
3334
# down.

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@
4545
}
4646
},
4747
"short_name": "Tide",
48-
"version": "0.2.1"
48+
"version": "0.3.0"
4949
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tide-calendar-adapter",
33
"display_name": "Tide Calendar",
4-
"version": "0.2.1",
4+
"version": "0.3.0",
55
"description": "Tide calendar for Mozilla WebThings Gateway",
66
"author": "Mozilla IoT",
77
"main": "main.py",

package.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#!/bin/bash
2-
3-
set -e
1+
#!/bin/bash -e
42

53
version=$(grep version package.json | cut -d: -f2 | cut -d\" -f2)
64

@@ -20,8 +18,13 @@ find package -type d -empty -delete
2018

2119
# Generate checksums
2220
cd package
23-
find . -type f \! -name SHA256SUMS -exec sha256sum {} \; >> SHA256SUMS
21+
find . -type f \! -name SHA256SUMS -exec shasum --algorithm 256 {} \; >> SHA256SUMS
2422
cd -
2523

2624
# Make the tarball
27-
tar czf "tide-calendar-adapter-${version}.tgz" package
25+
TARFILE="tide-calendar-adapter-${version}.tgz"
26+
tar czf ${TARFILE} package
27+
28+
shasum --algorithm 256 ${TARFILE} > ${TARFILE}.sha256sum
29+
30+
rm -rf SHA256SUMS package

pkg/tide_calendar_device.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(self, adapter, _id, station_id, unit):
4747
self,
4848
'lowTideTime',
4949
{
50-
'label': 'Low Tide Time',
50+
'title': 'Low Tide Time',
5151
'type': 'string',
5252
'readOnly': True,
5353
},
@@ -58,7 +58,7 @@ def __init__(self, adapter, _id, station_id, unit):
5858
self,
5959
'lowTideLevel',
6060
{
61-
'label': 'Low Tide Level',
61+
'title': 'Low Tide Level',
6262
'type': 'number',
6363
'unit': 'foot' if self.unit == 'english' else 'meter',
6464
'readOnly': True,
@@ -70,7 +70,7 @@ def __init__(self, adapter, _id, station_id, unit):
7070
self,
7171
'lowTide',
7272
{
73-
'label': 'Low Tide',
73+
'title': 'Low Tide',
7474
'type': 'boolean',
7575
'readOnly': True,
7676
},
@@ -81,7 +81,7 @@ def __init__(self, adapter, _id, station_id, unit):
8181
self,
8282
'highTideTime',
8383
{
84-
'label': 'High Tide Time',
84+
'title': 'High Tide Time',
8585
'type': 'string',
8686
'readOnly': True,
8787
},
@@ -92,7 +92,7 @@ def __init__(self, adapter, _id, station_id, unit):
9292
self,
9393
'highTideLevel',
9494
{
95-
'label': 'High Tide Level',
95+
'title': 'High Tide Level',
9696
'type': 'number',
9797
'unit': 'foot' if self.unit == 'english' else 'meter',
9898
'readOnly': True,
@@ -104,7 +104,7 @@ def __init__(self, adapter, _id, station_id, unit):
104104
self,
105105
'highTide',
106106
{
107-
'label': 'High Tide',
107+
'title': 'High Tide',
108108
'type': 'boolean',
109109
'readOnly': True,
110110
},
@@ -116,7 +116,7 @@ def __init__(self, adapter, _id, station_id, unit):
116116
self,
117117
'currentLevel',
118118
{
119-
'label': 'Current Level',
119+
'title': 'Current Level',
120120
'type': 'number',
121121
'unit': 'foot' if self.unit == 'english' else 'meter',
122122
'readOnly': True,

0 commit comments

Comments
 (0)