Skip to content

run pytest in gitaction #1172

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

Merged
merged 23 commits into from
Sep 13, 2024
Merged
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
8 changes: 8 additions & 0 deletions .github/workflows/loristest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ jobs:
- name: Override Test Files
run: |
cp test/Dockerfile.test.php8 Loris/
cp test/Dockerfile.test.python Loris/
cp test/docker-compose.yml Loris/
cp test/test_example.py Loris/test
cp test/phpunit.xml Loris/test/
cp test/RB_SQL/* Loris/raisinbread/RB_files/

Expand Down Expand Up @@ -90,3 +92,9 @@ jobs:
CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
# Use the index from matrix as an environment variable
CI_NODE_INDEX: ${{ matrix.ci_node_index }}


- name: Build and run Docker Compose
run: |
cd Loris
docker compose run -T --rm pytest pytest
22 changes: 22 additions & 0 deletions test/Dockerfile.test.python
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Dockerfile
FROM python:3.11.3-slim


WORKDIR /app

# Copy test files into the container
COPY . /app/test

RUN echo "Working directory:"
RUN pwd
RUN echo "Directory contents:"
RUN ls -R
RUN cd test


# Install pytest
RUN pip install pytest

# Set the default command to run tests
CMD ["pytest","/app/test"]

11 changes: 10 additions & 1 deletion test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
version: '2'
version: '3'
services:
pytest:
build:
context: .
dockerfile: Dockerfile.test.python
volumes:
- ./:/app
working_dir: /app/test
command: pytest

db:
build:
context: .
Expand Down
7 changes: 7 additions & 0 deletions test/test_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# tests/test_example.py
def test_addition():
assert 1 + 1 == 2

def test_subtraction():
assert 2 - 1 == 1

Loading