Skip to content

Commit e110571

Browse files
committed
🔨 Rename all rest-tests to tests and remove branch CI
The tests will include direct CRUD operations, not only rest tests, so it makes sense for them to be named just 'tests'. Also, remove all the 'branch' build and deployment sections, as it is not really being used and tested. It would leave many dangling stacks. And the most recent multi-file Docker Compose architecture allows having arbitrary more environments by just modifying the .gitlab-ci.yml (or equivalent) file.
1 parent a98e5a0 commit e110571

24 files changed

+26
-91
lines changed

cookiecutter.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
"project_slug": "{{ cookiecutter.project_name|lower|replace(' ', '-') }}",
44
"domain_main": "{{cookiecutter.project_slug}}.com",
55
"domain_staging": "stag.{{cookiecutter.domain_main}}",
6-
"domain_branch": "branch.{{cookiecutter.domain_main}}",
76
"domain_dev": "dev.{{cookiecutter.domain_main}}",
87

98
"docker_swarm_stack_name_main": "{{cookiecutter.domain_main|replace('.', '-')}}",
109
"docker_swarm_stack_name_staging": "{{cookiecutter.domain_staging|replace('.', '-')}}",
11-
"docker_swarm_stack_name_branch": "{{cookiecutter.domain_branch|replace('.', '-')}}",
1210

1311
"secret_key": "changethis",
1412
"first_superuser": "admin@{{cookiecutter.domain_main}}",
@@ -21,7 +19,6 @@
2119

2220
"traefik_constraint_tag": "{{cookiecutter.domain_main}}",
2321
"traefik_constraint_tag_staging": "{{cookiecutter.domain_staging}}",
24-
"traefik_constraint_tag_branch": "{{cookiecutter.domain_branch}}",
2522
"traefik_public_network": "traefik-public",
2623
"traefik_public_constraint_tag": "traefik-public",
2724

test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ docker-compose -f docker-stack.yml down -v --remove-orphans # Remove possibly pr
1212
docker-compose -f docker-stack.yml up -d
1313
sleep 20; # Give some time for the DB and prestart script to finish
1414
docker-compose -f docker-stack.yml exec -T backend bash -c 'alembic revision --autogenerate -m "Testing" && alembic upgrade head'
15-
docker-compose -f docker-stack.yml exec -T backend-rest-tests pytest
15+
docker-compose -f docker-stack.yml exec -T backend-tests pytest
1616
docker-compose -f docker-stack.yml down -v --remove-orphans
1717

1818
cd ../

{{cookiecutter.project_slug}}/.gitlab-ci.yml

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ stages:
88
- build
99
- deploy
1010

11-
rest-tests:
11+
tests:
1212
stage: test
1313
script:
1414
- >
@@ -22,31 +22,12 @@ rest-tests:
2222
- docker-compose -f docker-stack.yml down -v --remove-orphans # Remove possibly previous broken stacks left hanging after an error
2323
- docker-compose -f docker-stack.yml up -d
2424
- sleep 20; # Give some time for the DB and prestart script to finish
25-
- docker-compose -f docker-stack.yml exec -T backend-rest-tests pytest
25+
- docker-compose -f docker-stack.yml exec -T backend-tests pytest
2626
- docker-compose -f docker-stack.yml down -v --remove-orphans
2727
tags:
2828
- build
2929
- test
3030

31-
build-branch:
32-
stage: build
33-
script:
34-
- >
35-
TAG=branch
36-
docker-compose
37-
-f docker-compose.images.yml
38-
-f docker-compose.build.yml
39-
config > docker-stack.yml
40-
- docker-compose -f docker-stack.yml build
41-
- docker-compose -f docker-stack.yml push
42-
except:
43-
- master
44-
- production
45-
- tags
46-
tags:
47-
- build
48-
- test
49-
5031
build-stag:
5132
stage: build
5233
script:
@@ -81,33 +62,6 @@ build-prod:
8162
- build
8263
- test
8364

84-
deploy-branch:
85-
stage: deploy
86-
script:
87-
- >
88-
DOMAIN={{cookiecutter.domain_branch}}
89-
TRAEFIK_TAG={{cookiecutter.traefik_constraint_tag_branch}}
90-
TRAEFIK_PUBLIC_TAG={{cookiecutter.traefik_public_constraint_tag}}
91-
STACK_NAME={{cookiecutter.docker_swarm_stack_name_branch}}
92-
TAG=branch
93-
docker-compose
94-
-f docker-compose.yml
95-
-f docker-compose.admin.yml
96-
-f docker-compose.images.yml
97-
-f docker-compose.deploy.yml
98-
config > docker-stack.yml
99-
- docker stack deploy -c docker-stack.yml --with-registry-auth {{cookiecutter.docker_swarm_stack_name_branch}}
100-
environment:
101-
name: branch
102-
url: https://{{cookiecutter.domain_branch}}
103-
except:
104-
- master
105-
- production
106-
- tags
107-
tags:
108-
- swarm
109-
- branch
110-
11165
deploy-stag:
11266
stage: deploy
11367
script:

