Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
areyesd14 committed Mar 3, 2022
2 parents 2cd0f06 + f2818db commit 03094fa
Show file tree
Hide file tree
Showing 23 changed files with 310 additions and 147 deletions.
48 changes: 26 additions & 22 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pipeline {
stage("Build Docker image") {
when {
anyOf {
branch "master"
branch "main"
branch "develop"
branch "bugfix/*"
branch "hotfix/*"
Expand All @@ -37,30 +37,15 @@ pipeline {

dockerImageName = dockerImageName + image_tag
echo "dockerImageName: ${dockerImageName}"
dockerImage = docker.build dockerImageName
dockerImage = docker.build(dockerImageName, "-f docker/Dockerfile .")
}
}
}
// stage("Test Docker Image") {
// when {
// anyOf {
// branch "master"
// branch "develop"
// branch "bugfix/*"
// branch "hotfix/*"
// branch "release/*"
// }
// }
// steps {
// script {
// sh "docker run ${dockerImageName} pytest"
// }
// }
// }

stage("Push Docker image") {
when {
anyOf {
branch "master"
branch "main"
branch "develop"
branch "bugfix/*"
branch "hotfix/*"
Expand All @@ -77,6 +62,25 @@ pipeline {
}
}

stage("Test Docker Image") {
when {
anyOf {
branch "main"
branch "develop"
branch "bugfix/*"
branch "hotfix/*"
branch "release/*"
branch "PR-*"
}
}
steps {
script {
sh "docker build -f docker/Dockerfile-test -t love-manager-test ."
sh "docker run love-manager-test"
}
}
}

stage("Deploy documentation") {
agent {
docker {
Expand Down Expand Up @@ -110,12 +114,12 @@ pipeline {
build(job: '../LOVE-integration-tools/develop', wait: false)
}
}
stage("Trigger master deployment") {
stage("Trigger main deployment") {
when {
branch "master"
branch "main"
}
steps {
build(job: '../LOVE-integration-tools/master', wait: false)
build(job: '../LOVE-integration-tools/main', wait: false)
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ All these variables are initialized with default variables defined in :code:`.en

# Local load for development

We provide a docker image and a docker-compose file in order to load the LOVE-manager with a Postgres database locally, for development purposes, such as run tests and build documentation.
We provide docker images and a docker-compose file in order to load the LOVE-manager with a Postgres database locally, for development purposes, such as run tests and build documentation.

This docker-compose does not copy the code into the image, but instead it mounts the repository inside the image, this way you can edit the code from outside the docker container with no need to rebuild or restart.

Expand All @@ -40,8 +40,10 @@ This docker-compose does not copy the code into the image, but instead it mounts
Follow these instructions to run the application in a docker container and get into it:

```
docker-compose up -d
cd docker/
docker-compose up -d --build
docker-compose exec manager bash
cd /usr/src/love/manager/
```

## Run tests
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Dockerfile → docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ VOLUME /usr/src/love/manager/static
VOLUME /usr/src/love/manager/media
EXPOSE 8000

# Set env variables for runtime (to be replaced in docker-cpomse files)
# Set env variables for runtime (to be replaced in docker-compose files)
ENV ADMIN_USER_PASS=test
ENV USER_USER_PASS=test
ENV CMD_USER_PASS=test
Expand Down
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions docker/Dockerfile-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM python:3.8.2-buster

# Install required packages
RUN apt-get update && \
apt-get install -y \
libsasl2-dev \
python-dev \
libldap2-dev \
libssl-dev &&\
rm -rf /var/lib/apt/lists/*

# Set workdir and install python requirements
WORKDIR /usr/src/love
COPY manager/requirements.txt .
RUN pip install -r requirements.txt

# Copy source code and build project
COPY manager ./manager
COPY docker/run-tests.sh .

CMD ["/usr/src/love/run-tests.sh"]
15 changes: 6 additions & 9 deletions docker-compose.yml → docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3.7"
services:

database:
container_name: manager-postgres-local
container_name: love-manager-database
image: postgres:12.0
environment:
- POSTGRES_DB=postgres
Expand All @@ -14,11 +14,11 @@ services:
restart: always

manager:
container_name: manager-local
container_name: love-manager-mount
build:
context: .
dockerfile: Dockerfile-dev
image: love-manager-image-mount
context: ..
dockerfile: docker/Dockerfile-dev
image: love-manager-mount-image
environment:
- DB_ENGINE=postgresql
- DB_NAME=postgres
Expand All @@ -32,7 +32,4 @@ services:
- database
restart: always
volumes:
- .:/usr/src/love
command: "sleep infinity"
stdin_open: true
tty: true
- ../:/usr/src/love
3 changes: 3 additions & 0 deletions docker/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
cd /usr/src/love/manager/
pytest
8 changes: 5 additions & 3 deletions manager/api/management/commands/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ def test_command_creates_users(self):
"adminpass": "admin_pass",
"userpass": "user_pass",
"cmduserpass": "cmd_pass",
"authlistuserpass": "authlist_pass",
}
command.handle(*[], **options)
# Assert:
self.assertEqual(
User.objects.count(), old_users_num + 4, "There are no new users"
User.objects.count(), old_users_num + 5, "There are no new users"
)
self.assertEqual(
Group.objects.count(), old_groups_num + 1, "There is no new group"
Group.objects.count(), old_groups_num + 2, "There is no new group"
)
admin = User.objects.filter(username=admin_username).first()
user = User.objects.filter(username=user_username).first()
Expand Down Expand Up @@ -83,11 +84,12 @@ def test_command_sets_permissions_even_if_users_already_existed(self):
"adminpass": "admin_pass",
"userpass": "user_pass",
"cmduserpass": "cmd_pass",
"authlistuserpass": "authlist_pass",
}
command.handle(*[], **options)
# Assert:
self.assertEqual(
Group.objects.count(), old_groups_num + 1, "There is no new group"
Group.objects.count(), old_groups_num + 2, "There is no new group"
)
admin = User.objects.filter(username=admin_username).first()
user = User.objects.filter(username=user_username).first()
Expand Down
6 changes: 3 additions & 3 deletions manager/api/tests/test_authlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_csc_authorization_create_request_authlist_user(self):
response = self.client.post(url, payload, format="json")

# Assert
self.assertEqual(response.status_code, 200)
self.assertEqual(response.status_code, 201)
self.assertEqual(response.data["user"], self.user_authlist.username)
self.assertEqual(response.data["cscs_to_change"], payload["cscs_to_change"])
self.assertEqual(response.data["authorized_users"], payload["authorized_users"])
Expand Down Expand Up @@ -167,7 +167,7 @@ def test_csc_authorization_create_request_normal_user(self):
response = self.client.post(url, payload, format="json")

# Assert
self.assertEqual(response.status_code, 200)
self.assertEqual(response.status_code, 201)
self.assertEqual(response.data["user"], self.user_normal.username)
self.assertEqual(response.data["cscs_to_change"], payload["cscs_to_change"])
self.assertEqual(response.data["authorized_users"], payload["authorized_users"])
Expand Down Expand Up @@ -218,7 +218,7 @@ def test_csc_authorization_self_remove_normal_user(self):
response = self.client.post(url, payload, format="json")

# Assert
self.assertEqual(response.status_code, 200)
self.assertEqual(response.status_code, 201)
self.assertEqual(len(response.data), 2)

self.assertEqual(response.data[0]["user"], self.user_normal.username)
Expand Down
Loading

0 comments on commit 03094fa

Please sign in to comment.