Skip to content

Commit 20e4b17

Browse files
authored
Merge pull request #5 from aucampia/switch-to-poetry
Fix devcontainer stuff
2 parents c154844 + 2cee383 commit 20e4b17

File tree

10 files changed

+43
-23
lines changed

10 files changed

+43
-23
lines changed

.devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
"EditorConfig.EditorConfig",
2020
"paulvarache.vscode-taskfile",
2121
"stardog-union.vscode-stardog-languages"
22-
]
22+
],
23+
"postCreateCommand": "poetry install --all-extras"
2324
}

.github/workflows/validate.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ on:
88

99
env:
1010
FORCE_COLOR: 1
11-
XDG_CACHE_HOME: ${{ github.workspace }}/.cache
12-
POETRY_CACHE_DIR: ${{ github.workspace }}/.cache/pypoetry
13-
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip
11+
XDG_CACHE_HOME: ${{ github.workspace }}/.var/cache
12+
POETRY_CACHE_DIR: ${{ github.workspace }}/.var/cache/pypoetry
13+
PIP_CACHE_DIR: ${{ github.workspace }}/.var/cache/pip
1414

1515

1616
concurrency:
@@ -121,7 +121,7 @@ jobs:
121121
- name: Cache XDG_CACHE_HOME
122122
uses: actions/cache@v3
123123
with:
124-
path: ~/.cache
124+
path: ${{ env.XDG_CACHE_HOME }}
125125
key: ${{ github.job }}-xdg-v1-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml', '**/poetry.lock', '**/with-fuseki.sh', '**/*requirements*.txt') }}
126126
restore-keys: |
127127
${{ github.job }}-xdg-v1-${{ matrix.os }}-${{ matrix.python-version }}-

.var/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

Dockerfile.devcontainer

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ COPY devtools/requirements-poetry.in /var/tmp/
4646
RUN \
4747
python -m pip install --upgrade \
4848
tox \
49+
pre-commit \
4950
-r /var/tmp/requirements-poetry.in \
5051
&& \
5152
true
53+
54+
RUN git config --system --add safe.directory /srv/workspace

Taskfile.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ tasks:
216216
- task: clean:tox
217217
- task: clean:mypy
218218
- task: venv:clean
219+
- task: _rimraf
220+
vars: { RIMRAF_TARGET: ".var/devcontainer" }
219221

220222
test:data:fetch:
221223
desc: Fetch test data.

docker-compose.yml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,32 @@ services:
77
dockerfile: Dockerfile.devcontainer
88
working_dir: /srv/workspace
99
environment:
10-
- POETRY_VIRTUALENVS_IN_PROJECT=1
10+
- XDG_CACHE_HOME=/srv/workspace/.var/devcontainer/cache
11+
- MYPY_CACHE_DIR=/srv/workspace/.var/devcontainer/mypy_cache
12+
- TOX_WORK_DIR=/srv/workspace/.var/devcontainer/tox
13+
- PYTEST_ADDOPTS=-o cache_dir=/srv/workspace/.var/devcontainer/pytest_cache
14+
- PRE_COMMIT_HOME=/srv/workspace/.var/devcontainer/pre-commit
1115
volumes:
1216
- .:/srv/workspace:z,cached
13-
- xdg-cache-home:/root/.cache
14-
- dot-venv:/srv/workspace/.venv
15-
- dot-tox:/srv/workspace/.tox
16-
- dot-mypy-cache:/srv/workspace/.mypy_cache
17-
- dot-pytest-cache:/srv/workspace/.pytest_cache
1817
command:
1918
- /bin/sh
2019
- -c
2120
- |
2221
echo Waiting for shutdown... override the command if this is not what you want. 1>&2
2322
while sleep 1000; do :; done
23+
run:
24+
build:
25+
context: .
26+
dockerfile: Dockerfile.devcontainer
27+
working_dir: /srv/workspace
28+
environment:
29+
- XDG_CACHE_HOME=/srv/workspace-var/cache
30+
- MYPY_CACHE_DIR=/srv/workspace-var/mypy_cache
31+
- TOX_WORK_DIR=/srv/workspace-var/tox
32+
- PYTEST_ADDOPTS=-o cache_dir=/srv/workspace-var/pytest_cache
33+
- PRE_COMMIT_HOME=/srv/workspace-var/pre-commit
34+
volumes:
35+
- .:/srv/workspace:z,cached
36+
- workspace-var:/srv/workspace-var
2437
volumes:
25-
xdg-cache-home: {}
26-
dot-venv: {}
27-
dot-tox: {}
28-
dot-mypy-cache: {}
29-
dot-pytest-cache: {}
38+
workspace-var: {}

docs/developers.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,16 @@ To use the development container directly:
297297
docker-compose build
298298
299299
# Configure the system for development.
300-
docker-compose run --rm devcontainer task configure
300+
docker-compose run --rm run task configure
301301
302302
# Run the validate task inside the devtools container.
303-
docker-compose run --rm devcontainer task validate
303+
docker-compose run --rm run task validate
304304
305305
# Run extensive tests inside the devtools container.
306-
docker-compose run --rm devcontainer task EXTENSIVE=true test
306+
docker-compose run --rm run task EXTENSIVE=true test
307307
308308
# To get a shell into the devcontainer docker image.
309-
docker-compose run --rm devcontainer bash
309+
docker-compose run --rm run bash
310310
311311
The devcontainer also works with `Podman Compose
312312
<https://github.com/containers/podman-compose>`_.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ exclude = '''
122122
| \.pytest_cache
123123
| \.tox
124124
| \.venv
125-
| \.cache
125+
| \.var
126126
| \.github
127127
| _build
128128
| htmlcov
@@ -175,7 +175,7 @@ skip = [
175175
'.pytest_cache',
176176
'.tox',
177177
'.venv',
178-
'.cache,',
178+
'.var',
179179
'.github',
180180
'_build',
181181
'htmlcov',

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exclude =
77
.git,
88
__pycache__,
99
.venv,
10-
.cache,
10+
.var,
1111
.tox,
1212
var,
1313
.mypy_cache,

tox.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
envlist =
55
flake8,py3{7,8,9,10,11},covreport,docs,precommit
66
isolated_build = True
7+
toxworkdir={env:TOX_WORK_DIR:{tox_root}/.tox}
78

89
[testenv]
910
passenv =
@@ -81,6 +82,8 @@ skip_install = true
8182
deps = pre-commit
8283
passenv =
8384
HOMEPATH # needed on Windows
85+
PRE_COMMIT_HOME # so that users can configure it
86+
XDG_CACHE_HOME # so that pre-commit won't use the default
8487
commands =
8588
precommit: pre-commit run
8689
precommitall: pre-commit run --all-files

0 commit comments

Comments
 (0)