{{cookiecutter.project_slug}}/README.md

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ docker-compose -f docker-stack.yml build
5858
docker-compose -f docker-stack.yml up -d
5959
sleep 20; # Give some time for the DB and prestart script to finish
6060
# Run the REST tests
61-
docker-compose -f docker-stack.yml exec -T backend-rest-tests pytest
61+
docker-compose -f docker-stack.yml exec -T backend-tests pytest
6262
# Stop and eliminate the testing stack
6363
docker-compose -f docker-stack.yml down -v --remove-orphans
6464
```
6565

66-
The tests run with Pytest, modify and add tests to `./backend/app/app/rest_tests/`.
66+
The tests run with Pytest, modify and add tests to `./backend/app/app/tests/`.
6767

68-
If you need to install any additional package for the REST tests, add it to the file `./backend/app/Dockerfile-rest-tests`.
68+
If you need to install any additional package for the REST tests, add it to the file `./backend/app/Dockerfile-tests`.
6969

7070
If you use GitLab CI the tests will run automatically.
7171

@@ -229,11 +229,12 @@ docker stack deploy -c docker-stack.yml --with-registry-auth {{cookiecutter.dock
229229

230230
If you use GitLab CI, the included .gitlab-ci.yml can automatically deploy it. You may need to update it according to your GitLab configurations.
231231

232-
GitLab CI is configured assuming 3 environments following GitLab flow:
232+
GitLab CI is configured assuming 2 environments following GitLab flow:
233233

234234
* `prod` (production) from the `production` branch.
235235
* `stag` (staging) from the `master` branch.
236-
* `branch`, from any other branch (a feature in development).
236+
237+
If you need to add more environments, for example, you could imagine using a client-approved `preprod` branch, you can just copy the configurations int `.gitlab-ci.yml` for `stag` and rename the corresponding variables. All the Docker Compose files are configured to support as many environments as you need, so that you only need to modify `.gitlab-ci.yml` (or whichever CI system configuration you are using).
237238

238239

239240
## Docker Compose files
@@ -301,20 +302,6 @@ Swagger UI: https://{{cookiecutter.domain_staging}}/swagger/
301302
PGAdmin: https://pgadmin.{{cookiecutter.domain_staging}}
302303

303304
Flower: https://flower.{{cookiecutter.domain_staging}}
304-
305-
### Branch (feature branches)
306-
307-
Feature branch URLs, from any other branch.
308-
309-
Front end: https://{{cookiecutter.domain_branch}}
310-
311-
Back end: https://{{cookiecutter.domain_branch}}/api/
312-
313-
Swagger UI: https://{{cookiecutter.domain_branch}}/swagger/
314-
315-
PGAdmin: https://pgadmin.{{cookiecutter.domain_branch}}
316-
317-
Flower: https://flower.{{cookiecutter.domain_branch}}
318305

319306
### Development
320307

@@ -338,11 +325,9 @@ Traefik UI: http://{{cookiecutter.domain_dev}}:8080
338325
* `project_slug`: {{cookiecutter.project_slug}}
339326
* `domain_main`: {{cookiecutter.domain_main}}
340327
* `domain_staging`: {{cookiecutter.domain_staging}}
341-
* `domain_branch`: {{cookiecutter.domain_branch}}
342328
* `domain_dev`: {{cookiecutter.domain_dev}}
343329
* `docker_swarm_stack_name_main`: {{cookiecutter.docker_swarm_stack_name_main}}
344330
* `docker_swarm_stack_name_staging`: {{cookiecutter.docker_swarm_stack_name_staging}}
345-
* `docker_swarm_stack_name_branch`: {{cookiecutter.docker_swarm_stack_name_branch}}
346331
* `secret_key`: {{cookiecutter.secret_key}}
347332
* `first_superuser`: {{cookiecutter.first_superuser}}
348333
* `first_superuser_password`: {{cookiecutter.first_superuser_password}}
@@ -351,7 +336,6 @@ Traefik UI: http://{{cookiecutter.domain_dev}}:8080
351336
* `pgadmin_default_user_password`: {{cookiecutter.pgadmin_default_user_password}}
352337
* `traefik_constraint_tag`: {{cookiecutter.traefik_constraint_tag}}
353338
* `traefik_constraint_tag_staging`: {{cookiecutter.traefik_constraint_tag_staging}}
354-
* `traefik_constraint_tag_branch`: {{cookiecutter.traefik_constraint_tag_branch}}
355339
* `traefik_public_network`: {{cookiecutter.traefik_public_network}}
356340
* `traefik_public_constraint_tag`: {{cookiecutter.traefik_public_constraint_tag}}
357341
* `flower_auth`: {{cookiecutter.flower_auth}}

{{cookiecutter.project_slug}}/backend/Dockerfile-rest-tests renamed to {{cookiecutter.project_slug}}/backend/Dockerfile-tests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ COPY ./app /app
1414

1515
ENV PYTHONPATH=/app
1616

17-
WORKDIR /app/app/rest_tests
17+
WORKDIR /app/app/tests

{{cookiecutter.project_slug}}/backend/app/app/rest_tests/.gitignore renamed to {{cookiecutter.project_slug}}/backend/app/app/tests/.gitignore

File renamed without changes.

{{cookiecutter.project_slug}}/backend/app/app/rest_tests/__init__.py renamed to {{cookiecutter.project_slug}}/backend/app/app/tests/__init__.py

File renamed without changes.

{{cookiecutter.project_slug}}/backend/app/app/rest_tests/api/__init__.py renamed to {{cookiecutter.project_slug}}/backend/app/app/tests/api/__init__.py

File renamed without changes.

{{cookiecutter.project_slug}}/backend/app/app/rest_tests/api/api_v1/__init__.py renamed to {{cookiecutter.project_slug}}/backend/app/app/tests/api/api_v1/__init__.py

File renamed without changes.

{{cookiecutter.project_slug}}/backend/app/app/rest_tests/api/api_v1/conftest.py renamed to {{cookiecutter.project_slug}}/backend/app/app/tests/api/api_v1/conftest.py

File renamed without changes.

0 commit comments

Comments
 (0)