Skip to content

Examples testing

Examples testing #572

Workflow file for this run

name: Examples testing
on:
schedule:
- cron: "0 0 * * *"
pull_request:
branches: ["main"]
paths:
[
"**.py",
"pyproject.toml",
"poetry.lock",
".github/workflows/pytests.yml",
]
push:
branches: ["main"]
paths:
[
"**.py",
"pyproject.toml",
"poetry.lock",
".github/workflows/pytests.yml",
]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ ! (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) }}
jobs:
tests:
runs-on: ubuntu-latest
env:
# https://www.notion.so/nibiru/Resources-and-Repo-Configs-b31aa8074a2b419d80b0c946ed5efab0
DEVNET_NUMBER: ${{ secrets.DEVNET_NUMBER }}
VALIDATOR_MNEMONIC: ${{ secrets.VALIDATOR_MNEMONIC }}
EXAMPLES_WALLET_MNEMONIC: ${{ secrets.EXAMPLES_WALLET_MNEMONIC }}
steps:
# ----------------------------------------------
# check-out repo and set-up python
# ----------------------------------------------
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Python (3.8)
id: setup-python
uses: actions/setup-python@v3
with:
python-version: 3.8.16
# 3.8.16 is the highest version available for this GitHub action.
# For the full list of supported Python versions, see:
# https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json
# 3.8.16 is the highest 3.8 version available on pyenv
# See `grep '3.8' <<< $(pyenv install -l)` to view the available list.
- name: Run python
run: python --version && python -c "print('hello')"
# ----------------------------------------------
# Try to load a cached poetry binary
# See https://github.com/snok/install-poetry#caching-the-poetry-installation for the source
# ----------------------------------------------
- name: Load cached Poetry installation
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-2 # increment to reset cache
# ----------------------------------------------
# Install & configure poetry
# ----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
version: latest
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
#----------------------------------------------
# run examples
#----------------------------------------------
- name: Run the examples
run: |
pip install jupyter
poetry run pip install .
cd examples
for filename in *; do
if [[ $filename == *.ipynb ]] ; then
sed -i '/pip install nibiru/d' "$filename"
sed -i "s/put your mnemonic here.../$EXAMPLES_WALLET_MNEMONIC/g" "$filename"
jupyter nbconvert --to python "$filename"
fi
for filename in *; do
if [[ $filename == *.py ]]; then
poetry run python "$filename" || exit 1
fi
done
done