Mercurial > code > home > repos > rdferry
changeset 4:ddf021c87083
pretxncommit
author | drewp@bigasterisk.com |
---|---|
date | Sat, 16 Mar 2024 12:02:40 -0700 |
parents | b5afa9363c3b |
children | b34cd6619316 |
files | .hgignore precommit.sh pretxncommit.sh |
diffstat | 3 files changed, 46 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Sat Mar 16 12:02:40 2024 -0700 @@ -0,0 +1,7 @@ +__pycache__/ + +.pdm.toml +.pdm-python +.pdm-build/ +.vscode/settings.json +.pytest_cache/ \ No newline at end of file
--- a/precommit.sh Sat Mar 16 11:40:08 2024 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -#!/bin/bash -exit 0 - -# Define your project's root directory -PROJECT_ROOT="/path/to/your/project" - -# Change directory to the project root -cd "$PROJECT_ROOT" || exit - -# Install dependencies using pdm -pdm install - -# Check if the installation was successful -if [ $? -ne 0 ]; then - echo "Error: Failed to install dependencies with pdm." - exit 1 -fi - -# Run your code -# Modify the command as per your project structure and requirements -python your_script.py - -# Check if the execution was successful -if [ $? -ne 0 ]; then - echo "Error: Failed to run your code." - exit 1 -fi - -# If everything is successful, exit with 0 status -exit 0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pretxncommit.sh Sat Mar 16 12:02:40 2024 -0700 @@ -0,0 +1,39 @@ +#!/bin/zsh -e + +# e2e test including lib installs and test suite + +HG_NODE=${HG_NODE:-tip} + +echo node = $HG_NODE +SRC_DIR=`pwd` + +WORK_DIR=/tmp/rdferry_pretxncommit_$$ +mkdir $WORK_DIR + +TRAPZERR() { + rm -r $WORK_DIR +} + + +# $STAGE_DIR shall have the exact state to be committed. + +STAGE_DIR=$WORK_DIR/stage +hg clone -r $HG_NODE $SRC_DIR $STAGE_DIR + + +# TEST_PROJECT depends on rdferry from STAGE_DIR + +TEST_PROJECT_DIR=$WORK_DIR/test_project +mkdir $TEST_PROJECT_DIR +cd $TEST_PROJECT_DIR +pdm config --local venv.in_project True +pdm init --non-interactive +pdm add $STAGE_DIR pytest pytest-asyncio aiohttp +pdm run python -c 'import rdferry; print(f"using {rdferry}")' + +# pretend the example code is test project's code +cp -a ../stage/examples . +pdm run pytest examples + +rm -r $WORK_DIR +exit 0