Skip to content

Commit

Permalink
Merge branch 'master' into optimize_test_statistic_queries
Browse files Browse the repository at this point in the history
  • Loading branch information
martonmiklos authored Aug 2, 2024
2 parents 146cdec + 6fd5a99 commit 1a09ef0
Show file tree
Hide file tree
Showing 92 changed files with 37,212 additions and 32,888 deletions.
17 changes: 11 additions & 6 deletions .github/scripts/version_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

import requests

REPO = os.getenv('GITHUB_REPOSITORY', 'inventree/inventree')
GITHUB_API_URL = os.getenv('GITHUB_API_URL', 'https://api.github.com')


def get_existing_release_tags():
"""Request information on existing releases via the GitHub API."""
Expand All @@ -28,9 +31,7 @@ def get_existing_release_tags():
if token:
headers = {'Authorization': f'Bearer {token}'}

response = requests.get(
'https://api.github.com/repos/inventree/inventree/releases', headers=headers
)
response = requests.get(f'{GITHUB_API_URL}/repos/{REPO}/releases', headers=headers)

if response.status_code != 200:
raise ValueError(
Expand Down Expand Up @@ -90,6 +91,11 @@ def check_version_number(version_string, allow_duplicate=False):


if __name__ == '__main__':
# Ensure that we are running in GH Actions
if os.environ.get('GITHUB_ACTIONS', '') != 'true':
print('This script is intended to be run within a GitHub Action!')
sys.exit(1)

if 'only_version' in sys.argv:
here = Path(__file__).parent.absolute()
version_file = here.joinpath(
Expand All @@ -102,14 +108,13 @@ def check_version_number(version_string, allow_duplicate=False):
results[0] = str(int(results[0]) - 1)
print(results[0])
exit(0)

# GITHUB_REF_TYPE may be either 'branch' or 'tag'
GITHUB_REF_TYPE = os.environ['GITHUB_REF_TYPE']

# GITHUB_REF may be either 'refs/heads/<branch>' or 'refs/heads/<tag>'
GITHUB_REF = os.environ['GITHUB_REF']

GITHUB_REF_NAME = os.environ['GITHUB_REF_NAME']

GITHUB_BASE_REF = os.environ['GITHUB_BASE_REF']

# Print out version information, makes debugging actions *much* easier!
Expand Down Expand Up @@ -193,7 +198,7 @@ def check_version_number(version_string, allow_duplicate=False):
# Ref: https://getridbug.com/python/how-to-set-environment-variables-in-github-actions-using-python/
with open(os.getenv('GITHUB_ENV'), 'a') as env_file:
# Construct tag string
tags = ','.join([f'inventree/inventree:{tag}' for tag in docker_tags])
tags = ','.join([f'{REPO}:{tag}' for tag in docker_tags])

env_file.write(f'docker_tags={tags}\n')

Expand Down
2 changes: 1 addition & 1 deletion src/backend/InvenTree/InvenTree/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def check_daily_holdoff(task_name: str, n_days: int = 1) -> bool:
if last_success:
threshold = datetime.now() - timedelta(days=n_days)

if last_success > threshold:
if last_success.date() > threshold.date():
logger.info(
"Last successful run for '%s' was too recent - skipping task", task_name
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import django.db.models.deletion
import mptt.fields

from build.status_codes import BuildStatus


class Migration(migrations.Migration):

Expand Down Expand Up @@ -40,7 +42,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='build',
name='status',
field=models.PositiveIntegerField(choices=[(10, 'Pending'), (20, 'Production'), (30, 'Cancelled'), (40, 'Complete')], default=10, help_text='Build status code', validators=[django.core.validators.MinValueValidator(0)], verbose_name='Build Status'),
field=models.PositiveIntegerField(choices=BuildStatus.items(), default=BuildStatus.PENDING.value, help_text='Build status code', validators=[django.core.validators.MinValueValidator(0)], verbose_name='Build Status'),
),
migrations.AlterField(
model_name='build',
Expand Down
7 changes: 5 additions & 2 deletions src/backend/InvenTree/build/status_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ class BuildStatus(StatusCode):
"""Build status codes."""

PENDING = 10, _('Pending'), 'secondary' # Build is pending / active
PRODUCTION = 20, _('Production'), 'primary' # BuildOrder is in production
PRODUCTION = 20, _('Production'), 'primary' # Build is in production
CANCELLED = 30, _('Cancelled'), 'danger' # Build was cancelled
COMPLETE = 40, _('Complete'), 'success' # Build is complete


class BuildStatusGroups:
"""Groups for BuildStatus codes."""

ACTIVE_CODES = [BuildStatus.PENDING.value, BuildStatus.PRODUCTION.value]
ACTIVE_CODES = [
BuildStatus.PENDING.value,
BuildStatus.PRODUCTION.value,
]
Loading

0 comments on commit 1a09ef0

Please sign in to comment.