Skip to content

Commit

Permalink
Merge pull request #165 from LedgerHQ/ci/clean
Browse files Browse the repository at this point in the history
Deployment configuration cleaning
  • Loading branch information
lpascal-ledger authored Feb 7, 2024
2 parents 82f4295 + 908831e commit 063cd2c
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 121 deletions.
39 changes: 15 additions & 24 deletions .github/workflows/build_and_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -68,16 +68,15 @@ jobs:

package_and_deploy:
name: Build and deploy Ragger Python Package
needs: [build_install_test]
runs-on: ubuntu-latest
steps:

- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
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 Ragger Python package
run: |
pip install --upgrade pip build twine
Expand All @@ -89,24 +88,24 @@ jobs:
- 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"; \
if [[ ${{ github.ref }} == "refs/tags/"* ]];
then
echo "- Triggered from tag, package will be a release";
else
echo "- Not triggered from tag, package will be a pre-release";
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; \
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
Expand All @@ -123,15 +122,7 @@ jobs:
with:
automatic_release_tag: "v${{ env.TAG_VERSION }}"
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: true
prerelease: false
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
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install APT dependencies
run: |
sudo apt-get update
sudo apt-get install graphviz
- name: Install Python dependencies
run: pip install .[doc]
run: |
pip install -U pip
pip install .[doc]
- name: Generating automatic resources
run: (cd doc && make gen_resources)
- name: Generate the documentation
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/fast-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
- run: pip install flake8
uses: actions/checkout@v4
- run: pip install flake8 flake8-pyproject
- name: Flake8 lint Python code
run: find src/ -type f -name '*.py' -exec flake8 --max-line-length=120 '{}' '+'
run: flake8 src/

yapf:
name: Formatting
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
- run: pip install yapf toml
- name: Yapf source formatting
run: |
Expand All @@ -37,7 +37,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
- run: pip install mypy
- name: Mypy type checking
run: mypy src
Expand All @@ -47,7 +47,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
- run: pip install bandit
- name: Bandit security checking
run: bandit -r src -ll
Expand All @@ -57,7 +57,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Check misspellings
uses: codespell-project/actions-codespell@v1
with:
Expand Down
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,15 @@ Once done, you can generate the documentation:

Versions and changes are documented into the [CHANGELOG.md](CHANGELOG.MD) file.

Pushing a tag on the central GitHub repository triggers a deployment. Python packages are deployed
onto `pypi.org` or `test.pypi.org` depending on the tag, which must follow the following scheme:

- if the tag starts with `test-v`, for instance `test-v2.9.23`, the package is deployed on
`test.pypi.org` with version `2.9.23`.
- if the tag directly is composed of the `v` + the version, for instance `v2.9.23`, the package is
deployed on `pypi.org` with version `2.9.23`.

The version substring itself must respect the basic form of semantic versioning, i.e `(\d\.){2}\d`.
`-alpha`, `.dev22+ff35` or whatever other format will not be accepted, and the CI will fail.

The version embedded into the tag must also fit with the latest version documented into the
[CHANGELOG.md](CHANGELOG.MD) file. If not, the CI will fail.
Merging on master or pushing a tag on the GitHub repository triggers a deployment. Python packages
are deployed into `pypi.org`.

- if triggered via a merge, the package will be a "pre-release", with a version matching
`<M>.<m>.<p+1>-dev<N>` with:
- `M` the major number of the latest version,
- `m` the minor number of the latest version,
- `p` the patch number of the latest version,
- `N` the number of commits since the latest version.
- if triggered via a tag, the package will be a release with the tag as the version.
The version embedded into the tag must also fit with the latest version documented into the
[CHANGELOG.md](CHANGELOG.MD) file. If not, the CI will fail.
92 changes: 91 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,98 @@
[build-system]
requires = [
"setuptools>=45",
"setuptools>=61.2",
"setuptools_scm[toml]>=6.2",
"wheel"
]
build-backend = "setuptools.build_meta"

[project]
name = "ragger"
authors = [{name = "Ledger", email = "[email protected]"}]
description = "Testing framework using Speculos and LedgerComm as backends"
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
]
requires-python = ">=3.8"
dependencies = [
"bip_utils>=2.4.0",
"py-sr25519-bindings>=0.2.0,<0.3.0",
]
dynamic = ["version"]

[project.readme]
file = "README.md"
content-type = "text/markdown"

[project.urls]
Homepage = "https://github.com/LedgerHQ/ragger"
"Bug Tracker" = "https://github.com/LedgerHQ/ragger/issues"

[project.optional-dependencies]
tests = [
"pytest",
"pytest-cov",
]
checkers = [
"yapf",
"toml",
"flake8",
"flake8-pyproject",
"mypy",
"bandit",
"pyqt5-stubs",
]
doc = [
# embeds pyreverse
"pylint",
"sphinx",
"sphinx-rtd-theme",
"sphinxcontrib-images",
"sphinx-copybutton",
"Jinja2>=3.0",
# higher versions trigger build bugs with the RTD theme
"docutils==0.16",
]
speculos = [
"speculos>=0.5.0",
"mnemonic",
]
ledgercomm = [
"ledgercomm>=1.2.1",
"ledgercomm[hid]>=1.2.1",
"pyqt5",
"pytesseract",
]
ledgerwallet = [
"ledgerwallet>=0.4.0",
"pyqt5",
"pytesseract",
]
all_backends = [
"ragger[speculos]",
"ragger[ledgercomm]",
"ragger[ledgerwallet]",
]

[tool.setuptools]
package-dir = {"" = "src"}
include-package-data = true

[tool.setuptools.packages.find]
where = ["src"]
exclude = ["tests"]
namespaces = false

[tool.setuptools.package-data]
ragger = ["py.typed"]

[tool.setuptools_scm]
write_to = "src/ragger/__version__.py"
local_scheme = "no-local-version"
Expand All @@ -23,3 +110,6 @@ exclude_lines = [
"@abstractmethod",
"pragma: no cover"
]

[tool.flake8]
max-line-length = 120
73 changes: 0 additions & 73 deletions setup.cfg

This file was deleted.

0 comments on commit 063cd2c

Please sign in to comment.