From 14df4fdc02a09a1af6edbd7cfaf6c64a3e0d7845 Mon Sep 17 00:00:00 2001 From: Benjamin DeMann Date: Fri, 25 Oct 2024 09:31:42 -0600 Subject: [PATCH] move install dfx into a setup dfx action --- .github/actions/get_dfx_version/action.yml | 14 ---------- .../{get_dfx_version => setup_dfx}/README.md | 6 ++--- .github/actions/setup_dfx/action.yml | 27 +++++++++++++++++++ .github/workflows/release_parallel.yml | 20 +++----------- .github/workflows/run_test.yml | 9 ++----- 5 files changed, 36 insertions(+), 40 deletions(-) delete mode 100644 .github/actions/get_dfx_version/action.yml rename .github/actions/{get_dfx_version => setup_dfx}/README.md (84%) create mode 100644 .github/actions/setup_dfx/action.yml diff --git a/.github/actions/get_dfx_version/action.yml b/.github/actions/get_dfx_version/action.yml deleted file mode 100644 index 3797571230..0000000000 --- a/.github/actions/get_dfx_version/action.yml +++ /dev/null @@ -1,14 +0,0 @@ -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 templates - value: ${{ steps.get-dfx-version.outputs.dfx-version }} -runs: - using: composite - steps: - - 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 diff --git a/.github/actions/get_dfx_version/README.md b/.github/actions/setup_dfx/README.md similarity index 84% rename from .github/actions/get_dfx_version/README.md rename to .github/actions/setup_dfx/README.md index 6a114e88db..293d76f9e3 100644 --- a/.github/actions/get_dfx_version/README.md +++ b/.github/actions/setup_dfx/README.md @@ -17,8 +17,8 @@ checking out a specific branch. steps: - uses: actions/checkout@v4 - - id: get-dfx-version - uses: ./.github/actions/get_dfx_version + - id: setup-dfx + uses: ./.github/actions/setup_dfx - - run: echo ${{ steps.get-dfx-version.outputs.dfx-version }} + - run: echo ${{ steps.setup-dfx.outputs.dfx-version }} ``` diff --git a/.github/actions/setup_dfx/action.yml b/.github/actions/setup_dfx/action.yml new file mode 100644 index 0000000000..1d2103cd1a --- /dev/null +++ b/.github/actions/setup_dfx/action.yml @@ -0,0 +1,27 @@ +name: Setup dfx +description: 'Sets up dfx by detecting version from package.json and installing it. (Note: DFX must be installed before `npm install` because the azle installation process requires dfx)' +inputs: + dfx-version: + description: 'The version of dfx to install (optional - will read from package.json if not provided)' + required: false +outputs: + dfx-version: + description: 'The version of dfx that was installed' + value: ${{ steps.get-dfx-version.outputs.dfx-version }} +runs: + using: composite + steps: + - id: get-dfx-version + if: inputs.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 + + - name: Install dfx + run: | + VERSION="${{ inputs.dfx-version || steps.get-dfx-version.outputs.dfx-version }}" + # Install dfx (Note: dfx must be installed before `npx azle` because the azle installation process requires dfx) + src/build/stable/commands/install_global_dependencies/install_dfx.sh $VERSION + echo "$HOME/.local/share/dfx/bin" >> $GITHUB_PATH + shell: bash diff --git a/.github/workflows/release_parallel.yml b/.github/workflows/release_parallel.yml index 58bdd325b5..4d550c860c 100644 --- a/.github/workflows/release_parallel.yml +++ b/.github/workflows/release_parallel.yml @@ -46,14 +46,8 @@ jobs: - name: Install curl run: sudo apt-get install curl -y - - id: get-dfx-version - uses: ./.github/actions/get_dfx_version - - - name: Install dfx - run: | - # Install dfx (Note: dfx must be installed before `npx azle` 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 + - name: Setup dfx + uses: ./.github/actions/setup_dfx - run: npm install @@ -119,14 +113,8 @@ jobs: with: node-version: ${{ steps.get-node-version.outputs.node-version }} - - id: get-dfx-version - uses: ./.github/actions/get_dfx_version - - - name: Install dfx - run: | - # Install dfx (Note: dfx must be installed before `npx azle` 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 + - name: Setup dfx + uses: ./.github/actions/setup_dfx - name: Update azle version run: | diff --git a/.github/workflows/run_test.yml b/.github/workflows/run_test.yml index 49f8e74415..5074097cdf 100644 --- a/.github/workflows/run_test.yml +++ b/.github/workflows/run_test.yml @@ -65,16 +65,11 @@ jobs: with: node-version: ${{ steps.get-node-version.outputs.node-version }} - - id: get-dfx-version - uses: ./.github/actions/get_dfx_version + - id: setup-dfx + uses: ./.github/actions/setup_dfx - name: Run pre-test Azle setup run: | - - # 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 - # MacOS-specific DNS configuration if [[ "${{ matrix.os }}" == "macos-latest" ]]; then sudo networksetup -setdnsservers Ethernet 9.9.9.9