Skip to content

Commit

Permalink
install dfx with the right version
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Sep 18, 2024
1 parent bb850c5 commit 2779949
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 7 deletions.
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 Azle used for it's last template
value: ${{ steps.get-dfx-version.outputs.dfx-version }}
runs:
using: composite
steps:
- uses: actions/checkout@v4

- id: get-dfx-version
run: |
DFX_VERSION=$(./.github/actions/get_dfx_version/get_dfx_version.sh)
echo "dfx-version=${DFX_VERSION}" >> "$GITHUB_OUTPUT"
shell: bash
20 changes: 20 additions & 0 deletions .github/actions/get_dfx_version/get_dfx_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Path to package.json
PACKAGE_JSON_PATH="package.json"

# Check if package.json exists
if [ ! -f "$PACKAGE_JSON_PATH" ]; then
echo "Error: $PACKAGE_JSON_PATH not found."
exit 1
fi

# Extract the Node.js version from globalDependencies
DFX_VERSION=$(jq -r '.azle.globalDependencies.dfx // empty' "$PACKAGE_JSON_PATH")

if [ -z "$DFX_VERSION" ]; then
echo "dfx version not found in globalDependencies."
exit 1
else
echo "$DFX_VERSION"
fi
13 changes: 12 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,20 @@ jobs:
- name: Install curl
run: sudo apt-get install curl -y

- id: get-dfx-version
# TODO Hey Jordan, This is here to demonstrate two different ways of doing get node version and get dfx version. I think we should unify them, but I wanted to have both to see which you prefered
uses: ./.github/actions/get_dfx_version

- name: Install dfx
run: |
# Install dfx (Note: DFX must be installed before `npm install` because the azle instalation process required dfx)
# TODO if you want we could explore using the install script... it's kind of overkill and we would still have to supply the version. Though if dfinity ever changed their install script again it would be only one place we would have to update. This would apply to the installation in the test.yml as well
DFXVM_INIT_YES=true DFX_VERSION=${{ steps.get-dfx-version.outputs.dfx-version }} sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"
- name: Install global dependencies
run: |
npx azle install-global-dependencies --rust --wasi2ic --dfx
npx azle install-global-dependencies --rust --wasi2ic
echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH
# TODO we should use some Action-specific bot account
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,23 @@ jobs:
with:
node-version: ${{ needs.get-node-version.outputs.node-version }}

- id: get-dfx-version
# TODO Hey Jordan, This is here to demonstrate two different ways of doing get node version and get dfx version. I think we should unify them, but I wanted to have both to see which you prefered
uses: ./.github/actions/get_dfx_version

- name: Run pre-test Azle setup
run: |
# Install dfx (Note: DFX must be installed before `npm install` because the azle instalation process required dfx)
DFXVM_INIT_YES=true DFX_VERSION=${{ steps.get-dfx-version.outputs.dfx-version }} sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"
echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH
npm install
if [[ "${{ matrix.azle_source }}" == "repo" ]]; then
npm link
fi
# Install dfx
# Hey Jordan, can you help me figure out why this doesn't work? While we are at it, there is a weird error that happens when we npm install
# npx azle install-global-dependencies --dfx
node src/build/index.js install-global-dependencies --dfx
echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH
# MacOS-specific DNS configuration
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
sudo networksetup -setdnsservers Ethernet 9.9.9.9
Expand Down

0 comments on commit 2779949

Please sign in to comment.