Skip to content

Commit

Permalink
Merge branch 'master' into jsonrpc_exception_enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
robputt authored Oct 25, 2021
2 parents 12ee94a + f8b2d8c commit 4cc1462
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.
* @NebraLtd/developers

# See example for more details: https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-code-owners#example-of-a-codeowners-file
35 changes: 35 additions & 0 deletions .github/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# How to contriubte

Thanks for your interest in contributing to Nebra. We enforce certain rules on commits with the following goals in mind:

- Be able to reliably auto-generate the `CHANGELOG.md` *without* any human intervention.
- Be able to automatically and correctly increment the semver version number based on what was done since the last release.
- Be able to get a quick overview of what happened to the project by glancing over the commit history.
- Be able to automatically reference relevant changes from a dependency upgrade.

Our CI will run checks to ensure this guidelines are followed and won't allow merging contributions that don't adhere to them. Version number and changelog are automatically handled by the CI build flow after a pull request is merged. You only need to worry about the commit itself.

## Commit structure

Each commit message should consist of a header a body and a footer, structured in the following format:

```
<scope (optional)>: <subject (mandatory)>
--BLANK LINE--
(optional) <body>
--BLANK LINE--
(optional) Connects-to: #issue-number
(optional) Closes: #issue-number
(mandatory) Change-type: major | minor | patch
(optional) Signed-off-by: Foo Bar <[email protected]>
```

Note that:
- Blank lines are required to separate header from body and body from footer. You don't need to add two blank lines if you don't add a body.
- `scope`: If your commit touches a well defined component/part/service please addthe scope tag to clarify. Some examples: `docs`, `images`, `typos`.
- `subject`: The subject should contain a short description of the change. Use the imperative, present tense.
- `body`: A detailed description of changes being made and reasoning if necessary. This may contain several paragraphs.
- `Connects-to`: If your commit is connected to an existing issue, link it by adding this tag with `#issue-number`. Example: `Connects-to: #123`
- `Closes`: If your commit fixes an existing issue, link it by adding this tag with `#issue-number`. Example: `Closes: #123`
- `Change-type`: At least one of your commits on a PR needs to have this tag. You have the flexibility, and it's good practise, to use this tag in as many commits as you see fit; in the end, the resulting change type for the scope of the PR will be folded down to the biggest one as marked in the commits (`major>minor>patch`). Our version numbering adheres to [Semantic Versioning](http://semver.org/).
- `Signed-off-by`: Sign your commits by providing your full name and email address in the format: `Name Surname <[email protected]>`. *This is an optional tag.*
9 changes: 9 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**Why**
<!-- What is the objective of this work? -->

**How**
<!-- What steps were taken in this work? -->
<!-- Its encouraged to copy information from other places even if it seems redundant -->

**References**
<!-- Links to related issues, relevant documentation, etc. -->
13 changes: 9 additions & 4 deletions .github/workflows/publish-to-pypi-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: aarch64-unknown-linux-musl
target: arm-unknown-linux-gnueabihf
override: true

- name: Clone repo
run: |
git clone --branch v0.1.3 https://github.com/helium/gateway-mfr-rs.git .
git clone --branch v0.1.5 https://github.com/helium/gateway-mfr-rs.git .
- name: Run cargo check
uses: actions-rs/cargo@v1
Expand All @@ -32,11 +32,11 @@ jobs:
with:
use-cross: true
command: build
args: --target aarch64-unknown-linux-musl --release
args: --target arm-unknown-linux-gnueabihf --release

- name: Copy release file
run: |
cp ./target/aarch64-unknown-linux-musl/release/gateway_mfr gateway_mfr
cp ./target/arm-unknown-linux-gnueabihf/release/gateway_mfr gateway_mfr
- uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -82,7 +82,12 @@ jobs:
name: wheels
path: ./dist/*

- name: Get changed files
id: changed-files
uses: tj-actions/[email protected]

- name: Publish distribution 📦 to Test PyPI
if: contains(steps.changed-files.outputs.modified_files, 'setup.py')
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: aarch64-unknown-linux-musl
target: arm-unknown-linux-gnueabihf
override: true

- name: Clone repo
run: |
git clone --branch v0.1.3 https://github.com/helium/gateway-mfr-rs.git .
git clone --branch v0.1.5 https://github.com/helium/gateway-mfr-rs.git .
- name: Run cargo check
uses: actions-rs/cargo@v1
Expand All @@ -32,11 +32,11 @@ jobs:
with:
use-cross: true
command: build
args: --target aarch64-unknown-linux-musl --release
args: --target arm-unknown-linux-gnueabihf --release

- name: Copy release file
run: |
cp ./target/aarch64-unknown-linux-musl/release/gateway_mfr gateway_mfr
cp ./target/arm-unknown-linux-gnueabihf/release/gateway_mfr gateway_mfr
- uses: actions/upload-artifact@v2
with:
Expand Down
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,24 @@ project's Dockerfile.
```Dockerfile
RUN pip3 install setuptools wheel
RUN pip3 install --target="$OUTPUTS_DIR" git+https://github.com/NebraLtd/hm-pyhelper@BRANCH_NAME
``````
``````

## Releasing

To release, use the [Github new release flow](https://github.com/NebraLtd/hm-pyhelper/releases/new).

1. Create a new tag in format `vX.Y.Z`. You can use a previously tagged commit, but this is not necessary.
2. Make sure the tag you created matches the value in setup.py.
3. Select `master` as the target branch. If you do not select the master branch, the tag should be in format `vX.Y.Z-rc.N`.
4. Title: `Release vX.Y.Z`.
5. Body:

**Note: you can create the release notes automatically by selecting the "Auto-generate release notes" option on the releases page.**

```
## What's Changed
* Foo
* Bar

**Full Changelog**: https://github.com/NebraLtd/hm-pyhelper/compare/v0.0.A...v0.0.Z
```
4 changes: 4 additions & 0 deletions hm_pyhelper/miner_json_rpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ def get_peer_addr(self):

def get_peer_book(self):
return self.__fetch_data('peer_book', addr='self')

def get_firmware_version(self):
summary = self.get_summary()
return summary.get('firmware_version')
34 changes: 34 additions & 0 deletions hm_pyhelper/tests/test_miner_json_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,37 @@ def test_get_peer_book(self, mock_json_rpc_client):
addr='self'
)
self.assertEqual(result, [])

@mock.patch('hm_pyhelper.miner_json_rpc.client.request')
def test_get_firmware_version(self, mock_json_rpc_client):
firmware_version = '2021.10.18.0'
summary = {
'block_age': 1136610,
'epoch': 25612,
'firmware_version': firmware_version,
'gateway_details': 'undefined',
'height': 993640,
'mac_addresses': [
{'eth0': '0242AC110002'},
{'ip6tnl0': '00000000000000000000000000000000'},
{'tunl0': '00000000'},
{'lo': '000000000000'}
],
'name': 'scruffy-chocolate-shell',
'peer_book_entry_count': 3,
'sync_height': 993640,
'uptime': 144,
'version': 10010005
}
mock_json_rpc_client.return_value = Response(
data=Result(
result=summary
)
)
client = MinerClient()
result = client.get_firmware_version()
mock_json_rpc_client.assert_called_with(
BASE_URL,
'info_summary'
)
self.assertEqual(result, firmware_version)

0 comments on commit 4cc1462

Please sign in to comment.