Skip to content

Commit

Permalink
pr fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Sep 19, 2024
1 parent 8bab7a9 commit dce9262
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 159 deletions.
2 changes: 1 addition & 1 deletion .github/actions/get_dfx_version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Get dfx version
description: Determines Azle's dfx version
outputs:
dfx-version:
description: Returns the version of dfx that Azle will test against and use to generate its Wasm binary template
description: Returns the version of dfx that Azle will test against and use to generate its Wasm binary templates
value: ${{ steps.get-dfx-version.outputs.dfx-version }}
runs:
using: composite
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/get_node_version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Get node version
description: Determines Azle's node version
outputs:
node-version:
description: Returns the version of node that Azle will test against and use to generate its Wasm binary template
description: Returns the version of node that Azle will test against and use to generate its Wasm binary templates
value: ${{ steps.get-node-version.outputs.node-version }}
runs:
using: composite
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
- name: Run pre-test Azle setup
run: |
# Install dfx (Note: DFX must be installed before `npm install` because the azle instalation process requires dfx)
# Install dfx (Note: DFX must be installed before `npm install` because the azle installation process requires dfx)
src/build/stable/commands/install_global_dependencies/install_dfx.sh ${{ steps.get-dfx-version.outputs.dfx-version }}
echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH
Expand Down
32 changes: 5 additions & 27 deletions src/build/stable/commands/install_global_dependencies/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import { IOType } from 'child_process';
import { readFile } from 'fs/promises';
import { join } from 'path';

import { azle } from '../../../../../package.json';
import { execSyncPretty } from '../../utils/exec_sync_pretty';
import { AZLE_PACKAGE_PATH } from '../../utils/global_paths';

type DependencyName = 'node' | 'dfx' | 'rust' | 'wasi2ic';

type Versions = {
[key in DependencyName]: string;
};

