Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement/trigger db update #19

Merged
merged 4 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,19 @@ jobs:
echo "Indexing to Test."
python -u scripts/index.py ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }} ${{ github.event.inputs.release_version }} ${{ secrets.ES_INDEX_TEST }}
fi

- name: Trigger database update in Core repo
run: |
# Set the required variables
repo_owner="MikroElektronika"
repo_name="core_packages"
event_type="trigger-workflow"
version="${{ github.event.inputs.release_version }}"

curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$repo_owner/$repo_name/dispatches \
-d "{\"event_type\": \"$event_type\", \"client_payload\": {\"version\": \"$version\", \"unit\": false, \"integration\": true}}"
File renamed without changes
9 changes: 9 additions & 0 deletions resources/queries/boards/board_test_1/BoardToDevice.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"board_uid": "UNI_CLICKER",
"device_uid": {
"regexes": [
"CARD",
"SIBRAIN"
]
}
}
7 changes: 7 additions & 0 deletions resources/queries/boards/board_test_1/BoardToDevice.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- ? is expected to be a device_uid
INSERT INTO BoardToDevice (
board_uid,device_uid
)
VALUES (
"UNI_CLICKER",?
);
6 changes: 6 additions & 0 deletions resources/queries/boards/board_test_1/BoardToSocket.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"board_uid": "UNI_CLICKER",
"socket_uid": [
"SIBRAIN_SOCKET"
]
}
7 changes: 7 additions & 0 deletions resources/queries/boards/board_test_1/BoardToSocket.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- ? is expected to be a socket_uid
INSERT INTO BoardToSocket (
board_uid,socket_uid
)
VALUES (
"UNI_CLICKER",?
);
16 changes: 16 additions & 0 deletions resources/queries/boards/board_test_1/Boards.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"uid": "UNI_CLICKER",
"name": "UNI Clicker",
"icon": "images/boards/clicker-uni.png",
"default_device": "NULL",
"soldered_device": "NULL",
"category": "Supporting tools",
"mikrobus_count": 4,
"sort_order": 8,
"min_pin_count": 0,
"display_socket": "NO_DISPLAY",
"sdk_config": "{\"_MSDK_BOARD_NAME_\":\"UNI_CLICKER\", \"HAS_MIKROBUS\":\"true\"}",
"necto_config": "NULL",
"display": "NO_DISPLAY",
"package_uid": "NULL"
}
12 changes: 12 additions & 0 deletions resources/queries/boards/board_test_1/Boards.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
INSERT INTO Boards (
uid,name,icon,default_device,soldered_device,
category,mikrobus_count,sort_order,min_pin_count,display_socket,
sdk_config,
necto_config,display,package_uid
)
VALUES (
"UNI_CLICKER","UNI Clicker","images/boards/clicker-uni.png",NULL,NULL,
"Supporting tools",4,8,0,"NO_DISPLAY",
'{"_MSDK_BOARD_NAME_":"UNI_CLICKER","HAS_MIKROBUS":"true"}',
NULL,"NO_DISPLAY",NULL
);
4 changes: 4 additions & 0 deletions resources/queries/boards/board_test_1/SDKToBoard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"sdk_uid": "2.11.1+",
"board_uid": "UNI_CLICKER"
}
6 changes: 6 additions & 0 deletions resources/queries/boards/board_test_1/SDKToBoard.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
INSERT INTO SDKToBoard (
sdk_uid,board_uid
)
VALUES (
"mikrosdk_v${MIKROSDK_CURRENT_VERSION}","UNI_CLICKER"
);
19 changes: 19 additions & 0 deletions resources/queries/cards/card_test_1/Devices.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
INSERT INTO Devices (
def_file,family_uid,flash,
icon,
max_speed,name,ram,sdk_config,
necto_config,uid,vendor,compiler_flags,
linker_flags,tft_socket,sdk_support
)
VALUES (
"STM32F746VG.json","STM32","1024",
"images/mcu_cards/card-v7-easymx-pro-v7-stm32-stm32f746vgt6.png",
"216.000",
"EasyMx PRO v7 for STM32 MCUcard with STM32F746VGT6",
"327680",
'{"MCU_NAME":"STM32F746VG","CORE_NAME":"M7","_MSDK_HAL_LOW_LEVEL_TARGET_":"mikroe","_MSDK_ETH_PHY_CHIP_":"&lan8720PhyDriver","_MSDK_MCU_CARD_NAME_":"EASYMX_PRO_V7_FOR_STM32_MCUCARD_WITH_STM32F746VGT6"}',
NULL,
"EASYMX_PRO_V7_FOR_STM32_MCUCARD_WITH_STM32F746VGT6",
"STMicroelectronics",
NULL,NULL,1,1,NULL
);
21 changes: 16 additions & 5 deletions scripts/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def create_7z_archive(version, source_folder, archive_path):
"""Create a .7z archive from a source folder with a specific folder structure, excluding the .github folder."""
with py7zr.SevenZipFile(archive_path, 'w') as archive:
for root, dirs, files in os.walk(source_folder):
if re.search(r'(\.git)|(scripts)|(templates)|(changelog)|(images)', os.path.relpath(root, source_folder)):
if re.search(r'(\.git)|(scripts)|(templates)|(changelog)|(resources)', os.path.relpath(root, source_folder)):
continue
for file in files:
file_path = os.path.join(root, file)
Expand All @@ -29,7 +29,6 @@ def create_custom_archive(source_folder, archive_path):
with py7zr.SevenZipFile(archive_path, 'w') as archive:
os.chdir(source_folder)
archive.writeall('./')
os.chdir('..')

