Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/inventree/InvenTree into …
Browse files Browse the repository at this point in the history
…reduce-code-duplication
  • Loading branch information
matmair committed Aug 26, 2024
2 parents bb3a428 + 1634258 commit 92b1836
Show file tree
Hide file tree
Showing 168 changed files with 2,936 additions and 2,500 deletions.
4 changes: 2 additions & 2 deletions .github/scripts/check_js_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def check_prohibited_tags(data):
for filename in pathlib.Path(js_i18n_dir).rglob('*.js'):
print(f"Checking file 'translated/{os.path.basename(filename)}':")

with open(filename, 'r') as js_file:
with open(filename, encoding='utf-8') as js_file:
data = js_file.readlines()

errors += check_invalid_tag(data)
Expand All @@ -81,7 +81,7 @@ def check_prohibited_tags(data):
print(f"Checking file 'dynamic/{os.path.basename(filename)}':")

# Check that the 'dynamic' files do not contains any translated strings
with open(filename, 'r') as js_file:
with open(filename, encoding='utf-8') as js_file:
data = js_file.readlines()

invalid_tags = ['blocktrans', 'blocktranslate', 'trans', 'translate']
Expand Down
4 changes: 2 additions & 2 deletions .github/scripts/check_migration_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
if len(migrations) == 0:
sys.exit(0)

print('There are {n} unstaged migration files:'.format(n=len(migrations)))
print(f'There are {len(migrations)} unstaged migration files:')

for m in migrations:
print(' - {m}'.format(m=m))
print(f' - {m}')

sys.exit(len(migrations))
11 changes: 4 additions & 7 deletions .github/scripts/version_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def check_version_number(version_string, allow_duplicate=False):

if release > version_tuple:
highest_release = False
print(f'Found newer release: {str(release)}')
print(f'Found newer release: {release!s}')

return highest_release

Expand Down Expand Up @@ -134,7 +134,7 @@ def check_version_number(version_string, allow_duplicate=False):

version = None

with open(version_file, 'r') as f:
with open(version_file, encoding='utf-8') as f:
text = f.read()

# Extract the InvenTree software version
Expand Down Expand Up @@ -175,10 +175,7 @@ def check_version_number(version_string, allow_duplicate=False):
print(f"Version number '{version}' does not match tag '{version_tag}'")
sys.exit

if highest_release:
docker_tags = [version_tag, 'stable']
else:
docker_tags = [version_tag]
docker_tags = [version_tag, 'stable'] if highest_release else [version_tag]

elif GITHUB_REF_TYPE == 'branch':
# Otherwise we know we are targeting the 'master' branch
Expand All @@ -202,7 +199,7 @@ def check_version_number(version_string, allow_duplicate=False):
target_repos = [REPO.lower(), f'ghcr.io/{REPO.lower()}']

# 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:
with open(os.getenv('GITHUB_ENV'), 'a', encoding='utf-8') as env_file:
# Construct tag string
tag_list = [[f'{r}:{t}' for t in docker_tags] for r in target_repos]
tags = ','.join(itertools.chain(*tag_list))
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@883d8588e56d1753a8a58c1c86e88976f0c23449 # v3.26.3
uses: github/codeql-action/upload-sarif@2c779ab0d087cd7fe7b826087247c2c81f27bfa6 # v3.26.5
with:
sarif_file: results.sarif
34 changes: 24 additions & 10 deletions .github/workflows/translations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ permissions:
contents: read

jobs:
build:
synchronize-with-crowdin:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -39,16 +40,29 @@ jobs:
apt-dependency: gettext
- name: Make Translations
run: invoke translate
- name: Commit files
- name: Remove compiled static files
run: rm -rf src/backend/InvenTree/static
- name: Remove all local changes that are not *.po files
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git checkout -b l10_local
git add "*.po"
git commit -m "updated translation base"
- name: Push changes
uses: ad-m/github-push-action@d91a481090679876dfc4178fef17f286781251df # [email protected]
git add src/backend/InvenTree/locale/en/LC_MESSAGES/django.po src/frontend/src/locales/en/messages.po
git commit -m "add translations"
git reset --hard
git reset HEAD~
- name: crowdin action
uses: crowdin/github-action@6ed209d411599a981ccb978df3be9dc9b8a81699 # pin@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: l10
force: true
upload_sources: true
upload_translations: false
download_translations: true
localization_branch_name: l10_crowdin
create_pull_request: true
pull_request_title: 'New Crowdin updates'
pull_request_body: 'New Crowdin translations by [Crowdin GH Action](https://github.com/crowdin/github-action)'
pull_request_base_branch_name: 'l10'
pull_request_labels: 'translations'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ repos:
- id: check-yaml
- id: mixed-line-ending
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.1
rev: v0.6.1
hooks:
- id: ruff-format
args: [--preview]
- id: ruff
args: [
--fix,
# --unsafe-fixes,
--preview
]
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.2.13
rev: 0.2.37
hooks:
- id: pip-compile
name: pip-compile requirements-dev.in
Expand Down Expand Up @@ -77,7 +78,7 @@ repos:
- "prettier@^2.4.1"
- "@trivago/prettier-plugin-sort-imports"
- repo: https://github.com/pre-commit/mirrors-eslint
rev: "v9.6.0"
rev: "v9.9.0"
hooks:
- id: eslint
additional_dependencies:
Expand Down
1 change: 1 addition & 0 deletions contrib/container/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ gunicorn>=22.0.0
# LDAP required packages
django-auth-ldap # Django integration for ldap auth
python-ldap # LDAP auth support
django<5.0 # Force lower to match main project

# Upgraded python package installer
uv
Loading

0 comments on commit 92b1836

Please sign in to comment.