mirror of
https://github.com/inventree/InvenTree.git
synced 2026-10-14 22:20:59 +00:00
reduce ci time (#12985)
* we are currently locking on olugin lease for 2 mins per ci setup; not good * fix syntax * move setting * fix assign syntax * reduce noice while setting up
This commit is contained in:
1 parent
0a0cccedd9
commit
3e367df724
5 files changed
+22
-4
No files matched your search
@@ -15,3 +15,5 @@ runs:
|
|||||||
invoke migrate
|
invoke migrate
|
||||||
invoke import-records -c -f data.json --strict
|
invoke import-records -c -f data.json --strict
|
||||||
invoke import-records -c -f data.json --strict
|
invoke import-records -c -f data.json --strict
|
||||||
|
env:
|
||||||
|
SETUP_INITIALIZING: 1
|
||||||
@@ -37,6 +37,7 @@ inputs:
|
|||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: 'composite'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||||
@@ -97,15 +98,23 @@ runs:
|
|||||||
if: ${{ inputs.dev-install == 'true' || inputs.install == 'true' }}
|
if: ${{ inputs.dev-install == 'true' || inputs.install == 'true' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: invoke install --dev
|
run: invoke install --dev
|
||||||
|
env:
|
||||||
|
SETUP_INITIALIZING: 1
|
||||||
- name: Run invoke install
|
- name: Run invoke install
|
||||||
if: ${{ inputs.install == 'true' }}
|
if: ${{ inputs.install == 'true' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: invoke install
|
run: invoke install
|
||||||
|
env:
|
||||||
|
SETUP_INITIALIZING: 1
|
||||||
- name: Run invoke update
|
- name: Run invoke update
|
||||||
if: ${{ inputs.update == 'true' }}
|
if: ${{ inputs.update == 'true' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: invoke update --skip-backup --skip-static --no-frontend
|
run: invoke update --skip-backup --skip-static --no-frontend
|
||||||
|
env:
|
||||||
|
SETUP_INITIALIZING: 1
|
||||||
- name: Collect static files
|
- name: Collect static files
|
||||||
if: ${{ inputs.static == 'true' }}
|
if: ${{ inputs.static == 'true' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: invoke static --skip-plugins
|
run: invoke static --skip-plugins
|
||||||
|
env:
|
||||||
|
SETUP_INITIALIZING: 1
|
||||||
@@ -235,6 +235,7 @@ PLUGIN_TESTING_SETUP = get_setting(
|
|||||||
PLUGIN_TESTING_EVENTS = False # Flag if events are tested right now
|
PLUGIN_TESTING_EVENTS = False # Flag if events are tested right now
|
||||||
PLUGIN_TESTING_EVENTS_ASYNC = False # Flag if events are tested asynchronously
|
PLUGIN_TESTING_EVENTS_ASYNC = False # Flag if events are tested asynchronously
|
||||||
PLUGIN_TESTING_RELOAD = False # Flag if plugin reloading is in testing (check_reload)
|
PLUGIN_TESTING_RELOAD = False # Flag if plugin reloading is in testing (check_reload)
|
||||||
|
SETUP_INITIALIZING = os.environ.get('SETUP_INITIALIZING', '0') == '1'
|
||||||
|
|
||||||
# Plugin development settings
|
# Plugin development settings
|
||||||
PLUGIN_DEV_SLUG = get_setting('INVENTREE_PLUGIN_DEV_SLUG', 'plugin_dev.slug')
|
PLUGIN_DEV_SLUG = get_setting('INVENTREE_PLUGIN_DEV_SLUG', 'plugin_dev.slug')
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ Used to serialize an potentially long-running operation,
|
|||||||
without holding a database transaction open for the duration.
|
without holding a database transaction open for the duration.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
|
||||||
import time
|
import time
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.utils import IntegrityError, OperationalError, ProgrammingError
|
from django.db.utils import IntegrityError, OperationalError, ProgrammingError
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
@@ -82,7 +82,7 @@ def acquire_lease_blocking(
|
|||||||
"""
|
"""
|
||||||
deadline = time.monotonic() + timeout
|
deadline = time.monotonic() + timeout
|
||||||
|
|
||||||
if os.environ.get('SETUP_INITIALIZING', '0') == '1':
|
if settings.SETUP_INITIALIZING:
|
||||||
logger.debug("Skipping lease acquisition for '%s' during initialization", key)
|
logger.debug("Skipping lease acquisition for '%s' during initialization", key)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -227,6 +227,10 @@ class PluginsRegistry:
|
|||||||
dict[str, PluginConfig]: Mapping of plugin slug to PluginConfig instance.
|
dict[str, PluginConfig]: Mapping of plugin slug to PluginConfig instance.
|
||||||
None if the database is not ready to be queried.
|
None if the database is not ready to be queried.
|
||||||
"""
|
"""
|
||||||
|
# skip if the setup is initializing
|
||||||
|
if settings.SETUP_INITIALIZING:
|
||||||
|
return None
|
||||||
|
|
||||||
# As we have already checked the registry hash, this is a valid cache key
|
# As we have already checked the registry hash, this is a valid cache key
|
||||||
cache_key = f'plugin_configs:{self.registry_hash}'
|
cache_key = f'plugin_configs:{self.registry_hash}'
|
||||||
|
|
||||||
@@ -518,8 +522,10 @@ class PluginsRegistry:
|
|||||||
self.update_plugin_hash()
|
self.update_plugin_hash()
|
||||||
logger.info('Plugin Registry: Loaded %s plugins', len(self.plugins))
|
logger.info('Plugin Registry: Loaded %s plugins', len(self.plugins))
|
||||||
|
|
||||||
# Ensure that each loaded plugin has a valid configuration object in the database
|
# Ensure that each loaded plugin has a valid configuration object in the database; skip if setup is initializing
|
||||||
for plugin in self.plugins.values():
|
for plugin in (
|
||||||
|
self.plugins.values() if not settings.SETUP_INITIALIZING else []
|
||||||
|
):
|
||||||
if config := self.get_plugin_config(plugin.slug):
|
if config := self.get_plugin_config(plugin.slug):
|
||||||
# Ensure mandatory plugins are marked as active
|
# Ensure mandatory plugins are marked as active
|
||||||
if config.is_mandatory() and not config.active:
|
if config.is_mandatory() and not config.active:
|
||||||
|
|||||||
Reference in new issue
Block a user