-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Poetry as package manager | added github actions for publishing upon release creation #6
Changes from 29 commits
f285e04
3c44f03
64a0d13
927455b
7bc0fa8
76aca7a
e457915
c1c7960
099b09f
22dce65
48fb18b
77810e0
4fbc9d2
c3f8746
b7780f1
99fc42c
ed5b400
4fe2f2b
97180ae
5d781df
e0fadf9
7032f09
801987f
0b278ad
966c518
475b819
9bee798
4b7e14a
b37e42f
5586301
7ea7ef8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: "Prepare development environment" | ||
description: "Set up Python and Node.js environments with caching" | ||
runs: | ||
using: "composite" | ||
steps: | ||
# Python setup | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.10.14 | ||
|
||
- name: Cache Poetry installation | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.local | ||
key: poetry-${{ runner.os }} | ||
|
||
- name: Install Poetry | ||
shell: bash | ||
run: curl -sSL https://install.python-poetry.org | python3 - | ||
|
||
- name: Cache Poetry dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: .venv | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you test that this cache stuff works/makes it faster? From CI it looks like virtualenv is installed elsewhere:
so I wonder what is this caching. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See CI run above, Python packages + node packages are installed only once, although the action inside |
||
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} | ||
|
||
- name: Install Python dependencies | ||
shell: bash | ||
run: poetry install | ||
|
||
# Node.js setup | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Cache node_modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
python_web3_wallet/frontend/node_modules | ||
~/.cache/yarn | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('python_web3_wallet/frontend/yarn.lock') }} | ||
|
||
- name: Install frontend dependencies | ||
shell: bash | ||
run: yarn install --cwd python_web3_wallet/frontend --immutable |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Python + frontend CI | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build_frontend: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: ./.github/actions/python_prepare | ||
- name: Build Frontend | ||
env: | ||
CI: false # needed otherwise dependencies warnings stop the job | ||
run: yarn --cwd python_web3_wallet/frontend build | ||
- name: Cache frontend build | ||
uses: actions/cache@v3 | ||
with: | ||
path: python_web3_wallet/frontend/build | ||
key: frontend-build-${{ github.sha }} | ||
|
||
build_python: | ||
needs: [build_frontend] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: ./.github/actions/python_prepare | ||
- name: Restore frontend build | ||
uses: actions/cache@v3 | ||
with: | ||
path: python_web3_wallet/frontend/build | ||
key: frontend-build-${{ github.sha }} | ||
fail-on-cache-miss: true | ||
- name: Run poetry build | ||
run: poetry build -f wheel |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Python CD | ||
|
||
on: | ||
pull_request: | ||
release: | ||
types: [ published ] | ||
|
||
jobs: | ||
build: | ||
if: github.event_name == 'release' | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Verify the tag version in the pyproject.toml | ||
run: grep -q "version = \"${{ github.event.release.tag_name }}\"" pyproject.toml || exit 1 | ||
shell: bash | ||
- name: Set Node.js 20.x | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
cache: 'yarn' | ||
- uses: ./.github/actions/python_prepare | ||
- name: Build Frontend | ||
env: | ||
CI: false # needed otherwise dependencies warnings stop the job | ||
run: yarn --cwd python_web3_wallet/frontend build | ||
- name: Build a binary wheel and a source tarball | ||
run: poetry build | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
publish-to-pypi: | ||
name: Publish to PyPI | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/python-web3-wallet | ||
|
||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Publish distribution to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_TOKEN }} | ||
verify-metadata: false | ||
verbose: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
dist/ | ||
build/ | ||
.env | ||
*.egg-info | ||
*.egg-info | ||
.idea/ |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[tool.poetry] | ||
name = "python-web3-wallet" | ||
version = "0.0.11" | ||
description = "Streamlit component that allows users to connect a wallet and send transactions with dynamic recipients and amounts" | ||
authors = ["Gnosis AI <[email protected]>"] | ||
license = "MIT" | ||
gabrielfior marked this conversation as resolved.
Show resolved
Hide resolved
|
||
readme = "README.md" | ||
include = [ | ||
"python_web3_wallet/frontend/build/**/*" | ||
] | ||
packages = [ | ||
{ include = "python_web3_wallet" } | ||
] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.10" | ||
streamlit = "^1.40.0" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice idea with cache!
I didn't use that in Github before, but from their repo, it seems like there needs to be something as
in the follow-up step. Or did you test that Poetry will quickly skip the installation by itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see latest changes and the corresponding CI run -> https://github.com/gnosis/python-web3-wallet-streamlit/actions/runs/12692379504?pr=6
I believe the
cache
is working now 🙏