forked from tbnobody/OpenDTU
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into jbd-bms-support
- Loading branch information
Showing
15 changed files
with
74 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -7,4 +7,5 @@ | |
platformio-device-monitor*.log | ||
logs/device-monitor*.log | ||
platformio_override.ini | ||
webapp_dist/ | ||
.DS_Store |
This file contains 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
This file contains 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
This file contains 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,65 @@ | ||
import os | ||
import hashlib | ||
import pickle | ||
import subprocess | ||
|
||
def check_files(directories, filepaths, hash_file): | ||
old_file_hashes = {} | ||
file_hashes = {} | ||
|
||
for directory in directories: | ||
for root, dirs, filenames in os.walk(directory): | ||
for file in filenames: | ||
filepaths.append(os.path.join(root, file)) | ||
|
||
for file_path in filepaths: | ||
with open(file_path, 'rb') as f: | ||
file_data = f.read() | ||
file_hashes[file_path] = hashlib.md5(file_data).hexdigest() | ||
|
||
if os.path.exists(hash_file): | ||
with open(hash_file, 'rb') as f: | ||
old_file_hashes = pickle.load(f) | ||
|
||
update = False | ||
for file_path, file_hash in file_hashes.items(): | ||
if file_path not in old_file_hashes or old_file_hashes[file_path] != file_hash: | ||
update = True | ||
break | ||
|
||
if not update: | ||
print("webapp artifacts should be up-to-date") | ||
return | ||
|
||
print("compiling webapp (hang on, this can take a while and there might be little output)...") | ||
|
||
try: | ||
# if these commands fail, an exception will prevent us from | ||
# persisting the current hashes => commands will be executed again | ||
subprocess.run(["yarn", "--cwd", "webapp", "install", "--frozen-lockfile"], | ||
check=True) | ||
|
||
subprocess.run(["yarn", "--cwd", "webapp", "build"], check=True) | ||
|
||
except FileNotFoundError: | ||
raise Exception("it seems 'yarn' is not installed/available on your system") | ||
|
||
with open(hash_file, 'wb') as f: | ||
pickle.dump(file_hashes, f) | ||
|
||
def main(): | ||
if os.getenv('GITHUB_ACTIONS') == 'true': | ||
print("INFO: not testing for up-to-date webapp artifacts when running as Github action") | ||
return 0 | ||
|
||
print("INFO: testing for up-to-date webapp artifacts") | ||
|
||
directories = ["webapp/src/", "webapp/public/"] | ||
files = ["webapp/index.html", "webapp/tsconfig.config.json", | ||
"webapp/tsconfig.json", "webapp/vite.config.ts", | ||
"webapp/yarn.lock"] | ||
hash_file = "webapp_dist/.hashes.pkl" | ||
|
||
check_files(directories, files, hash_file) | ||
|
||
main() |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.