Skip to content
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

Release 0.24.2 rc.9 #2106

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/actions/get_dfx_version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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
value: ${{ steps.get-dfx-version.outputs.dfx-version }}
runs:
using: composite
steps:
- uses: actions/checkout@v4

- id: get-dfx-version
run: |
DFX_VERSION=$(jq -r '.azle.globalDependencies.dfx // error("dfx version not found")' "package.json")
echo "dfx-version=${DFX_VERSION}" >> "$GITHUB_OUTPUT"
shell: bash
16 changes: 16 additions & 0 deletions .github/actions/get_node_version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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
value: ${{ steps.get-node-version.outputs.node-version }}
runs:
using: composite
steps:
- uses: actions/checkout@v4

- id: get-node-version
run: |
NODE_VERSION=$(jq -r '.azle.globalDependencies.node // error("node version not found")' "package.json")
echo "node-version=${NODE_VERSION}" >> "$GITHUB_OUTPUT"
shell: bash
7 changes: 3 additions & 4 deletions .github/actions/get_test_infos/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ description:
displayPath: string // An abbreviated version of the path for display purposes only
}'
inputs:
node-version:
description: The version of Node.js to use
required: true
directories:
description: List of directories to search for npm projects with an npm test script
required: true
exclude-dirs:
description: List of directories to exclude from the search
required: false
default: ''
node-version:
description: The version of Node.js to use
required: true
default: '20.x'
outputs:
test-infos:
description: All of the test info objects found by this action
Expand Down
58 changes: 0 additions & 58 deletions .github/scripts/install_global_dependencies.sh

This file was deleted.

25 changes: 18 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ on:
branches:
- main
pull_request: # Runs on pull requests to any branch
env:
DFX_VERSION: 0.21.0
NODE_VERSION: 20
jobs:
determine-should-release:
if: ${{ startsWith(github.head_ref, 'release--') }}
Expand All @@ -30,10 +27,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- id: get-node-version
uses: ./.github/actions/get_node_version

- name: Get all test infos
id: get-test-infos
uses: ./.github/actions/get_test_infos
with:
node-version: ${{ steps.get-node-version.outputs.node-version }}
directories: |
./examples
./tests
Expand All @@ -55,24 +56,34 @@ jobs:
ref: ${{ github.event.pull_request.head.ref || github.ref }}
token: ${{ secrets.LASTMJS_GITHUB_TOKEN || github.token }}

- id: get-node-version
uses: ./.github/actions/get_node_version

- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
node-version: ${{ steps.get-node-version.outputs.node-version }}
registry-url: https://registry.npmjs.org
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Install curl
run: sudo apt-get install curl -y

- name: Install global dependencies
run: ./.github/scripts/install_global_dependencies.sh
- id: get-dfx-version
uses: ./.github/actions/get_dfx_version

- name: Install dfx
run: |
DFXVM_INIT_YES=true DFX_VERSION=${{ env.DFX_VERSION }} sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"
# Install dfx (Note: DFX must be installed before `npx azle` because the azle instalation 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

- run: npm install

- name: Install global dependencies
run: |
AZLE_VERBOSE=true npx azle install-global-dependencies --rust --wasi2ic

# TODO we should use some Action-specific bot account
- name: Configure git for publishing release
run: |
Expand Down
39 changes: 29 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ on:
- main
pull_request: # Runs on pull requests to any branch
env:
DFX_VERSION: 0.22.0
NODE_VERSION: 20
IS_MAIN_BRANCH: ${{ github.ref == 'refs/heads/main' }}
IS_RELEASE_BRANCH_PR: ${{ startsWith(github.head_ref, 'release--') }}
IS_FEATURE_BRANCH_PR: ${{ !startsWith(github.head_ref, 'release--') }}
Expand All @@ -38,10 +36,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- id: get-node-version
uses: ./.github/actions/get_node_version

- name: Get test infos
id: get-test-infos
uses: ./.github/actions/get_test_infos
with:
node-version: ${{ steps.get-node-version.outputs.node-version }}
directories: |
./examples
./tests
Expand Down Expand Up @@ -94,15 +96,21 @@ jobs:

- uses: actions/checkout@v4

- id: get-node-version
uses: ./.github/actions/get_node_version

- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
node-version: ${{ steps.get-node-version.outputs.node-version }}

