-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test python scripts in github actions (#605)
- Loading branch information
Showing
18 changed files
with
195 additions
and
26 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,14 @@ | ||
.venv/* | ||
hello.py | ||
.ci/scripts.py | ||
code/nfts/upload-arweave/upload-arweave.en.py | ||
code/local-development/airdropping-sol/airdropping-sol.en.py | ||
code/basic-transactions/sending-sol/sending-sol.en.py | ||
code/local-development/connecting-websocket/connecting-websocket.en.py | ||
code/anchor/testing-with-anchor/client/testing_with_anchor.py | ||
code/keypairs-and-wallets/vanity-publickeys/vanity-publickeys.en.py | ||
code/serialization/clientdata/python.client.data.py | ||
code/serialization/primitives/python.demo_primitives.py | ||
code/serialization/instruction/python.client.py | ||
code/local-development/connecting-cluster/connecting-cluster.en.py | ||
code/local-development/connecting-private-cluster/connecting-private-cluster.en.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,43 @@ | ||
import os | ||
import re | ||
import subprocess | ||
from concurrent.futures import ThreadPoolExecutor | ||
|
||
exclude_file = '.ci/.exclude_files' | ||
root_dir = os.path.curdir | ||
|
||
with open(exclude_file, 'r') as f: | ||
exclude_patterns = [re.compile(line.strip()) for line in f.readlines()] | ||
|
||
def find_py_files(root_dir, exclude_patterns): | ||
py_files = [] | ||
for root, dirs, files in os.walk(root_dir): | ||
for file in files: | ||
file_path = os.path.join(root, file) | ||
relative_path = os.path.relpath(file_path, root_dir) | ||
if file.endswith('.py') and ".preview." not in file: | ||
ignore_file = any(pattern.search(relative_path) for pattern in exclude_patterns) | ||
if not ignore_file: | ||
py_files.append(relative_path) | ||
return py_files | ||
|
||
def execute_file(file_path): | ||
result = subprocess.run(['python', file_path], capture_output=True, text=True) | ||
return result.stdout, result.stderr, file_path | ||
|
||
def main(): | ||
files_to_execute = find_py_files(root_dir, exclude_patterns) | ||
print("Executing these python files:") | ||
print("\n".join(files_to_execute)) | ||
|
||
with ThreadPoolExecutor() as executor: | ||
futures = [executor.submit(execute_file, file) for file in files_to_execute] | ||
for future in futures: | ||
stdout, stderr, file_path = future.result() | ||
print(f'\nExecuting {file_path}:\n\n Output: \n\r {stdout}') | ||
if stderr: | ||
print(f'\nError from {file_path}:\n\n Error: {stderr}') | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,42 @@ | ||
name: Test Python Files | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0 * * *" | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
branches: | ||
- master | ||
|
||
jobs: | ||
run-py: | ||
strategy: | ||
matrix: | ||
py-version: [3.9] | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{matrix.py-version}} | ||
cache: pip | ||
|
||
- name: Create, activate virtual environment and Install dependencies | ||
run: | | ||
python -m venv .venv | ||
source .venv/bin/activate | ||
python -m pip install -r requirements.txt --upgrade pip | ||
echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH | ||
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV | ||
- name: Run python files | ||
run: | | ||
source .venv/bin/activate | ||
python .ci/scripts.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 |
---|---|---|
|
@@ -5,4 +5,5 @@ node_modules | |
.DS_Store | ||
**/*/target | ||
.vscode | ||
.history | ||
.history | ||
.venv |
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
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
8 changes: 7 additions & 1 deletion
8
code/keypairs-and-wallets/generate-keypair/generate-keypair.en.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 |
---|---|---|
@@ -1,3 +1,9 @@ | ||
from solders.keypair import Keypair | ||
import based58 | ||
|
||
keypair = Keypair() | ||
keypair = Keypair() | ||
print("Keypair PublicKey: ", keypair.pubkey()) | ||
|
||
rawPK = bytes(keypair) | ||
pk = based58.b58encode(rawPK).decode() | ||
print("Keypair Secret: ", pk) |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from mnemonic import Mnemonic | ||
|
||
mnemo = Mnemonic("english") | ||
words = mnemo.generate(strength=256) | ||
words = mnemo.generate(strength=256) | ||
print(words) |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from solders.keypair import Keypair | ||
|
||
b58_string = "5MaiiCavjCmn9Hs1o3eznqDEhRwxo7pXiAYez7keQUviUkauRiTMD8DrESdrNjN8zd9mTmVhRvBJeg5vhyvgrAhG" | ||
keypair = Keypair.from_string(b58_string) | ||
keypair = Keypair.from_base58_string(b58_string) | ||
print("Created Keypair with Public Key: {}".format(keypair.pubkey())) |
2 changes: 1 addition & 1 deletion
2
code/keypairs-and-wallets/keypair-from-secret/from-bs58.preview.en.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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
b58_string = "5MaiiCavjCmn9Hs1o3eznqDEhRwxo7pXiAYez7keQUviUkauRiTMD8DrESdrNjN8zd9mTmVhRvBJeg5vhyvgrAhG" | ||
keypair = Keypair.from_string(b58_string) | ||
keypair = Keypair.from_base58_string(b58_string) |
5 changes: 3 additions & 2 deletions
5
code/keypairs-and-wallets/mnemonic-to-keypair/from-bip39.preview.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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mnemo = Mnemonic("english") | ||
seed = mnemo.to_seed("pill tomorrow foster begin walnut borrow virtual kick shift mutual shoe scatter") | ||
keypair = Keypair.from_bytes(seed) | ||
phrase = "pill tomorrow foster begin walnut borrow virtual kick shift mutual shoe scatter" | ||
seed = mnemo.to_seed(phrase) | ||
keypair = Keypair.from_seed(seed[:32]) |
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
11 changes: 6 additions & 5 deletions
11
code/keypairs-and-wallets/mnemonic-to-keypair/from-bip44.preview.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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
mnemo = Mnemonic("english") | ||
seed = mnemo.to_seed("neither lonely flavor argue grass remind eye tag avocado spot unusual intact") | ||
seed = mnemo.to_seed("pill tomorrow foster begin walnut borrow virtual kick shift mutual shoe scatter") | ||
|
||
hd = HDKey.from_master_seed(seed) | ||
keypairs = [] | ||
for i in range(10): | ||
path = f"m/44'/501'/{i}'/0'" | ||
keypair = Keypair.from_bytes(hd.derive(path).private_key) | ||
print(f"{path} => {keypair.public_key()}") | ||
derivation_path = f"m/44'/501'/{i}'/0'" | ||
keypair = Keypair.from_seed_and_derivation_path(seed, derivation_path) | ||
keypairs.append(keypair) | ||
print(f"Keypair {i + 1} with Public Key: {keypair.pubkey()}") |
15 changes: 8 additions & 7 deletions
15
code/keypairs-and-wallets/mnemonic-to-keypair/from-bip44.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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
from solana.keypair import Keypair | ||
from solders.keypair import Keypair | ||
from mnemonic import Mnemonic | ||
from hdkey import HDKey | ||
|
||
mnemo = Mnemonic("english") | ||
seed = mnemo.to_seed("neither lonely flavor argue grass remind eye tag avocado spot unusual intact") | ||
mnemonic_phrase = "pill tomorrow foster begin walnut borrow virtual kick shift mutual shoe scatter" | ||
seed = mnemo.to_seed(mnemonic_phrase) | ||
|
||
hd = HDKey.from_master_seed(seed) | ||
keypairs = [] | ||
for i in range(10): | ||
path = f"m/44'/501'/{i}'/0'" | ||
keypair = Keypair.from_bytes(hd.derive(path).private_key) | ||
print(f"{path} => {keypair.public_key()}") | ||
derivation_path = f"m/44'/501'/{i}'/0'" | ||
keypair = Keypair.from_seed_and_derivation_path(seed, derivation_path) | ||
keypairs.append(keypair) | ||
print(f"Keypair {i + 1} with Public Key: {keypair.pubkey()}") |
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
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
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
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,53 @@ | ||
anchorpy==0.20.1 | ||
anchorpy-core==0.2.0 | ||
anyio==4.4.0 | ||
asn1crypto==1.5.1 | ||
attrs==23.2.0 | ||
base58==2.1.1 | ||
based58==0.1.1 | ||
borsh-construct==0.1.0 | ||
cbor2==5.6.3 | ||
certifi==2024.6.2 | ||
cffi==1.16.0 | ||
charset-normalizer==3.3.2 | ||
coincurve==20.0.0 | ||
construct==2.10.68 | ||
construct-typing==0.5.6 | ||
crcmod==1.7 | ||
ecdsa==0.19.0 | ||
ed25519==1.5 | ||
ed25519-blake2b==1.4.1 | ||
exceptiongroup==1.2.1 | ||
fastecdsa==2.3.2 | ||
h11==0.14.0 | ||
httpcore==1.0.5 | ||
httpx==0.27.0 | ||
idna==3.7 | ||
iniconfig==2.0.0 | ||
jsonalias==0.1.1 | ||
mnemonic==0.21 | ||
more-itertools==8.14.0 | ||
numpy==1.26.4 | ||
packaging==24.0 | ||
pluggy==1.5.0 | ||
py-sr25519-bindings==0.2.0 | ||
pycparser==2.22 | ||
pycryptodome==3.20.0 | ||
pyheck==0.1.5 | ||
PyNaCl==1.5.0 | ||
pytest==8.2.1 | ||
pytest-asyncio==0.23.7 | ||
requests==2.32.3 | ||
riemann-secpy256k1==0.2.8 | ||
six==1.16.0 | ||
sniffio==1.3.1 | ||
solana==0.34.0 | ||
solders==0.21.0 | ||
SQLAlchemy==2.0.30 | ||
sumtypes==0.1a6 | ||
toml==0.10.2 | ||
tomli==2.0.1 | ||
toolz==0.11.2 | ||
typing_extensions==4.12.1 | ||
urllib3==2.2.1 | ||
websockets==10.4 |