-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from LedgerHQ/setup
Setup
- Loading branch information
Showing
12 changed files
with
556 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
name: Build, test and deploy Ledgered | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
tags: | ||
- '*' | ||
branches: | ||
- master | ||
- develop | ||
pull_request: | ||
branches: | ||
- master | ||
- develop | ||
|
||
jobs: | ||
|
||
build_install_test: | ||
name: Build, install and test the Ledgered Python package | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Clone | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build & install | ||
run: | | ||
pip install -U pip | ||
pip install -U .[dev] | ||
- name: Run tests and generate coverage | ||
run: pytest -v --tb=short tests/ --cov ledgered --cov-report xml | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
name: codecov-ledgered | ||
|
||
|
||
package_and_deploy: | ||
name: Build and deploy Ledgered Python package | ||
runs-on: ubuntu-latest | ||
needs: [build_install_test] | ||
steps: | ||
|
||
- name: Clone | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# Fetching dependencies from test.pypi,org or pypi.org depending on the package destination: | ||
# tag -> pypi.org, not tag -> test.pypi.org | ||
- name: Build Ledgered Python package | ||
run: | | ||
pip install --upgrade pip build twine | ||
if [[ ${{ github.ref }} == "refs/tags/"* ]]; \ | ||
then \ | ||
python -m build; \ | ||
pip install . | ||
else \ | ||
PIP_EXTRA_INDEX_URL=https://test.pypi.org/simple/ python -m build; \ | ||
pip install --extra-index-url https://test.pypi.org/simple/ . | ||
fi | ||
python -m twine check dist/* | ||
echo "TAG_VERSION=$(python -c 'from ledgered import __version__; print(__version__)')" >> "$GITHUB_ENV" | ||
- name: Display current status | ||
run: | | ||
echo "Current status is:" | ||
if [[ ${{ github.ref }} == "refs/tags/"* ]]; \ | ||
then \ | ||
echo "- Triggered from tag, will be deployed on pypi.org"; \ | ||
else \ | ||
echo "- Not triggered from tag, will be deployed on test.pypi.org"; \ | ||
fi | ||
echo "- Tag version: ${{ env.TAG_VERSION }}" | ||
- name: Check version against CHANGELOG | ||
if: startsWith(github.ref, 'refs/tags/') | ||
run: | | ||
CHANGELOG_VERSION=$(grep -Po '(?<=## \[)(\d+\.)+[^\]]' CHANGELOG.md | head -n 1) | ||
if [ "${{ env.TAG_VERSION }}" == "${CHANGELOG_VERSION}" ]; \ | ||
then \ | ||
exit 0; \ | ||
else \ | ||
echo "Tag '${{ env.TAG_VERSION }}' and CHANGELOG '${CHANGELOG_VERSION}' versions mismatch!"; \ | ||
exit 1; \ | ||
fi | ||
- name: Publish Python package on pypi.org | ||
if: success() && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | ||
run: python -m twine upload dist/* | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_PUBLIC_API_TOKEN }} | ||
TWINE_NON_INTERACTIVE: 1 | ||
|
||
- name: Publish a release on the repo | ||
if: success() && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | ||
uses: "marvinpinto/action-automatic-releases@latest" | ||
with: | ||
automatic_release_tag: "v${{ env.TAG_VERSION }}" | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
prerelease: true | ||
files: | | ||
LICENSE | ||
dist/ | ||
- name: Publish Python package on test.pypi.org | ||
if: success() && github.event_name == 'push' | ||
run: python -m twine upload --repository testpypi dist/* | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PUBLIC_API_TOKEN }} | ||
TWINE_NON_INTERACTIVE: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: "CodeQL" | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- develop | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: | ||
- master | ||
- develop | ||
schedule: | ||
- cron: '35 0 * * 5' | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
|
||
strategy: | ||
fail-fast: false | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
# Initializes the CodeQL tools for scanning. | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: "python" | ||
# If you wish to specify custom queries, you can do so here or in a config file. | ||
# By default, queries listed here will override any specified in a config file. | ||
# Prefix the list here with "+" to use these queries and those in the config file. | ||
# queries: ./path/to/local/query, your-org/your-repo/queries@main | ||
queries: +security-and-quality | ||
|
||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). | ||
# If this step fails, then you should remove it and run the build manually (see below) | ||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v2 | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Fast checks | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- develop | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
name: Linting | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone | ||
uses: actions/checkout@v3 | ||
- run: pip install flake8 | ||
- name: Flake8 lint Python code | ||
run: find src/ -type f -name '*.py' -exec flake8 --max-line-length=120 '{}' '+' | ||
|
||
yapf: | ||
name: Formatting | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone | ||
uses: actions/checkout@v3 | ||
- run: pip install yapf toml | ||
- name: Yapf source formatting | ||
run: | | ||
yapf src/ --recursive -d | ||
mypy: | ||
name: Type checking | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone | ||
uses: actions/checkout@v3 | ||
- run: pip install mypy types-toml | ||
- name: Mypy type checking | ||
run: mypy src | ||
|
||
bandit: | ||
name: Security checking | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone | ||
uses: actions/checkout@v3 | ||
- run: pip install bandit | ||
- name: Bandit security checking | ||
run: bandit -r src -ll | ||
|
||
misspell: | ||
name: Check misspellings | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone | ||
uses: actions/checkout@v3 | ||
- name: Check misspellings | ||
uses: codespell-project/actions-codespell@v1 | ||
with: | ||
builtin: clear,rare | ||
check_filenames: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ | |
coverage.xml | ||
build/ | ||
dist/ | ||
__version__.py | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [0.1.0] - 2023-10-17 | ||
|
||
### Added | ||
|
||
- 'ledgered' library Python package | ||
- Application 'ledger_app.toml' manifest parser utilitary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
[build-system] | ||
requires = [ | ||
"setuptools>=45", | ||
"setuptools_scm[toml]>=6.2", | ||
"wheel" | ||
] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "ledgered" | ||
authors = [ | ||
{ name = "Ledger", email = "hello@ledger.fr" } | ||
] | ||
description = "Python tools, utils, libraries, to be used with Ledger cryptodevices" | ||
readme = { file = "README.md", content-type = "text/markdown" } | ||
license = { file = "LICENSE" } | ||
classifiers = [ | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Operating System :: POSIX :: Linux", | ||
"Operating System :: Microsoft :: Windows", | ||
"Operating System :: MacOS :: MacOS X", | ||
] | ||
dynamic = [ "version" ] | ||
requires-python = ">=3.7" | ||
dependencies = [ | ||
"toml", | ||
] | ||
|
||
[project.optional-dependencies] | ||
dev = [ | ||
"pytest", | ||
"pytest-cov" | ||
] | ||
|
||
[project.urls] | ||
Home = "https://github.com/LedgerHQ/ledgered" | ||
|
||
[project.scripts] | ||
ledger-manifest = "ledgered.utils.manifest:main" | ||
|
||
[tool.setuptools_scm] | ||
write_to = "src/ledgered/__version__.py" | ||
local_scheme = "no-local-version" | ||
|
||
[tool.mypy] | ||
ignore_missing_imports = true | ||
|
||
[tool.yapf] | ||
based_on_style = "pep8" | ||
column_limit = 100 | ||
|
||
[tool.coverage.report] | ||
show_missing = true | ||
exclude_lines = [ | ||
"@abstractmethod", | ||
"pragma: no cover" | ||
] | ||
|
||
[tool.bandit] | ||
skips = ["B101"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
try: | ||
from ledgered.__version__ import __version__ # noqa | ||
except ImportError: | ||
__version__ = "unknown version" # noqa |
Empty file.
Oops, something went wrong.