- id: get-dfx-version
uses: ./.github/actions/get_dfx_version

- name: Run pre-test Azle setup
run: |

# Install dfx
DFXVM_INIT_YES=true DFX_VERSION=${{ env.DFX_VERSION }} sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"
# Install dfx (Note: DFX must be installed before `npm install` because the azle instalation 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

# MacOS-specific DNS configuration
Expand Down Expand Up @@ -161,16 +169,27 @@ jobs:
# These final jobs are designed to ensure that all jobs spun up from the matrix in the run-test have succeeded
check-test-success:
name: Check Azle tests succeeded
needs: run-test
needs:
- run-test
- check-test-failure
runs-on: ubuntu-latest
if: success()
steps:
- run: exit 0
- name: Check test result
run: |
if [ "${{ job.status }}" == "success" ]; then
exit 0
else
exit 1

# TODO if this works how I think it should then we can get rid of this tests completely
check-test-failure:
name: Check Azle tests didn't fail
needs: run-test
runs-on: ubuntu-latest
if: failure()
steps:
- run: exit 1
- name: Check test result
run: |
if [ "${{ job.status }}" != "failure" ]; then
exit 1
else
exit 0
4 changes: 2 additions & 2 deletions package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "azle",
"version": "0.24.1",
"version": "0.24.2-rc.9",
"description": "TypeScript and JavaScript CDK for the Internet Computer",
"scripts": {
"typecheck": "tsc --noEmit",
Expand Down Expand Up @@ -81,7 +81,8 @@
"globalDependencies": {
"wasi2ic": "https://github.com/wasm-forge/wasi2ic?rev=806c3558aad24224852a9582f018178402cb3679#806c3558",
"node": "20.11.0",
"rustc": "1.80.1"
"rustc": "1.80.1",
"dfx": "0.22.0"
}
}
}
28 changes: 28 additions & 0 deletions src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { runCommand as runCleanCommand } from './stable/commands/clean';
import { runCommand as runStableCompileCommand } from './stable/commands/compile';
import { runCommand as runInstallDfxExtensionCommand } from './stable/commands/install_dfx_extension';
import { runCommand as runInstallGlobalDependenciesCommand } from './stable/commands/install_global_dependencies';
import { runCommand as runNewCommand } from './stable/commands/new';
import { runCommand as runStableTemplateCommand } from './stable/commands/template';
import { runCommand as runVersionCommand } from './stable/commands/version';
Expand All @@ -38,6 +39,12 @@ async function build(): Promise<void> {
return;
}

if (command === 'install-global-dependencies') {
handleInstallGlobalDependenciesCommand(ioType);

return;
}

if (command === 'upload-assets') {
await handleUploadAssetsCommand();

Expand Down Expand Up @@ -129,6 +136,27 @@ async function handleTemplateCommand(ioType: IOType): Promise<void> {
}
}

async function handleInstallGlobalDependenciesCommand(
ioType: IOType
): Promise<void> {
const node = process.argv.includes('--node');
const dfx = process.argv.includes('--dfx');
const rustc = process.argv.includes('--rust');
const wasi2ic = process.argv.includes('--wasi2ic');

if (!node && !dfx && !rustc && !wasi2ic) {
await runInstallGlobalDependenciesCommand(
{ dfx: true, node: true, rustc: true, wasi2ic: true },
ioType
);
} else {
await runInstallGlobalDependenciesCommand(
{ dfx, node, rustc, wasi2ic },
ioType
);
}
}

async function handleNewCommand(): Promise<void> {
const experimental = process.argv.includes('--experimental');
const httpServer = process.argv.includes('--http-server');
Expand Down
55 changes: 55 additions & 0 deletions src/build/stable/commands/install_global_dependencies/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { IOType } from 'child_process';
import { readFile } from 'fs/promises';
import { join } from 'path';

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

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

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

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

export async function runCommand(
dependenciesToInstall: Dependencies,
ioType: IOType
): Promise<void> {
for (const key in dependenciesToInstall) {
const dependency = key as DependencyName;
if (dependenciesToInstall[dependency] === true) {
installDependency(dependency, ioType);
}
}
}

async function installDependency(
dependency: DependencyName,
ioType: IOType
): Promise<void> {
console.info(`Installing ${dependency}...`);
const version = (await getGlobalDependencies())[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;
}
Loading
Loading