2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-27 19:16:44 +00:00

Add namespaces to tasks (#7904)

* Namespaces for invoke tasks
Fixes #7852

* adjust various places that call re-namespaced tasks

* use full invoke command
easier for future refactors

* fix call name

* move worker to int

* adapt calls in tasks

* fix changed path

* ignore localhost links

* Avoid using internal names
This commit is contained in:
Matthias Mair 2024-09-05 05:04:57 +02:00 committed by GitHub
parent 690308d032
commit e3205184be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 112 additions and 58 deletions

View File

@ -11,10 +11,10 @@ python3 -m venv /home/inventree/dev/venv --system-site-packages --upgrade-deps
invoke update -s
# Configure dev environment
invoke setup-dev
invoke dev.setup-dev
# Install required frontend packages
invoke frontend-install
invoke dev.frontend-install
# remove existing gitconfig created by "Avoiding Dubious Ownership" step
# so that it gets copied from host to the container to have your global

View File

@ -9,7 +9,7 @@ runs:
shell: bash
run: |
invoke migrate
invoke import-fixtures
invoke dev.import-fixtures
invoke export-records -f data.json
python3 ./src/backend/InvenTree/manage.py flush --noinput
invoke migrate

View File

@ -37,6 +37,6 @@ jobs:
install: true
apt-dependency: gettext
- name: Test Translations
run: invoke translate
run: invoke dev.translate
- name: Check Migration Files
run: python3 .github/scripts/check_migration_files.py

View File

@ -97,7 +97,7 @@ jobs:
run: |
docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run inventree-dev-server invoke install
docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run inventree-dev-server invoke update
docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run inventree-dev-server invoke setup-dev
docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run inventree-dev-server invoke dev.setup-dev
docker compose --project-directory . -f contrib/container/dev-docker-compose.yml up -d
docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run inventree-dev-server invoke wait
- name: Check Data Directory
@ -115,10 +115,10 @@ jobs:
- name: Run Unit Tests
run: |
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> contrib/container/docker.dev.env
docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run --rm inventree-dev-server invoke test --disable-pty
docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run --rm inventree-dev-server invoke dev.test --disable-pty
- name: Run Migration Tests
run: |
docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run --rm inventree-dev-server invoke test --migrations
docker compose --project-directory . -f contrib/container/dev-docker-compose.yml run --rm inventree-dev-server invoke dev.test --migrations
- name: Clean up test folder
run: |
rm -rf InvenTree/_testfolder

View File

@ -157,7 +157,7 @@ jobs:
dev-install: true
update: true
- name: Export API Documentation
run: invoke schema --ignore-warnings --filename src/backend/InvenTree/schema.yml
run: invoke dev.schema --ignore-warnings --filename src/backend/InvenTree/schema.yml
- name: Upload schema
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # pin@v4.4.0
with:
@ -191,7 +191,7 @@ jobs:
diff --color -u src/backend/InvenTree/schema.yml api.yaml
diff -u src/backend/InvenTree/schema.yml api.yaml && echo "no difference in API schema " || exit 2
- name: Check schema - including warnings
run: invoke schema
run: invoke dev.schema
continue-on-error: true
- name: Extract version for publishing
id: version
@ -262,9 +262,9 @@ jobs:
run: git clone --depth 1 https://github.com/inventree/${{ env.wrapper_name }} ./${{ env.wrapper_name }}
- name: Start InvenTree Server
run: |
invoke delete-data -f
invoke import-fixtures
invoke server -a 127.0.0.1:12345 &
invoke dev.delete-data -f
invoke dev.import-fixtures
invoke dev.server -a 127.0.0.1:12345 &
invoke wait
- name: Run Tests For `${{ env.wrapper_name }}`
run: |
@ -302,11 +302,11 @@ jobs:
- name: Data Export Test
uses: ./.github/actions/migration
- name: Test Translations
run: invoke translate
run: invoke dev.translate
- name: Check Migration Files
run: python3 .github/scripts/check_migration_files.py
- name: Coverage Tests
run: invoke test --coverage
run: invoke dev.test --coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # pin@v4.5.0
if: always()
@ -355,7 +355,7 @@ jobs:
dev-install: true
update: true
- name: Run Tests
run: invoke test
run: invoke dev.test
- name: Data Export Test
uses: ./.github/actions/migration
@ -399,7 +399,7 @@ jobs:
dev-install: true
update: true
- name: Run Tests
run: invoke test
run: invoke dev.test
- name: Data Export Test
uses: ./.github/actions/migration
@ -438,7 +438,7 @@ jobs:
dev-install: true
update: true
- name: Run Tests
run: invoke test --migrations --report --coverage
run: invoke dev.test --migrations --report --coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # pin@v4.5.0
if: always()
@ -525,11 +525,11 @@ jobs:
install: true
update: true
- name: Set up test data
run: invoke setup-test -i
run: invoke dev.setup-test -i
- name: Rebuild thumbnails
run: invoke rebuild-thumbnails
run: invoke int.rebuild-thumbnails
- name: Install dependencies
run: inv frontend-compile
run: invoke int.frontend-compile
- name: Install Playwright Browsers
run: cd src/frontend && npx playwright install --with-deps
- name: Run Playwright tests

View File

@ -39,7 +39,7 @@ jobs:
npm: true
apt-dependency: gettext
- name: Make Translations
run: invoke translate
run: invoke dev.translate
- name: Remove compiled static files
run: rm -rf src/backend/InvenTree/static
- name: Remove all local changes that are not *.po files

20
.vscode/tasks.json vendored
View File

@ -9,61 +9,61 @@
{
"label": "worker",
"type": "shell",
"command": "inv worker",
"command": "invoke int.worker",
"problemMatcher": [],
},
{
"label": "clean-settings",
"type": "shell",
"command": "inv clean-settings",
"command": "invoke int.clean-settings",
"problemMatcher": [],
},
{
"label": "delete-data",
"type": "shell",
"command": "inv delete-data",
"command": "invoke dev.delete-data",
"problemMatcher": [],
},
{
"label": "migrate",
"type": "shell",
"command": "inv migrate",
"command": "invoke migrate",
"problemMatcher": [],
},
{
"label": "server",
"type": "shell",
"command": "inv server",
"command": "invoke dev.server",
"problemMatcher": [],
},
{
"label": "setup-dev",
"type": "shell",
"command": "inv setup-dev",
"command": "invoke dev.setup-dev",
"problemMatcher": [],
},
{
"label": "setup-test",
"type": "shell",
"command": "inv setup-test -i --path dev/inventree-demo-dataset",
"command": "invoke dev.setup-test -i --path dev/inventree-demo-dataset",
"problemMatcher": [],
},
{
"label": "superuser",
"type": "shell",
"command": "inv superuser",
"command": "invoke superuser",
"problemMatcher": [],
},
{
"label": "test",
"type": "shell",
"command": "inv test",
"command": "invoke dev.test",
"problemMatcher": [],
},
{
"label": "update",
"type": "shell",
"command": "inv update",
"command": "invoke update",
"problemMatcher": [],
},
]

