Skip to content

Commit

Permalink
use bash where acceptable
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Sep 18, 2024
1 parent 77c023f commit a3fa9bb
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 54 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 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
4 changes: 1 addition & 3 deletions .github/actions/get_node_version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ runs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4

- id: get-node-version
run: |
NODE_VERSION=$(npx tsx ./.github/actions/get_node_version/index.ts)
NODE_VERSION=$(jq -r '.azle.globalDependencies.node // error("node version not found")' "package.json")
echo "node-version=${NODE_VERSION}" >> "$GITHUB_OUTPUT"
shell: bash
18 changes: 0 additions & 18 deletions .github/actions/get_node_version/index.ts

This file was deleted.

10 changes: 3 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,12 @@ jobs:
run: sudo apt-get install curl -y

- id: get-dfx-version
run: |
DFX_VERSION=$(npx tsx ./src/build/stable/utils/versions/dfx.ts)
echo "dfx-version=${DFX_VERSION}" >> "$GITHUB_OUTPUT"
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)"
# 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 }}
- name: Install global dependencies
run: |
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,13 @@ jobs:
node-version: ${{ steps.get-node-version.outputs.node-version }}

- id: get-dfx-version
run: |
DFX_VERSION=$(npx tsx ./src/build/stable/utils/versions/dfx.ts)
echo "dfx-version=${DFX_VERSION}" >> "$GITHUB_OUTPUT"
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)"
# 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,7 @@ fi

NODE_VERSION=$1

# Load nvm if it's installed
if [ -s "$HOME/.nvm/nvm.sh" ]; then
source "$HOME/.nvm/nvm.sh"
elif [ -s "/usr/local/opt/nvm/nvm.sh" ]; then
# Fallback for macOS/Homebrew installation path
source "/usr/local/opt/nvm/nvm.sh"
else
echo "nvm is not installed."
fi

# Check if nvm is installed
if ! command -v nvm &> /dev/null; then
echo "nvm is not installed. Installing nvm..."
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# Load nvm into the shell (necessary for the script to use nvm after installation)
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
else
echo "nvm is already installed."
fi
source "$HOME/.nvm/nvm.sh"

if nvm ls "$NODE_VERSION" &> /dev/null; then
echo "Node.js version $NODE_VERSION is already installed. Skipping installation."
Expand Down

0 comments on commit a3fa9bb

Please sign in to comment.