Skip to content

Commit

Permalink
move install dfx into a setup dfx action
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Oct 25, 2024
1 parent 622de9d commit 14df4fd
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 40 deletions.
14 changes: 0 additions & 14 deletions .github/actions/get_dfx_version/action.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
```
27 changes: 27 additions & 0 deletions .github/actions/setup_dfx/action.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 4 additions & 16 deletions .github/workflows/release_parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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: |
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/run_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 14df4fd

Please sign in to comment.