type Dependencies = {
type DependencyInstallInfo = {
[key in DependencyName]: boolean;
};

export async function runCommand(
dependenciesToInstall: Dependencies,
dependenciesToInstall: DependencyInstallInfo,
ioType: IOType
): Promise<void> {
for (const key in dependenciesToInstall) {
Expand All @@ -27,29 +22,12 @@ export async function runCommand(
}
}

async function installDependency(
dependency: DependencyName,
ioType: IOType
): Promise<void> {
function installDependency(dependency: DependencyName, ioType: IOType): void {
console.info(`Installing ${dependency}...`);
const version = (await getGlobalDependencies())[dependency];
const version = azle.globalDependencies[dependency];
const script = `install_${dependency}.sh`;
execSyncPretty(
`${AZLE_PACKAGE_PATH}/src/build/stable/commands/install_global_dependencies/${script} ${version}`,
ioType
);
}

async function getGlobalDependencies(): Promise<Versions> {
const packageJsonPath = join(AZLE_PACKAGE_PATH, 'package.json');

const packageJson = JSON.parse(await readFile(packageJsonPath, 'utf-8'));

const globalDependencies = packageJson.azle.globalDependencies;

if (globalDependencies === undefined) {
throw new Error('No globalDependencies found in package.json.');
}

return globalDependencies;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,6 @@ fi

DFX_VERSION=$1

if command -v dfx &> /dev/null; then
INSTALLED_VERSION=$(npx tsx src/build/stable/utils/versions/dfx.ts 2>&1 | tr -d '[:space:]')

echo "Installed dfx version: $INSTALLED_VERSION"
echo "Requested dfx version: $DFX_VERSION"

if [ "$INSTALLED_VERSION" = "$DFX_VERSION" ]; then
echo "dfx $DFX_VERSION is already installed. No installation needed."
exit 0
else
echo "Updating dfx from version $INSTALLED_VERSION to $DFX_VERSION"
fi
else
echo "dfx is not installed. Proceeding with installation of dfx $DFX_VERSION."
fi

# Install or update dfx using the official installation script
echo "Installing dfx version $DFX_VERSION..."
DFXVM_INIT_YES=true DFX_VERSION=$DFX_VERSION sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ else
echo "Installing Node.js version $NODE_VERSION..."
nvm install "$NODE_VERSION"
nvm use "$NODE_VERSION"
nvm alias default "$NODE_VERSION"
echo "Node.js $NODE_VERSION installation completed."
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,6 @@ fi

RUST_VERSION=$1

if command -v rustc &> /dev/null; then
INSTALLED_VERSION=$(npx tsx src/build/stable/utils/versions/rust.ts 2>&1 | tr -d '[:space:]')

echo "Installed Rust version: $INSTALLED_VERSION"
echo "Requested Rust version: $RUST_VERSION"

if [ "$INSTALLED_VERSION" = "$RUST_VERSION" ]; then
echo "Rust $RUST_VERSION is already installed. No installation needed."
exit 0
else
echo "Updating Rust from version $INSTALLED_VERSION to $RUST_VERSION"
fi
else
echo "Rust is not installed. Proceeding with installation of Rust $RUST_VERSION."
fi

# Install Rust
echo "Installing Rust version $RUST_VERSION..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "$RUST_VERSION"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@ else
WASI2IC_URL=""
fi

if command -v wasi2ic &> /dev/null; then
INSTALLED_VERSION=$(npx tsx src/build/stable/utils/versions/wasi2ic.ts 2>&1 | tr -d '[:space:]')

echo "Installed wasi2ic version: $INSTALLED_VERSION"
echo "Requested wasi2ic version: $WASI2IC_VERSION"

if [ "$INSTALLED_VERSION" = "$WASI2IC_VERSION" ]; then
echo "wasi2ic $WASI2IC_VERSION is already installed. No installation needed."
exit 0
else
echo "Updating wasi2ic from version $INSTALLED_VERSION to $WASI2IC_VERSION"
fi
else
echo "wasi2ic is not installed. Proceeding with installation."
fi

# Install or update wasi2ic
if [[ -n "$WASI2IC_URL" ]]; then
echo "Installing wasi2ic from repository $WASI2IC_URL"
Expand Down
16 changes: 8 additions & 8 deletions src/build/stable/utils/log_global_dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import { readFile, writeFile } from 'fs/promises';
import { join } from 'path';

import { AZLE_PACKAGE_PATH } from './global_paths';
import { getDfxVersionLocal } from './versions/dfx';
import { getNodeVersionLocal } from './versions/node';
import { getRustVersionLocal } from './versions/rust';
import { getWasi2icVersionLocal } from './versions/wasi2ic';
import { getLocalDfxVersion } from './versions/dfx';
import { getLocalNodeVersion } from './versions/node';
import { getLocalRustVersion } from './versions/rust';
import { getLocalWasi2icVersion } from './versions/wasi2ic';

export async function logGlobalDependencies(): Promise<void> {
const wasiVersion = getWasi2icVersionLocal();
const nodeVersion = getNodeVersionLocal();
const rustVersion = getRustVersionLocal();
const dfxVersion = getDfxVersionLocal();
const wasiVersion = getLocalWasi2icVersion();
const nodeVersion = getLocalNodeVersion();
const rustVersion = getLocalRustVersion();
const dfxVersion = getLocalDfxVersion();

const globalDependencies = {
wasi2ic: wasiVersion,
Expand Down
23 changes: 1 addition & 22 deletions src/build/stable/utils/versions/dfx.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { pathToFileURL } from 'url';

import { execSyncPretty } from '../exec_sync_pretty';
import { getVersionFromPackageJson } from './get_version_from_package_json';

export function getDfxVersionLocal(): string {
export function getLocalDfxVersion(): string {
const dfxOutput = execSyncPretty('dfx --version').toString().trim();

const match = dfxOutput.match(/dfx (\d+\.\d+\.\d+)/);
Expand All @@ -14,21 +11,3 @@ export function getDfxVersionLocal(): string {
throw new Error('Could not parse the dfx version');
}
}

export async function getDfxVersionPackageJson(): Promise<string> {
return await getVersionFromPackageJson('dfx');
}

async function main(): Promise<void> {
const args = process.argv.slice(2);

if (args.includes('--local')) {
process.stdout.write(getDfxVersionLocal());
} else {
process.stdout.write(await getDfxVersionPackageJson());
}
}

if (import.meta.url === pathToFileURL(process.argv[1]).href) {
main();
}
18 changes: 0 additions & 18 deletions src/build/stable/utils/versions/get_version_from_package_json.ts

This file was deleted.

12 changes: 1 addition & 11 deletions src/build/stable/utils/versions/node.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { pathToFileURL } from 'url';

import { execSyncPretty } from '../exec_sync_pretty';

export function getNodeVersionLocal(): string {
export function getLocalNodeVersion(): string {
const nodeOutput = execSyncPretty('node --version').toString().trim();
const match = nodeOutput.match(/^v(\d+\.\d+\.\d+)/);

Expand All @@ -12,11 +10,3 @@ export function getNodeVersionLocal(): string {
throw new Error('Could not parse node version');
}
}

function main(): void {
process.stdout.write(getNodeVersionLocal());
}

if (import.meta.url === pathToFileURL(process.argv[1]).href) {
main();
}
12 changes: 1 addition & 11 deletions src/build/stable/utils/versions/rust.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { pathToFileURL } from 'url';

import { execSyncPretty } from '../exec_sync_pretty';

export function getRustVersionLocal(): string {
export function getLocalRustVersion(): string {
const rustcOutput = execSyncPretty('rustc --version').toString().trim();
const match = rustcOutput.match(/^rustc\s+(\d+\.\d+\.\d+)/);

Expand All @@ -12,11 +10,3 @@ export function getRustVersionLocal(): string {
throw new Error('Could not parse rustc version');
}
}

function main(): void {
process.stdout.write(getRustVersionLocal());
}

if (import.meta.url === pathToFileURL(process.argv[1]).href) {
main();
}
12 changes: 1 addition & 11 deletions src/build/stable/utils/versions/wasi2ic.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { pathToFileURL } from 'url';

import { execSyncPretty } from '../exec_sync_pretty';

export function getWasi2icVersionLocal(): string {
export function getLocalWasi2icVersion(): string {
return getCargoVersion('wasi2ic');
}

Expand All @@ -25,11 +23,3 @@ function getCargoVersion(packageName: string): string {
throw new Error(`Could not parse ${packageName} version`);
}
}

function main(): void {
process.stdout.write(getWasi2icVersionLocal());
}

if (import.meta.url === pathToFileURL(process.argv[1]).href) {
main();
}

0 comments on commit dce9262

Please sign in to comment.