-
Notifications
You must be signed in to change notification settings - Fork 8
134 lines (123 loc) · 5.2 KB
/
pytests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: "E2E 🐍 tests"
on:
pull_request:
branches: ["main", "release/*"]
paths:
[
"pysdk/**.py",
"pysdk/pyproject.toml",
"pysdk/poetry.lock",
".github/workflows/pytests.yml",
]
push:
branches: ["main", "release/*"]
paths:
[
"pysdk/**.py",
"pysdk/pyproject.toml",
"pysdk/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
# `jobs.<job_id>.defaults`:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_iddefaultsrun
defaults:
run:
working-directory: "pysdk"
env:
# https://www.notion.so/nibiru/Resources-and-Repo-Configs-b31aa8074a2b419d80b0c946ed5efab0
VALIDATOR_MNEMONIC: "guard cream sadness conduct invite crumble clock pudding hole grit liar hotel maid produce squeeze return argue turtle know drive eight casino maze host"
DEVNET_NUMBER: ${{ secrets.DEVNET_NUMBER }}
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@v2
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 # sanity check on the installation.
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 ping for early tests
# ----------------------------------------------
- name: Install ping
run: sudo apt-get install -y iputils-ping
# ----------------------------------------------
# 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
- name: Run localnet.sh in the background.
run: |
curl -s https://get.nibiru.fi/@v0.21.5! | bash
bash scripts/localnet.sh --no-build &
# - name: Run chaosnet
# uses: NibiruChain/[email protected]
# id: chaosnet
# with:
# services: nibiru pricefeeder
# ghtoken: ${{ secrets.GITHUB_TOKEN }}
# ghactor: ${{ github.actor }}
- name: "Sleep so that the network has time to start."
run: sleep 5
#----------------------------------------------
# run tests
#----------------------------------------------
- name: Install unbuffer command for run step
run: sudo apt-get install -y expect-dev
- name: Run Python SDK tests
run: unbuffer poetry run pytest -s tests --cov=nibiru --log-cli-level=DEBUG 2>&1 | tee coverage.txt; exit "${PIPESTATUS[0]}"
# piping to tee lets us see stdout and write to a file simultaneously.
# unbuffer retains the colored text from pytest through the pipe to tee
# -s makes the output verbose to make logs more descriptive.
# --cov toggles on the coverage report at the specified path
#----------------------------------------------
# Upload test output and coverage report as a GitHub artifact
#----------------------------------------------
- uses: actions/upload-artifact@v3
with:
name: test-coverage
path: coverage.txt