Skip to content

Commit

Permalink
Merge branch 'main' of github.com:demergent-labs/azle into chunk_prop…
Browse files Browse the repository at this point in the history
…erty_tests
  • Loading branch information
lastmjs committed Aug 16, 2024
2 parents fad575a + 0e1c241 commit 28344f7
Show file tree
Hide file tree
Showing 59 changed files with 148,647 additions and 688 deletions.
56 changes: 42 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions global_dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
wasi2ic version: wasi2ic v0.2.0 (https://github.com/wasm-forge/wasi2ic?rev=806c3558aad24224852a9582f018178402cb3679#806c3558):
wasi2ic

node version: v20.11.0

rustc version: rustc 1.76.0 (07dca489a 2024-02-04)
20 changes: 20 additions & 0 deletions scripts/delete_git_branches.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# List of branches to delete
branches=(
"my_branch1"
"my_branch2"
)

# Function to delete branches locally and on GitHub
delete_branch() {
local branch=$1

git branch -d "$branch"
git push --delete origin "$branch"
}

# Iterate over the branches and delete them
for branch in "${branches[@]}"; do
delete_branch "$branch"
done
2 changes: 1 addition & 1 deletion scripts/file_generator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function fillFileWithRandomBytes(
for (let i = 0; i < totalChunks; i++) {
const remainingBytes = sizeInBytes - i * defaultChunkSize;
const chunkSize = Math.min(remainingBytes, defaultChunkSize);
const randomBytes = await createRandomBytes(chunkSize);
const randomBytes = createRandomBytes(chunkSize);
await appendFile(path, randomBytes);
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/jest_isolate_modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ fs.writeFile(jestConfigPath, newJestConfigContent, 'utf8', (err) => {
return;
}

console.log('jest.config.js successfully overwritten.');
console.info('jest.config.js successfully overwritten.');
});
2 changes: 1 addition & 1 deletion src/compiler/file_uploader/incomplete_files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function hasValidHash(
actor: UploaderActor
): Promise<boolean> {
try {
const hashOption = await actor.get_file_hash(path);
const hashOption = await actor._azle_get_file_hash(path);
return hashOption.length === 1;
} catch {
return false;
Expand Down
7 changes: 5 additions & 2 deletions src/compiler/file_uploader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export async function uploadFiles(
canisterName: string,
paths: [Src, Dest][]
): Promise<void> {
if (paths.length === 0) {
if (
paths.length === 0 ||
process.env.AZLE_DISABLE_AUTO_FILE_UPLOAD === 'true'
) {
return;
}

Expand All @@ -30,7 +33,7 @@ export async function uploadFiles(
}

console.info(
'Finished uploading files. Waiting for file hashing to finish...'
'Finished uploading files. Waiting for all chunks to finish uploading...' // TODO remove after https://github.com/demergent-labs/azle/issues/1996 is complete
);

onBeforeExit(expandedPaths, actor);
Expand Down
29 changes: 5 additions & 24 deletions src/compiler/file_uploader/on_before_exit.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { Dest, Src } from '.';
import { getListOfIncompleteFiles } from './incomplete_files';
import { getOngoingHashingJobs, OngoingHashingJob } from './ongoing_hashes';
import { UploaderActor } from './uploader_actor';

export function onBeforeExit(paths: [Src, Dest][], actor: UploaderActor): void {
let hashingComplete = false;
let cleanUpComplete = false;
let ongoingHashingJobs: OngoingHashingJob[] = [];

process.on('beforeExit', async () => {
if (cleanUpComplete) {
Expand All @@ -17,26 +14,10 @@ export function onBeforeExit(paths: [Src, Dest][], actor: UploaderActor): void {
return;
}

if (hashingComplete) {
await cleanup(paths, actor);
cleanUpComplete = true;
return;
}

ongoingHashingJobs = await getOngoingHashingJobs(
paths,
ongoingHashingJobs,
actor
);

hashingComplete = ongoingHashingJobs.length === 0;

if (!hashingComplete) {
console.info(
`Waiting 5 seconds before checking hashing status again...`
);
await new Promise((resolve) => setTimeout(resolve, 5000));
}
console.info('Cleaning up incomplete files');
await cleanup(paths, actor);
cleanUpComplete = true;
return;
});
}

Expand All @@ -46,6 +27,6 @@ async function cleanup(
): Promise<void> {
const incompleteFiles = await getListOfIncompleteFiles(paths, actor);
for (const [_, path] of incompleteFiles) {
await actor.clear_file_and_info(path);
await actor._azle_clear_file_and_info(path);
}
}
Loading

0 comments on commit 28344f7

Please sign in to comment.