Skip to content

Commit

Permalink
test installed code, not source (Chia-Network#15532)
Browse files Browse the repository at this point in the history
* explore testing installed code, not source

* non-editable install

* hmm

* yup

* bash it up

* test-single.yml: defaults: run: shell: bash

* try removing windows specific steps

* env.GITHUB_WORKSPACE

* Update test-single.yml

* Update test-single.yml

* Update test-single.yml

* also Install.ps1

* ,

* more

* Update test-single.yml

* Update .coveragerc

* whitespace
  • Loading branch information
altendky authored Jul 25, 2023
1 parent 7fe09a3 commit 74b02fa
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ omit=
concurrency=multiprocessing, thread
parallel=True

[paths]
source =
chia/
venv/**/site-packages/chia/

[report]
precision = 1
exclude_lines =
Expand Down
8 changes: 6 additions & 2 deletions .github/actions/install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ inputs:
description: "Install development dependencies."
required: false
default: ""
editable:
description: "Install as editable source."
required: false
default: "true"
legacy_keyring:
description: "Install legacy keyring dependencies."
required: false
Expand All @@ -33,12 +37,12 @@ runs:
env:
INSTALL_PYTHON_VERSION: ${{ inputs.python-version }}
run: |
${{ inputs.command-prefix }} sh install.sh ${{ inputs.development && '-d' || '' }} ${{ inputs.legacy_keyring && '-l' || '' }} ${{ inputs.automated == 'true' && '-a' || '' }}
${{ inputs.command-prefix }} sh install.sh ${{ inputs.development && '-d' || '' }} ${{ (inputs.editable != 'true') && '-i' || '' }} ${{ inputs.legacy_keyring && '-l' || '' }} ${{ inputs.automated == 'true' && '-a' || '' }}
- name: Run install script (Windows)
if: runner.os == 'windows'
shell: pwsh
env:
INSTALL_PYTHON_VERSION: ${{ inputs.python-version }}
run: |
${{ inputs.command-prefix }} ./Install.ps1 ${{ inputs.development && '-d' || '' }}
${{ inputs.command-prefix }} ./Install.ps1 ${{ inputs.development && '-d' || '' }} ${{ (inputs.editable != 'true') && '-i' || '' }}
9 changes: 9 additions & 0 deletions .github/workflows/test-single.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ jobs:
with:
python-version: ${{ matrix.python.install_sh }}
development: true
editable: false
legacy_keyring: ${{ matrix.configuration.legacy_keyring_required }}

- uses: chia-network/actions/activate-venv@main
Expand All @@ -212,12 +213,20 @@ jobs:
sh install-timelord.sh -n
./vdf_bench square_asm 400000
- name: Move chia/ so we test the installed code
run: |
mv chia/ notchia/
- name: Test blockchain code with pytest
env:
ENABLE_PYTEST_MONITOR: ${{ matrix.os.matrix == 'ubuntu' && matrix.configuration.enable_pytest_monitor || '' }}
run: |
pytest --cov=chia --cov=tests --cov-config=.coveragerc --cov-report= --durations=10 ${{ matrix.configuration.pytest_parallel_args[matrix.os.matrix] }} -m "not benchmark" ${{ env.ENABLE_PYTEST_MONITOR }} ${{ matrix.configuration.test_files }}
- name: Move back to chia/ for coverage
run: |
mv notchia/ chia/
- name: Process coverage data
run: |
coverage xml --rcfile=.coveragerc -o coverage.xml
Expand Down
10 changes: 9 additions & 1 deletion Install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ param(
[Parameter(HelpMessage="install development dependencies")]
[switch]$d = $False,
[Parameter()]
[switch]$i = $False,
[Parameter()]
[switch]$p = $False
)

Expand All @@ -13,6 +15,12 @@ if ($d)
$extras += "dev"
}

$editable_cli = "--editable"
if ($i)
{
$editable_cli = ""
}

if ([Environment]::Is64BitOperatingSystem -eq $false)
{
Write-Output "Chia requires a 64-bit Windows installation"
Expand Down Expand Up @@ -106,7 +114,7 @@ py -$pythonVersion -m venv venv

venv\scripts\python -m pip install --upgrade pip setuptools wheel
venv\scripts\pip install --extra-index-url https://pypi.chia.net/simple/ miniupnpc==2.2.2
venv\scripts\pip install --editable ".$extras_cli" --extra-index-url https://pypi.chia.net/simple/
venv\scripts\pip install $editable_cli ".$extras_cli" --extra-index-url https://pypi.chia.net/simple/

if ($p)
{
Expand Down
18 changes: 11 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
set -o errexit

USAGE_TEXT="\
Usage: $0 [-adlsph]
Usage: $0 [-adilpsh]
-a automated install, no questions
-d install development dependencies
-i install non-editable
-l install legacy keyring dependencies (linux only)
-s skip python package installation and just do pip install
-p additional plotters installation
-s skip python package installation and just do pip install
-h display this help and exit
"

Expand All @@ -21,19 +22,22 @@ PACMAN_AUTOMATED=
EXTRAS=
SKIP_PACKAGE_INSTALL=
PLOTTER_INSTALL=
EDITABLE='-e'

while getopts adlsph flag
while getopts adilpsh flag
do
case "${flag}" in
# automated
a) PACMAN_AUTOMATED=--noconfirm;;
# development
d) EXTRAS=${EXTRAS}dev,;;
# simple install
s) SKIP_PACKAGE_INSTALL=1;;
p) PLOTTER_INSTALL=1;;
# non-editable
i) EDITABLE='';;
# legacy keyring
l) EXTRAS=${EXTRAS}legacy_keyring,;;
p) PLOTTER_INSTALL=1;;
# simple install
s) SKIP_PACKAGE_INSTALL=1;;
h) usage; exit 0;;
*) echo; usage; exit 1;;
esac
Expand Down Expand Up @@ -342,7 +346,7 @@ python -m pip install wheel
#if [ "$INSTALL_PYTHON_VERSION" = "3.8" ]; then
# This remains in case there is a diversion of binary wheels
python -m pip install --extra-index-url https://pypi.chia.net/simple/ miniupnpc==2.2.2
python -m pip install -e ."${EXTRAS}" --extra-index-url https://pypi.chia.net/simple/
python -m pip install ${EDITABLE} ."${EXTRAS}" --extra-index-url https://pypi.chia.net/simple/

if [ -n "$PLOTTER_INSTALL" ]; then
set +e
Expand Down

0 comments on commit 74b02fa

Please sign in to comment.