View File

@ -115,7 +115,7 @@ RUN apk add --no-cache --update nodejs npm yarn
RUN yarn config set network-timeout 600000 -g
COPY src ${INVENTREE_HOME}/src
COPY tasks.py ${INVENTREE_HOME}/tasks.py
RUN cd ${INVENTREE_HOME} && inv frontend-compile
RUN cd ${INVENTREE_HOME} && invoke int.frontend-compile
# InvenTree production image:
# - Copies required files from local directory

View File

@ -56,7 +56,7 @@ services:
inventree-dev-worker:
image: inventree-dev-image
build: *build_config
command: invoke worker
command: invoke int.worker
depends_on:
- inventree-dev-server
volumes:

View File

@ -83,7 +83,7 @@ services:
# If you wish to specify a particular InvenTree version, do so here
image: inventree/inventree:${INVENTREE_TAG:-stable}
container_name: inventree-worker
command: invoke worker
command: invoke int.worker
depends_on:
- inventree-server
env_file:

View File

@ -287,7 +287,7 @@ function update_or_install() {
# Run update as app user
echo "# Updating InvenTree"
sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && pip install wheel"
sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && invoke update | sed -e 's/^/# inv update| /;'"
sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && invoke update | sed -e 's/^/# invoke update| /;'"
# Make sure permissions are correct again
echo "# Set permissions for data dir and media: ${DATA_DIR}"

View File

@ -9,9 +9,9 @@ export SETUP_ENVS=PATH,APP_HOME,INVENTREE_MEDIA_ROOT,INVENTREE_STATIC_ROOT,INVEN
if test -f "${APP_HOME}/env/bin/pip"; then
# Check if clear-generated is available
if sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && invoke clear-generated --help" > /dev/null 2>&1; then
if sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && invoke int.clear-generated --help" > /dev/null 2>&1; then
echo "# Clearing precompiled files"
sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && invoke clear-generated"
sudo -u ${APP_USER} --preserve-env=$SETUP_ENVS bash -c "cd ${APP_HOME} && invoke int.clear-generated"
else
echo "# Clearing precompiled files - skipping"
fi

View File

@ -22,10 +22,10 @@ The API is self-documenting, and the documentation is provided alongside any Inv
### Generating Schema File
If you want to generate the API schema file yourself (for example to use with an external client, use the `invoke schema` command. Run with the `-help` command to see available options.
If you want to generate the API schema file yourself (for example to use with an external client, use the `invoke dev.schema` command. Run with the `-help` command to see available options.
```
invoke schema -help
invoke dev.schema -help
```
## Authentication

View File

@ -52,7 +52,7 @@ invoke setup-dev
## Branches and Versioning
InvenTree roughly follow the [GitLab flow](https://docs.gitlab.com/ee/topics/gitlab_flow.html) branching style, to allow simple management of multiple tagged releases, short-lived branches, and development on the main branch.
InvenTree roughly follow the [GitLab flow](https://about.gitlab.com/topics/version-control/what-are-gitlab-flow-best-practices/) branching style, to allow simple management of multiple tagged releases, short-lived branches, and development on the main branch.
There are nominally 5 active branches:
- `master` - The main development branch

View File

@ -14,7 +14,7 @@ The React frontend requires its own packages that aren't installed via the usual
#### Docker
Run the following command:
`docker compose run inventree-dev-server invoke frontend-compile`
`docker compose run inventree-dev-server invoke int.frontend-compile`
This will install the required packages for running the React frontend on your InvenTree dev server.
#### Devcontainer
@ -24,14 +24,14 @@ This will install the required packages for running the React frontend on your I
Open a new terminal from the top menu by clicking `Terminal > New Terminal`
Make sure this terminal is running within the virtual env. The start of the last line should display `(venv)`
Run the command `invoke frontend-compile`. Wait for this to finish
Run the command `invoke int.frontend-compile`. Wait for this to finish
### Running
After finishing the install, you need to launch a frontend server to be able to view the new UI.
Using the previously described ways of running commands, execute the following:
`invoke frontend-dev` in your environment
`invoke dev.frontend-dev` in your environment
This command does not run as a background daemon, and will occupy the window it's ran in.
### Accessing
@ -40,7 +40,7 @@ When the frontend server is running, it will be available on port 5173.
i.e: https://localhost:5173/
!!! note "Backend Server"
The InvenTree backend server must also be running, for the frontend interface to have something to connect to! To launch a backend server, use the `invoke server` command.
The InvenTree backend server must also be running, for the frontend interface to have something to connect to! To launch a backend server, use the `invoke dev.server` command.
### Debugging

View File

@ -107,7 +107,7 @@ The background worker process must be started separately to the web-server appli
From the top-level source directory, run the following command from a separate terminal, while the server is already running:
```
invoke worker
invoke int.worker
```
!!! info "Supervisor"

View File

@ -17,7 +17,7 @@ InvenTree includes a simple server application, suitable for use in a developmen
To run the development server on a local machine, run the command:
```
(env) invoke server
(env) invoke dev.server
```
This will launch the InvenTree web interface at `http://127.0.0.1:8000`.
@ -25,7 +25,7 @@ This will launch the InvenTree web interface at `http://127.0.0.1:8000`.
A different port can be specified using the `-a` flag:
```
(env) invoke server -a 127.0.0.1:8123
(env) invoke dev.server -a 127.0.0.1:8123
```
Serving on the address `127.0.0.1` means that InvenTree will only be available *on that computer*. The server will be accessible from a web browser on the same computer, but not from any other computers on the local network.
@ -35,7 +35,7 @@ Serving on the address `127.0.0.1` means that InvenTree will only be available *
To enable access to the InvenTree server from other computers on a local network, you need to know the IP of the computer running the server. For example, if the server IP address is `192.168.120.1`:
```
(env) invoke server -a 192.168.120.1:8000
(env) invoke dev.server -a 192.168.120.1:8000
```
## Background Worker
@ -52,7 +52,7 @@ source ./env/bin/activate
### Start Background Worker
```
(env) invoke worker
(env) invoke int.worker
```
This will start the background process manager in the current shell.

View File

@ -202,7 +202,7 @@ Any persistent files generated by the Caddy container (such as certificates, etc
To quickly get started with a [demo dataset](../demo.md), you can run the following command:
```
docker compose run --rm inventree-server invoke setup-test -i
docker compose run --rm inventree-server invoke dev.setup-test -i
```
This will install the InvenTree demo dataset into your instance.
@ -210,7 +210,7 @@ This will install the InvenTree demo dataset into your instance.
To start afresh (and completely remove the existing database), run the following command:
```
docker compose run --rm inventree-server invoke delete-data
docker compose run --rm inventree-server invoke dev.delete-data
```
## Install custom packages
@ -247,7 +247,7 @@ index 8adee63..dc3993c 100644
- image: inventree/inventree:${INVENTREE_TAG:-stable}
+ image: inventree/inventree:${INVENTREE_TAG:-stable}-custom
+ pull_policy: never
command: invoke worker
command: invoke int.worker
depends_on:
- inventree-server
```

View File

@ -6,6 +6,9 @@
{
"pattern": "http://localhost"
},
{
"pattern": "https://localhost:5173/"
},
{
"pattern": "http://127.0.0.1"
},

View File

@ -17,6 +17,6 @@ build:
- echo "Generating API schema file"
- pip install -U invoke
- invoke migrate
- invoke export-settings-definitions --filename docs/inventree_settings.json --overwrite
- invoke schema --filename docs/schema.yml --ignore-warnings
- invoke int.export-settings-definitions --filename docs/inventree_settings.json --overwrite
- invoke dev.schema --filename docs/schema.yml --ignore-warnings
- python docs/extract_schema.py docs/schema.yml

View File

@ -36,7 +36,7 @@ export default defineConfig({
timeout: 120 * 1000
},
{
command: 'invoke server -a 127.0.0.1:8000',
command: 'invoke dev.server -a 127.0.0.1:8000',
env: {
INVENTREE_DEBUG: 'True'
},

View File

@ -11,7 +11,7 @@ from pathlib import Path
from platform import python_version
from typing import Optional
from invoke import task
from invoke import Collection, task
def checkPythonVersion():
@ -367,7 +367,7 @@ def translate_stats(c):
The file generated from this is needed for the UI.
"""
# Recompile the translation files (.mo)
# We do not run 'invoke translate' here, as that will touch the source (.po) files too!
# We do not run 'invoke dev.translate' here, as that will touch the source (.po) files too!
try:
manage(c, 'compilemessages', pty=True)
except Exception:
@ -1431,7 +1431,7 @@ def docs_server(c, address='localhost:8080', compile_schema=False):
@task
def clear_generated(c):
"""Clear generated files from `inv update`."""
"""Clear generated files from `invoke update`."""
# pyc/pyo files
run(c, 'find . -name "*.pyc" -exec rm -f {} +')
run(c, 'find . -name "*.pyo" -exec rm -f {} +')
@ -1441,3 +1441,54 @@ def clear_generated(c):
# Generated translations
run(c, 'find . -name "django.mo" -exec rm -f {} +')
run(c, 'find . -name "messages.mo" -exec rm -f {} +')
# Collection sorting
development = Collection(
delete_data,
docs_server,
frontend_dev,
gunicorn,
import_fixtures,
schema,
server,
setup_dev,
setup_test,
test,
test_translations,
translate,
)
internal = Collection(
clean_settings,
clear_generated,
export_settings_definitions,
frontend_build,
frontend_check,
frontend_compile,
frontend_install,
frontend_trans,
render_js_files,
rebuild_models,
rebuild_thumbnails,
showmigrations,
translate_stats,
worker,
)
ns = Collection(
backup,
export_records,
frontend_download,
import_records,
install,
migrate,
plugins,
remove_mfa,
restore,
static,
superuser,
update,
version,
wait,
)
ns.add_collection(development, 'dev')
ns.add_collection(internal, 'int')