-
Notifications
You must be signed in to change notification settings - Fork 48
Adding SDK Recursive Build Tool #15
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
Closed
Closed
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d3ac087
Added install_necto.py and recursive_build.py scripts for recursiveBu…
IvanRuzavin fa6d5b8
Added an action to be triggered on each PR to main branch
IvanRuzavin 7d70268
Changed main branch name to master branch
IvanRuzavin b894b5f
Fixed SQL query that caused the runtime error
IvanRuzavin c00b5d6
Added NECTO download url to secrets
IvanRuzavin cfd2bfc
Updated SQL queries for MCUs and MCU cards
IvanRuzavin 3636f97
Added SDK support to MCU query for Build All
IvanRuzavin 51cea55
Added workaround for not building ALL
IvanRuzavin 03585a0
Merge remote-tracking branch 'origin/master' into topic/sdk-build-aut…
IvanRuzavin b0eb7ae
Added packages to the Necto installer command
IvanRuzavin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: SDK Recursive Build | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
build_type: | ||
type: choice | ||
description: Build all or only changed files | ||
options: | ||
- Only changed files | ||
- All files | ||
necto_type: | ||
type: choice | ||
description: Live or Development NECTO build | ||
options: | ||
- Development | ||
- Live | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
recursiveBuild: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install aiohttp | ||
pip install aiofiles | ||
pip install requests | ||
pip install py7zr | ||
pip install elasticsearch==7.13.4 | ||
sudo apt-get update | ||
sudo apt-get install p7zip-full | ||
sudo apt-get install libopus-dev | ||
sudo apt-get install libevent-dev | ||
sudo apt-get install freeglut3-dev | ||
sudo apt-get install libminizip-dev | ||
sudo apt-get install libxcb-shape0-dev | ||
sudo apt-get install libxcb-icccm4-dev | ||
sudo apt-get install libxcb-cursor-dev | ||
sudo apt-get install libxcb-keysyms1-dev | ||
sudo apt-get install libxkbcommon-x11-dev | ||
|
||
- name: Install NECTO | ||
run: | | ||
if [[ "${{ github.event.inputs.necto_type }}" == 'Live' ]]; then | ||
export NECTO_DOWNLOAD_URL=${{ secrets.NECTO_LIVE_DOWNLOAD_URL }} | ||
else | ||
export NECTO_DOWNLOAD_URL=${{ secrets.NECTO_DEV_DOWNLOAD_URL }} | ||
fi | ||
python -u scripts/install_necto.py | ||
|
||
- name: Run Recursive Build | ||
run: | | ||
if [[ "${{ github.event.inputs.build_type }}" == 'All files' ]]; then | ||
export BUILD_ALL=1 | ||
echo "Building all files." | ||
else | ||
export BUILD_ALL=0 | ||
echo "Building only changed files." | ||
fi | ||
python -u scripts/recursive_build.py | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the option to skip the build entirely. Maybe a script parameter which checks a commit message variable or branch name. |
||
|
||
- name: Archive test results | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: test-results | ||
path: /home/runner/test_results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import os | ||
import shutil | ||
import subprocess | ||
import urllib.request | ||
|
||
# Runs a shell command and prints the output. | ||
def run_command(command): | ||
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) | ||
for line in process.stdout: | ||
print(line.strip()) | ||
process.wait() | ||
return process.returncode | ||
|
||
def main(): | ||
original_working_dir = os.getcwd() | ||
print(f"Original working directory: {original_working_dir}") | ||
|
||
os.chdir('/home/runner/') | ||
print(f"Script executed from: {os.getcwd()}") | ||
print("Current folder contents") | ||
for file in os.listdir(os.getcwd()): | ||
print(file) | ||
|
||
url = os.getenv('NECTO_DOWNLOAD_URL') | ||
if 'live' in url: | ||
print("Step 1: Downloading Live NECTOStudio version") | ||
else: | ||
print("Step 1: Downloading Development NECTOStudio version") | ||
urllib.request.urlretrieve(url, "NECTOInstaller.zip") | ||
|
||
print("Step 2: Extract installer") | ||
run_command("7za x NECTOInstaller.zip") | ||
|
||
print("Step 3: Install NECTO") | ||
run_command("./NECTOInstaller installer --install-packages necto_installer necto_application database /home/runner/MikroElektronika /home/runner/.MIKROE/NECTOStudio7") | ||
|
||
print("Step 4: Move installer to MIKROE if it's generated in root") | ||
if os.path.isfile("/home/runner/MikroElektronika/installer_tmp"): | ||
shutil.move("/home/runner/MikroElektronika/installer_tmp", "/home/runner/MikroElektronika/installer") | ||
|
||
print("Step 5: Move instance_uuid.txt to MIKROE if it's generated in root") | ||
if os.path.isfile("/home/runner/instance_uuid.txt"): | ||
shutil.move("/home/runner/instance_uuid.txt", "/home/runner/MikroElektronika/instance_uuid.txt") | ||
|
||
print("Step 6: Read hash from instance_uuid.txt") | ||
with open("/home/runner/MikroElektronika/instance_uuid.txt", "r") as f: | ||
line = f.readline().strip() | ||
|
||
print("Step 7: Copy NECTOStudio.conf to current directory") | ||
shutil.copy("/home/runner/.config/MikroElektronika/NECTOStudio.conf", "/home/runner/NECTOStudio.conf") | ||
|
||
print("Step 8: Add the read hash to it") | ||
with open("/home/runner/NECTOStudio.conf", "r+") as f: | ||
content = f.read() | ||
f.seek(0, 0) | ||
f.write(f"[{line}]\n" + content) | ||
|
||
print("Step 9: Copy it back to .config/MikroElektronika") | ||
shutil.copy("/home/runner/NECTOStudio.conf", "/home/runner/.config/MikroElektronika/NECTOStudio.conf") | ||
|
||
print("Step 10: Move installed_packages.json to MIKROE if it's generated in root") | ||
if os.path.isfile("/home/runner/installed_packages.json"): | ||
shutil.move("/home/runner/installed_packages.json", "/home/runner/MikroElektronika/installed_packages.json") | ||
|
||
print("Step 11: Remove NECTOInstaller.zip") | ||
os.remove("/home/runner/NECTOInstaller.zip") | ||
|
||
print("Step 12: Remove NECTOInstaller") | ||
os.remove("/home/runner/NECTOInstaller") | ||
|
||
print("Step 13: Remove NECTOStudio.conf") | ||
os.remove("/home/runner/NECTOStudio.conf") | ||
|
||
print("Current folder contents") | ||
for file in os.listdir(os.getcwd()): | ||
print(file) | ||
|
||
os.chdir(original_working_dir) | ||
print(f"Returned to original working directory: {os.getcwd()}") | ||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the workflow so that NECTO is installed after checking for changed files.
In other words install it only if there is a need to run the automated builds.
I assume you will need to split the
recursive_build
into two scripts.