Skip to content

Commit

Permalink
make one-liners for building&running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-v committed Sep 7, 2023
1 parent 7b6ef3e commit 905fd27
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 10 deletions.
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
23 changes: 23 additions & 0 deletions .run.docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/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 rm -f $DOCKER_CONTAINER_NAME || true ) 2>&1 >/dev/null

docker run \
-u "$(id -u):$(id -g)" \
-it \
--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
```

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
2 changes: 2 additions & 0 deletions lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash -e
time ./.run.docker.sh make lint
3 changes: 3 additions & 0 deletions pytest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash -ex
ARGS="$@"
time ./.run.docker.sh bash -c "set -ex; export TEST_ARGS=\"$ARGS\"; make test-postgres"

0 comments on commit 905fd27

Please sign in to comment.