Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest.sh #86

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions .github/workflows/test_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.10'
- run: sudo apt-get install graphviz graphviz-dev
- run: make test-postgres
- run: ./pytest.sh
lint:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.10'
- run: sudo apt-get install graphviz graphviz-dev
- run: make lint
- run: ./lint.sh
30 changes: 30 additions & 0 deletions .run.docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
set -ex
export DOCKER_IMG=redun_python_test:redun_python_test
export DOCKER_CONTAINER_NAME=redun_python_test

docker build . --tag $DOCKER_IMG >/dev/null
docker-compose up -d

( docker rm -f $DOCKER_CONTAINER_NAME || true ) 2>&1 >/dev/null

if [ -t 0 ]; then
TERM="-i -t"
else
TERM="-i "
fi

docker run \
-u "$(id -u):$(id -g)" \
$TERM \
--rm \
--name $DOCKER_CONTAINER_NAME \
-e PGUSER=postgres -e PGPASSWORD=postgres \
-v "$PWD:/v" \
-w /v \
--net host \
--shm-size=4gb \
--memory 6gb \
--memory-swap 6gb \
$DOCKER_IMG \
"$@"
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.10-bookworm
ENV DEBIAN_FRONTEND=noninteractive
RUN mkdir -p /usr/share/man/man1 /usr/share/man/man2
RUN apt-get update -y && apt-get install -y libpq-dev gcc graphviz graphviz-dev openjdk-17-jdk libpq-dev gcc postgresql-client-15 pre-commit
RUN java --version
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64/
ENV REQUIRE_POSTGRES=1

# run containers with user with id 1000
RUN useradd -rm -d /home/debian -s /bin/bash -g root -G sudo -u 1000 debian
USER debian
WORKDIR /home/debian
10 changes: 10 additions & 0 deletions docs/source/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ tocpdeth: 3

# Developer guide

## One-liner to run tests using Docker & Docker-Compose

Run `./pytest.sh` with the arguments that you would pass to `pytest`, for example:

```
./pytest.sh -k static --pdb
```

The lints also have their own shortcut: `./lint.sh`

## Development installation

If you have postgres available, (perhaps with `brew install postgresql` on macOS), you can prepare
Expand Down
3 changes: 3 additions & 0 deletions lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -e
./.run.docker.sh make lint
4 changes: 4 additions & 0 deletions pytest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -e
ARGS="$@"
./.run.docker.sh bash -c "set -ex; export TEST_ARGS=\"$ARGS\"; make test-postgres"