def upload_asset_to_release(repo, release_id, asset_path, token):
"""Upload an asset to a specific GitHub release."""
Expand Down Expand Up @@ -71,6 +70,7 @@ def zip_bsp_related_files(archive_path, repo_dir):
]
)
create_custom_archive('output', archive_path)
os.chdir(repo_dir)

def hash_file(filename):
"""Generate MD5 hash of a file."""
Expand Down Expand Up @@ -126,11 +126,12 @@ def hash_directory_contents(directory):
upload_result = upload_asset_to_release(args.repo, release_id, archive_path, args.token)
print('Asset "%s" uploaded successfully to release ID: %s' % ('mikrosdk', release_id))

if os.path.exists(os.path.join(repo_dir, 'images')):
if os.path.exists(os.path.join(repo_dir, 'resources/images')):
archive_path = os.path.join(repo_dir, 'images.7z')
print('Creating archive: %s' % archive_path)
create_custom_archive('images', archive_path)
metadata_content['images'] = {'hash': hash_directory_contents(os.path.join(repo_dir, 'images'))}
create_custom_archive('resources/images', archive_path)
os.chdir(repo_dir)
metadata_content['images'] = {'hash': hash_directory_contents(os.path.join(repo_dir, 'resources/images'))}
print('Archive created successfully: %s' % archive_path)
upload_result = upload_asset_to_release(args.repo, release_id, archive_path, args.token)
print('Asset "%s" uploaded successfully to release ID: %s' % ('images', release_id))
Expand All @@ -139,11 +140,21 @@ def hash_directory_contents(directory):
archive_path = os.path.join(repo_dir, 'templates.7z')
print('Creating archive: %s' % archive_path)
create_custom_archive('templates/necto', archive_path)
os.chdir(repo_dir)
metadata_content['templates'] = {'hash': hash_directory_contents(os.path.join(repo_dir, 'templates/necto'))}
print('Archive created successfully: %s' % archive_path)
upload_result = upload_asset_to_release(args.repo, release_id, archive_path, args.token)
print('Asset "%s" uploaded successfully to release ID: %s' % ('templates', release_id))

if os.path.exists(os.path.join(repo_dir, 'resources/queries')):
archive_path = os.path.join(repo_dir, 'queries.7z')
print('Creating archive: %s' % archive_path)
create_custom_archive('resources/queries', archive_path)
os.chdir(repo_dir)
print('Archive created successfully: %s' % archive_path)
upload_result = upload_asset_to_release(args.repo, release_id, archive_path, args.token)
print('Asset "%s" uploaded successfully to release ID: %s' % ('queries', release_id))

# BSP asset
archive_path = os.path.join(repo_dir, 'bsps.7z')
print('Creating archive: %s' % archive_path)
Expand Down
Loading