Skip to content

Commit e0d4cc6

Browse files
authored
Switch to docker compose command, fix tests (#855)
* Switch to docker compose cmd * Update versions in pre-commit * Update inner pre commit config * Bump upload artifact * Remove version from docker compose config * fix test script, remove extra package
1 parent 429c981 commit e0d4cc6

File tree

9 files changed

+34
-39
lines changed

9 files changed

+34
-39
lines changed

.github/workflows/cookiecutter-project-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ jobs:
3939
if: ${{ always() }}
4040
run: |
4141
cd ./test-project
42-
docker-compose logs -t
42+
docker compose logs -t
4343
4444
- name: Archive cypress screenshots
4545
if: always()
46-
uses: actions/upload-artifact@v3
46+
uses: actions/upload-artifact@v4
4747
with:
4848
name: cypress-screenshots
4949
path: |

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
exclude: "(src/generated/|alembic/versions|test.yaml)"
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v2.3.0
4+
rev: v5.0.0
55
hooks:
66
- id: check-yaml
77
- id: end-of-file-fixer
88
- id: trailing-whitespace
99

1010
# Backend hooks
1111
- repo: https://github.com/psf/black
12-
rev: 22.3.0
12+
rev: 25.1.0
1313
hooks:
1414
- id: black
1515
files: backend/
1616
types: [file, python]
1717
- repo: https://github.com/myint/autoflake
18-
rev: v1.4
18+
rev: v2.3.1
1919
hooks:
2020
- id: autoflake
2121
args:
@@ -25,7 +25,7 @@ repos:
2525
types: [file, python]
2626

2727
- repo: https://github.com/pycqa/isort
28-
rev: 5.11.5
28+
rev: 6.0.1
2929
hooks:
3030
- id: isort
3131
name: isort (python)
@@ -42,7 +42,7 @@ repos:
4242
types: [pyi]
4343

4444
- repo: https://github.com/pycqa/flake8
45-
rev: 3.8.3
45+
rev: 7.1.2
4646
hooks:
4747
- id: flake8
4848
files: backend/

scripts/test.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
set -eou pipefail
44

5-
# Stop containers from previous run, if any
6-
(cd ./test-project && docker-compose -f docker-compose.yml down --rmi local -v && cd ..) || true
5+
# Stop containers from prlibasound2evious run, if any
6+
(cd ./test-project && docker compose -f docker-compose.yml down --rmi local -v && cd ..) || true
77

88
# Run this from the root of the project
99
rm -rf ./test-project
@@ -13,24 +13,24 @@ cookiecutter --no-input -f ./ project_slug="test-project" project_name="Test pro
1313
cd ./test-project/
1414

1515
# Start docker containers
16-
docker-compose -f docker-compose.yml up -d --build
16+
docker compose -f docker-compose.yml up -d --build
1717

1818

1919
# Run backend tests
20-
docker-compose exec -T postgres createdb -U postgres apptest
20+
docker compose exec -T postgres createdb -U postgres apptest
2121

22-
docker-compose exec -T backend pytest -v --cov --cov-report term-missing
22+
docker compose exec -T backend pytest -v --cov --cov-report term-missing
2323

2424
# Run cypress tests
25-
docker-compose exec -T backend alembic upgrade head
25+
docker compose exec -T backend alembic upgrade head
2626

27-
docker-compose exec -T backend alembic check
27+
docker compose exec -T backend alembic check
2828

2929
docker build --target build -t frontend-build:latest frontend
3030

3131
mv $(pwd)/frontend/src/generated /tmp/src-generated
3232

33-
PACKAGE_LIST="xvfb libnss3 libatk1.0 libatk-bridge2.0 libgtk-3.0 libgbm1 libasound2 default-jre"
33+
PACKAGE_LIST="xvfb libnss3 libatk1.0 libatk-bridge2.0 libgtk-3.0 libgbm1 default-jre"
3434
# If GITHUB_REPOSITORY is not set, then we can just run it in docker
3535
# We need to have two paths here because Github CI works weirdly with bind mounts that we can use to run the tests locally in Docker
3636
if [ -z "${GITHUB_REPOSITORY-}" ]

{{cookiecutter.project_slug}}/.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
exclude: "(frontend/src/generated/|backend/alembic/versions/)"
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v2.3.0
4+
rev: v5.0.0
55
hooks:
66
- id: check-yaml
77
- id: end-of-file-fixer
88
- id: trailing-whitespace
99

1010
# Backend hooks
1111
- repo: https://github.com/psf/black
12-
rev: 22.3.0
12+
rev: 25.1.0
1313
hooks:
1414
- id: black
1515
files: backend/
1616
types: [file, python]
1717
- repo: https://github.com/myint/autoflake
18-
rev: v1.4
18+
rev: v2.3.1
1919
hooks:
2020
- id: autoflake
2121
args:
@@ -25,7 +25,7 @@ repos:
2525
types: [file, python]
2626

2727
- repo: https://github.com/pycqa/isort
28-
rev: 5.11.5
28+
rev: 6.0.1
2929
hooks:
3030
- id: isort
3131
name: isort (python)
@@ -42,7 +42,7 @@ repos:
4242
types: [pyi]
4343

4444
- repo: https://github.com/pycqa/flake8
45-
rev: 3.8.3
45+
rev: 7.1.2
4646
hooks:
4747
- id: flake8
4848
files: backend/

{{cookiecutter.project_slug}}/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ The frontend of this project uses React Admin. Follow the quick tutorial to unde
1616

1717
## Step 1: Getting started
1818

19-
Start a local development instance with docker-compose
19+
Start a local development instance with docker compose
2020

2121
```bash
22-
docker-compose up -d
22+
docker compose up -d
2323

2424
# Run database migration
25-
docker-compose exec backend alembic upgrade head
25+
docker compose exec backend alembic upgrade head
2626

2727
# Create database used for testing
28-
docker-compose exec postgres createdb apptest -U postgres
28+
docker compose exec postgres createdb apptest -U postgres
2929
```
3030

3131
Now you can navigate to the following URLs:
@@ -43,10 +43,10 @@ pre-commit install
4343

4444
### Local development
4545

46-
The backend setup of docker-compose is set to automatically reload the app whenever code is updated. However, for frontend it's easier to develop locally.
46+
The backend setup of docker compose is set to automatically reload the app whenever code is updated. However, for frontend it's easier to develop locally.
4747

4848
```bash
49-
docker-compose stop frontend
49+
docker compose stop frontend
5050
cd frontend
5151
yarn
5252
yarn start
@@ -66,7 +66,7 @@ Don't forget to edit the `.env` file and update the `BACKEND_CORS_ORIGINS` value
6666
If you add a dependency, you'll need to rebuild your containers like this:
6767

6868
```bash
69-
docker-compose up -d --build
69+
docker compose up -d --build
7070
```
7171

7272
### Regenerate front-end API package
@@ -83,24 +83,24 @@ These two are the most used commands when working with alembic. For more info, f
8383

8484
```bash
8585
# Auto generate a revision
86-
docker-compose exec backend alembic revision --autogenerate -m 'message'
86+
docker compose exec backend alembic revision --autogenerate -m 'message'
8787

8888
# Apply latest changes
89-
docker-compose exec backend alembic upgrade head
89+
docker compose exec backend alembic upgrade head
9090
```
9191

9292
### Backend tests
9393

9494
The `Backend` service uses a hardcoded database named `apptest`. First, ensure that it's created
9595

9696
```bash
97-
docker-compose exec postgres createdb apptest -U postgres
97+
docker compose exec postgres createdb apptest -U postgres
9898
```
9999

100100
Then you can run tests with this command:
101101

102102
```bash
103-
docker-compose run backend pytest --cov --cov-report term-missing
103+
docker compose run backend pytest --cov --cov-report term-missing
104104
```
105105

106106
### Single docker image

{{cookiecutter.project_slug}}/backend/app/api/items.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ async def get_items(
3737
.scalars()
3838
.all()
3939
)
40-
response.headers[
41-
"Content-Range"
42-
] = f"{request_params.skip}-{request_params.skip + len(items)}/{total}"
40+
response.headers["Content-Range"] = (
41+
f"{request_params.skip}-{request_params.skip + len(items)}/{total}"
42+
)
4343
return items
4444

4545

{{cookiecutter.project_slug}}/docker-compose.ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3.9"
2-
31
services:
42
backend:
53
image: "{{ cookiecutter.project_slug }}-backend:latest"

{{cookiecutter.project_slug}}/docker-compose.override.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# We specify volumes in override.yml, because volumes don't work well in a
22
# docker-in-docker setup (the paths of parent host rarely match the nested containers)
3-
version: "3.9"
43

54
services:
65
postgres:

{{cookiecutter.project_slug}}/docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3.9"
2-
31
services:
42
postgres:
53
image: postgres:12

0 commit comments

Comments
 (0)