Skip to content

Commit

Permalink
fix: errors related to windows/linux
Browse files Browse the repository at this point in the history
  • Loading branch information
ermineJose committed Nov 5, 2024
1 parent 8e81595 commit 365ff32
Showing 1 changed file with 66 additions and 74 deletions.
140 changes: 66 additions & 74 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -351,26 +351,23 @@ jobs:
timeout-minutes: 2

- name: Estimate cost to create a vault
if: matrix.os != 'windows-latest'
run: |
echo "test-file" > upload-test.txt
./target/release/autonomi --log-output-dest=data-dir file upload ./upload-test.txt
# 1 MB
python3 -c "with open('random.txt', 'wb') as f: f.write(bytearray([0xff] * 1 * 1024 * 1024))"
./target/release/autonomi --log-output-dest=data-dir file upload random.txt
./target/release/autonomi --log-output-dest=data-dir register create sample_new_register 1234
./target/release/autonomi --log-output-dest=data-dir vault cost
./target/release/autonomi --log-output-dest=data-dir file list 2>&1 | tee file_list.txt
./target/release/autonomi --log-output-dest=data-dir register list 2>&1 | tee register_list.txt
env:
SN_LOG: "v"
timeout-minutes: 2

- name: create a vault with existing user data as above
if: matrix.os != 'windows-latest'
run: ./target/release/autonomi --log-output-dest=data-dir vault create
env:
SN_LOG: "v"
timeout-minutes: 2

- name: add more files
- name: add more files - linux/macos
if: matrix.os != 'windows-latest'
run: |
for i in {1..100}; do
Expand All @@ -383,18 +380,13 @@ jobs:
SN_LOG: "v"
timeout-minutes: 25

