Skip to content

Commit

Permalink
development: fix devcontainer setup
Browse files Browse the repository at this point in the history
The only supported workflow for developing in this repository
should be using the devcontainer:

Update extensions to remove unused ones and add only:
- python
- mypy
- flake8
 - pytest
 - robottest

The python modules are now installed into a venv, because
the global installation in the devcontainer could belong
to a user with a different UID due to the way the devcontainers work.
The local venv is picked up by vscode and used for all vscode extensions and
in the console automatically.
  • Loading branch information
MofX authored and thir820 committed Jan 23, 2025
1 parent 4ca8ba2 commit 26f80ac
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 58 deletions.
11 changes: 7 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "EB corbos Linux build tools",
"image": "ghcr.io/elektrobit/ebcl_dev_container:v1.4.6",
"image": "ghcr.io/elektrobit/ebcl_dev_container:v1.4.9",
// This script will get the container and tag it with the local container tag.
"initializeCommand": "${PWD}/init_workspace",
"postCreateCommand": "${PWD}/setup_workspace",
"customizations": {
"vscode": {
"settings": {
"python.terminal.activateEnvInCurrentTerminal": true,
"cmake.options.statusBarVisibility": "visible",
"cmake.configureOnOpen": false
},
"extensions": [
"[email protected]",
"[email protected]"
"ms-python.python",
"ms-python.mypy-type-checker",
"ms-python.flake8",
"littlefoxteam.vscode-python-test-adapter",
"d-biehl.robotcode"
]
}
},
Expand Down
5 changes: 1 addition & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Please use the content of this section in the PR merge comment.
_(Provide a brief description of the changes in this pull request)_

# Dependencies:
_(Provide list of pull requests with dependecies with this pull request)_
_(Provide list of pull requests with dependencies with this pull request)_

# Tests results
```bash
Expand Down Expand Up @@ -44,6 +44,3 @@ _(Provide list of pull requests with dependecies with this pull request)_
no contradictions, no double descriptions
- [ ] Terminology: technical terms are clear and they are used correctly and documented in the glossary
- [ ] Level of detail: the content matches the detail level necessary for the reviewed object
0 commit comments
Comments
0
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@

## How to develop?

Some commands are executed using sudo.
This requires allowing sudo w/o password which is a bad idea on your dev host.
To workaorund this, a dev container is used.
The recommended way to develop ebcl_build_tools is using the devcontainer.
It can used by loading the workspace into vscode and executing the command "Dev Containers: Reopen in Container".
This will download the dev container that contains all required tools,
install useful extensions (python, flake8, mypy, robot framework and pytest) and setup a virtual environment for development.

- Open the dev container.
### Tests

If you don't use the dev container, consider to run:
#### pytest
The pytests are mostly unit tests but cross over into integration tests for some modules.
Some of these tests download packages from debian repositories. They should be marked with `@pytest.mark.requires_download`.

- Setup Python venv and install required tools: `setup_workspace`
- Install extensions: `install_extensions`
Test can be executed using ptest, either on the command line or using the testing integration.

#### robot framework
The robot framework tests are black box integration tests.
They take a long time to execute and download files from debian repositories.

To execute the tests either the robot command line utility or the vscode integration can be used.
9 changes: 6 additions & 3 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
flake8==7.1.1
Flake8-pyproject==1.2.3
pytest==8.3.3
flake8==7.1.1
mypy==1.13.0
types-requests
pytest-cov==6.0.0
pytest==8.3.3
robotframework==7.2
types-PyYAML
types-requests

9 changes: 0 additions & 9 deletions init_workspace

This file was deleted.

18 changes: 0 additions & 18 deletions install_extensions

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ minversion = "6.2.5"
addopts = ""
testpaths = [ "tests" ]
markers = [
"dev_container: tests requiring tools only avaiable in the dev container, e.g. kiwi-ng.",
"dev_container: tests requiring tools only available in the dev container, e.g. kiwi-ng.",
"requires_download: tests requiring downloads form public resources, which is not allowed for GH actions",
]
log_level = "debug"
Expand Down
16 changes: 4 additions & 12 deletions setup_workspace
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@

set -e

# install embdgen dependencies
sudo apt install libparted-dev python3-dev pkg-config udev \
mtools e2fsprogs cryptsetup-bin dosfstools fakeroot fdisk \
debootstrap


# remove container ebcl installation
yes | pip uninstall ebcl

# Create a new .venv to work in
python3 -m venv .venv
. .venv/bin/activate
# install the build tools
pip install -e .

# install robot framework
pip install robotframework pytest pytest-cov
pip install -r dev-requirements.txt

0 comments on commit 26f80ac

Please sign in to comment.