Skip to content

Commit

Permalink
Merge pull request #1 from julianneswinoga/js/add-snap-build
Browse files Browse the repository at this point in the history
Js/add snap build
  • Loading branch information
julianneswinoga committed Sep 29, 2023
2 parents 7c656b0 + 7bfcea7 commit 3589163
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 1 deletion.
66 changes: 66 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,42 @@ jobs:
root: .
paths:
- dist
snap_build:
machine:
# https://circleci.com/developer/machine/image/ubuntu-2004
# lxd fails with 22.04... https://discuss.circleci.com/t/lxd-networking-fails-in-2204-image-not-2004-image/44581
image: ubuntu-2004:2023.07.1
steps:
- checkout
- run:
name: apt update
command: sudo apt update
- run:
name: Install snapd
command: sudo apt install snapd
- run:
name: Install lxd
command: sudo snap install lxd
- run:
name: Init lxd
command: lxd init --auto
- run:
name: Install Snapcraft
command: sudo snap install snapcraft --classic
- run:
name: Build Snap
command: snapcraft --verbose
- run:
name: Move .snap file
command: |
mkdir snap_dist
mv *.snap snap_dist/
- store_artifacts:
path: snap_dist
- persist_to_workspace:
root: .
paths:
- snap_dist
poetry_publish:
executor:
name: python/default
Expand Down Expand Up @@ -81,6 +117,25 @@ jobs:
command: |
VERSION=$(echo ./dist/*.whl | cut -d- -f2)
ghr -token ${GITHUB_PAT} -username ${CIRCLE_PROJECT_USERNAME} -repository ${CIRCLE_PROJECT_REPONAME} -commitish ${CIRCLE_SHA1} -parallel 1 -b "Automatic release ${VERSION}" ${VERSION} ./dist
snap_publish:
machine:
image: ubuntu-2204:2023.07.2 # https://circleci.com/developer/machine/image/ubuntu-2204
steps:
- attach_workspace:
at: .
- run:
name: apt update
command: sudo apt update
- run:
name: Install snapd
command: sudo apt install snapd
- run:
name: Install Snapcraft
command: sudo snap install snapcraft --classic
- run:
name: Snapcraft Upload
# Requires SNAPCRAFT_STORE_CREDENTIALS
command: snapcraft upload --verbose --release=stable ./snap_dist/*.snap

tag-filter: &tag-filter
filters:
Expand All @@ -99,11 +154,22 @@ workflows:
filters: # required since `deploy` has tag filters AND requires `build`
tags:
only: /.*/
- snap_build:
filters: # required since `deploy` has tag filters AND requires `build`
tags:
only: /.*/
- poetry_publish:
requires:
- build_install_test
- snap_build
<<: *tag-filter
- github_publish:
requires:
- build_install_test
- snap_build
<<: *tag-filter
- snap_publish:
requires:
- build_install_test
- snap_build
<<: *tag-filter
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ dist/
docs/build/
docs/source/_autosummary/
.coverage
*.snap
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,26 @@ Don't know where to begin? Check out the [quick-start](https://tracex-parser.rea
More documentation about ThreadX trace buffers can be found [here](https://docs.microsoft.com/en-us/azure/rtos/tracex/chapter5).

## Install
`pip3 install tracex-parser`
### Via `pip`
```console
$ python3 -m pip install tracex-parser
```

### Via `snap`
> [!NOTE]
> This installation method only allows you to use the command line file parser, not the Python library
```console
$ sudo snap install tracex-parser
$ sudo snap alias tracex-parser.parse-trx parse-trx # Register the `parse-trx` command, otherwise you will need to use tracex-parser.parse-trx
$ sudo snap connect tracex-parser:removable-media # Required to allow reading of files outside of /home
```

> [!NOTE]
> Due to how snap packages work, there are restrictions on which files snaps are allowed to access.
> Currently only `/home`, `/media`, `/run/media`, `/mnt` are able to be read.
> For example attempting to read a file in `/tmp` will throw a `No such file or directory` error

## Example trace buffers
In the repository source there are a couple example TraceX traces which can be used to verify that things are working correctly.
Expand Down
33 changes: 33 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: tracex-parser
base: core22
adopt-info: tracex-parser
summary: Parse ThreadX trace buffers into both human and machine-readable formats
description: |
This is a python package that parses ThreadX trace buffers into both
human and machine-readable formats.
website: https://github.com/julianneswinoga/tracex_parser
source-code: https://github.com/julianneswinoga/tracex_parser

grade: stable
confinement: strict

parts:
tracex-parser:
plugin: python
source: .
python-packages:
- poetry
override-build: |
craftctl default
git clean -d --force --force -x
poetry build --no-ansi --no-interaction
python3 -m pip install ./dist/tracex_parser-*.whl
VERSION=$(echo ./dist/*.whl | cut -d- -f2)
craftctl set version=${VERSION}
apps:
parse-trx:
plugs:
- home
- removable-media
command: bin/python3 -m tracex_parser.file_parser

0 comments on commit 3589163

Please sign in to comment.