- name: add more files
- name: add more files - windows
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
for ($i = 1; $i -le 100; $i++) {
# Generate a random file with PowerShell
$randomData = [System.IO.File]::OpenWrite("random_file_$i.bin")
$buffer = New-Object byte[](1024 * 1024) # 1MB buffer
[System.Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($buffer)
$randomData.Write($buffer, 0, $buffer.Length)
$randomData.Close()
python3 -c "import sys; with open(sys.argv[1], 'wb') as f: f.write(bytearray([0xff] * 1 * 1024 * 1024))" "random_file_$i.bin"
# Run autonomi commands
./target/release/autonomi --log-output-dest=data-dir file upload "random_file_$i.bin" --public
./target/release/autonomi --log-output-dest=data-dir file upload "random_file_$i.bin"
Expand Down Expand Up @@ -451,66 +443,66 @@ jobs:
SN_LOG: "v"
timeout-minutes: 15

- name: Set up variables - vault sync
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
# Initialize variables to empty
$NUM_OF_PUBLIC_FILES = ""
$NUM_OF_PRIVATE_FILES = ""
$NUM_OF_REGISTERS = ""
$NUM_OF_PUBLIC_FILES_IN_VAULT = ""
$NUM_OF_PRIVATE_FILES_IN_VAULT = ""
$NUM_OF_REGISTERS_IN_VAULT = ""
# Execute commands and save outputs to files
./target/release/autonomi --log-output-dest=data-dir file list > file_list.txt 2>&1
./target/release/autonomi register list | Select-String "register" > register_list.txt
./target/release/autonomi --log-output-dest=data-dir vault load > vault_data.txt 2>&1
# Parse the files and extract numbers
$NUM_OF_PUBLIC_FILES = (Select-String "public" file_list.txt | ForEach-Object { $_ -match "\d+"; $matches[0] })[0]
$NUM_OF_PRIVATE_FILES = (Select-String "private" file_list.txt | ForEach-Object { $_ -match "\d+"; $matches[0] })[0]
$NUM_OF_REGISTERS = (Select-String "register" register_list.txt | ForEach-Object { $_ -match "\d+"; $matches[0] })[0]
# Get the first word only (PowerShell handles this without additional parsing)
$NUM_OF_REGISTERS_first = $NUM_OF_REGISTERS -split '\s+' | Select-Object -First 1
Write-Output "NUM_OF_REGISTERS is $NUM_OF_REGISTERS_first"
# Continue with vault data parsing
$NUM_OF_PUBLIC_FILES_IN_VAULT = (Select-String "public" vault_data.txt | ForEach-Object { $_ -match "\d+"; $matches[0] })[0]
$NUM_OF_PRIVATE_FILES_IN_VAULT = (Select-String "private" vault_data.txt | ForEach-Object { $_ -match "\d+"; $matches[0] })[0]
$NUM_OF_REGISTERS_IN_VAULT = (Select-String "register" vault_data.txt | ForEach-Object { $_ -match "\d+"; $matches[0] })[0]
# Output summary
Write-Output "Total Num of local public files is $NUM_OF_PUBLIC_FILES and in vault is $NUM_OF_PUBLIC_FILES_IN_VAULT"
Write-Output "Total Num of local private files is $NUM_OF_PRIVATE_FILES and in vault is $NUM_OF_PRIVATE_FILES_IN_VAULT"
Write-Output "Total Num of local registers is $NUM_OF_REGISTERS_first and in vault is $NUM_OF_REGISTERS_IN_VAULT"
# Clean up temporary files
Remove-Item -Force file_list.txt, register_list.txt, vault_data.txt
- name: Vault sync validation
if: matrix.os == 'windows-latest'
shell: python
run: |
import sys
# Define the values as environment variables
NUM_OF_PUBLIC_FILES = int("$env:NUM_OF_PUBLIC_FILES")
NUM_OF_PUBLIC_FILES_IN_VAULT = int("$env:NUM_OF_PUBLIC_FILES_IN_VAULT")
NUM_OF_PRIVATE_FILES = int("$env:NUM_OF_PRIVATE_FILES")
NUM_OF_PRIVATE_FILES_IN_VAULT = int("$env:NUM_OF_PRIVATE_FILES_IN_VAULT")
NUM_OF_REGISTERS_FIRST = int("$env:NUM_OF_REGISTERS_first")
NUM_OF_REGISTERS_IN_VAULT = int("$env:NUM_OF_REGISTERS_IN_VAULT")
# Assertions
assert NUM_OF_PUBLIC_FILES == NUM_OF_PUBLIC_FILES_IN_VAULT, f"Error: Local public Files: {NUM_OF_PUBLIC_FILES} and vault public files: {NUM_OF_PUBLIC_FILES_IN_VAULT} are Not Equal"
assert NUM_OF_PRIVATE_FILES == NUM_OF_PRIVATE_FILES_IN_VAULT, f"Error: Local private Files: {NUM_OF_PRIVATE_FILES} and vault private files: {NUM_OF_PRIVATE_FILES_IN_VAULT} are Not Equal"
assert NUM_OF_REGISTERS_FIRST == NUM_OF_REGISTERS_IN_VAULT, f"Error: Local registers: {NUM_OF_REGISTERS_FIRST} and vault registers: {NUM_OF_REGISTERS_IN_VAULT} are Not Equal"
print("Vault synced successfully!")
# - name: Set up variables - vault sync - windows
# if: matrix.os == 'windows-latest'
# shell: pwsh
# run: |
# # Initialize variables to empty
# $NUM_OF_PUBLIC_FILES = ""
# $NUM_OF_PRIVATE_FILES = ""
# $NUM_OF_REGISTERS = ""
# $NUM_OF_PUBLIC_FILES_IN_VAULT = ""
# $NUM_OF_PRIVATE_FILES_IN_VAULT = ""
# $NUM_OF_REGISTERS_IN_VAULT = ""

# # Execute commands and save outputs to files
# ./target/release/autonomi --log-output-dest=data-dir file list > file_list.txt 2>&1
# ./target/release/autonomi register list | Select-String "register" > register_list.txt
# ./target/release/autonomi --log-output-dest=data-dir vault load > vault_data.txt 2>&1

# # Parse the files and extract numbers
# $NUM_OF_PUBLIC_FILES = (Select-String "public" file_list.txt | ForEach-Object { $_ -match "\d+"; $matches[0] })[0]
# $NUM_OF_PRIVATE_FILES = (Select-String "private" file_list.txt | ForEach-Object { $_ -match "\d+"; $matches[0] })[0]
# $NUM_OF_REGISTERS = (Select-String "register" register_list.txt | ForEach-Object { $_ -match "\d+"; $matches[0] })[0]

# # Get the first word only (PowerShell handles this without additional parsing)
# $NUM_OF_REGISTERS_first = $NUM_OF_REGISTERS -split '\s+' | Select-Object -First 1

# Write-Output "NUM_OF_REGISTERS is $NUM_OF_REGISTERS_first"

# # Continue with vault data parsing
# $NUM_OF_PUBLIC_FILES_IN_VAULT = (Select-String "public" vault_data.txt | ForEach-Object { $_ -match "\d+"; $matches[0] })[0]
# $NUM_OF_PRIVATE_FILES_IN_VAULT = (Select-String "private" vault_data.txt | ForEach-Object { $_ -match "\d+"; $matches[0] })[0]
# $NUM_OF_REGISTERS_IN_VAULT = (Select-String "register" vault_data.txt | ForEach-Object { $_ -match "\d+"; $matches[0] })[0]

# # Output summary
# Write-Output "Total Num of local public files is $NUM_OF_PUBLIC_FILES and in vault is $NUM_OF_PUBLIC_FILES_IN_VAULT"
# Write-Output "Total Num of local private files is $NUM_OF_PRIVATE_FILES and in vault is $NUM_OF_PRIVATE_FILES_IN_VAULT"
# Write-Output "Total Num of local registers is $NUM_OF_REGISTERS_first and in vault is $NUM_OF_REGISTERS_IN_VAULT"

# # Clean up temporary files
# Remove-Item -Force file_list.txt, register_list.txt, vault_data.txt

# - name: Vault sync validation
# if: matrix.os == 'windows-latest'
# shell: python
# run: |
# import sys

# # Define the values as environment variables
# NUM_OF_PUBLIC_FILES = int("$env:NUM_OF_PUBLIC_FILES")
# NUM_OF_PUBLIC_FILES_IN_VAULT = int("$env:NUM_OF_PUBLIC_FILES_IN_VAULT")
# NUM_OF_PRIVATE_FILES = int("$env:NUM_OF_PRIVATE_FILES")
# NUM_OF_PRIVATE_FILES_IN_VAULT = int("$env:NUM_OF_PRIVATE_FILES_IN_VAULT")
# NUM_OF_REGISTERS_FIRST = int("$env:NUM_OF_REGISTERS_first")
# NUM_OF_REGISTERS_IN_VAULT = int("$env:NUM_OF_REGISTERS_IN_VAULT")

# # Assertions
# assert NUM_OF_PUBLIC_FILES == NUM_OF_PUBLIC_FILES_IN_VAULT, f"Error: Local public Files: {NUM_OF_PUBLIC_FILES} and vault public files: {NUM_OF_PUBLIC_FILES_IN_VAULT} are Not Equal"
# assert NUM_OF_PRIVATE_FILES == NUM_OF_PRIVATE_FILES_IN_VAULT, f"Error: Local private Files: {NUM_OF_PRIVATE_FILES} and vault private files: {NUM_OF_PRIVATE_FILES_IN_VAULT} are Not Equal"
# assert NUM_OF_REGISTERS_FIRST == NUM_OF_REGISTERS_IN_VAULT, f"Error: Local registers: {NUM_OF_REGISTERS_FIRST} and vault registers: {NUM_OF_REGISTERS_IN_VAULT} are Not Equal"

# print("Vault synced successfully!")

- name: load an existing vault from the network
if: matrix.os != 'windows-latest'
Expand Down

0 comments on commit 365ff32

Please sign in to comment.