From 7b1b034f7390f64e1e13d74813c2f44bba19a02a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoralf=20M=C3=BCller?= Date: Tue, 26 Nov 2024 15:50:29 +0100 Subject: [PATCH 1/5] feat(CI): add Move IDE Tests workflow --- .github/actions/diffs/action.yml | 5 + .github/workflows/_move_ide_tests.yml | 127 ++++++++++++++++++ .github/workflows/hierarchy.yml | 12 ++ .../editors/code/scripts/create.sh | 23 ++-- 4 files changed, 155 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/_move_ide_tests.yml diff --git a/.github/actions/diffs/action.yml b/.github/actions/diffs/action.yml index 4e6922ba60f..b3a7c2260b7 100644 --- a/.github/actions/diffs/action.yml +++ b/.github/actions/diffs/action.yml @@ -10,6 +10,9 @@ outputs: isMove: description: True when changes happened to the Move code value: "${{ steps.diff.outputs.isMove }}" + isMoveIDE: + description: True when changes happened in move-analyzer code + value: "${{ steps.diff.outputs.isMoveIDE }}" isReleaseNotesEligible: description: True when changes happened in Release Notes eligible paths value: "${{ steps.diff.outputs.isReleaseNotesEligible }}" @@ -56,6 +59,8 @@ runs: - "examples/**" - "iota_programmability/**" - ".github/workflows/_move_tests.yml" + isMoveIDE: + - "external-crates/move/crates/move-analyzer/**" isReleaseNotesEligible: - "consensus/**" - "crates/**" diff --git a/.github/workflows/_move_ide_tests.yml b/.github/workflows/_move_ide_tests.yml new file mode 100644 index 00000000000..eb002d9436a --- /dev/null +++ b/.github/workflows/_move_ide_tests.yml @@ -0,0 +1,127 @@ +name: Move IDE Tests + +on: workflow_call + +concurrency: + group: move-ide-tests-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + move-auto-formatter-test: + name: Move Auto-formatter Test + runs-on: [self-hosted] + + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1 + with: + ref: ${{ github.event.inputs.iota_repo_ref || github.ref }} + + - name: Setup Node + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # pin@v4.0.2 + with: + node-version: "20" + + - name: Install dependencies + working-directory: ./external-crates/move/crates/move-analyzer/prettier-plugin + run: npm install && npm i web-tree-sitter + + - name: Run npm test + working-directory: ./external-crates/move/crates/move-analyzer/prettier-plugin + shell: bash + run: npm run test + + move-ide-test: + name: Move IDE Test + runs-on: [self-hosted] + + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1 + with: + ref: ${{ github.event.inputs.iota_repo_ref || github.ref }} + + - name: Setup Node + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # pin@v4.0.2 + with: + node-version: "20" + + - name: Install dependencies and start Xvfb (emulate display) + working-directory: ./external-crates/move/crates/move-analyzer/editors/code + run: | + sudo apt install libgtk-3-0 -y + sudo apt-get install -y xvfb x11-apps x11-xkb-utils libx11-6 libx11-xcb1 + set -eux + # Start server + /usr/bin/Xvfb :99 -screen 0 1024x768x24 & + sleep 1 + ps aux | grep Xvfb --color=always | grep -v grep + npm install && npm install --save-dev @types/node @types/semver + sudo add-apt-repository ppa:kisak/kisak-mesa -y + sudo apt update + sudo apt upgrade -y + + - name: Build move-analyzer + run: | + cargo build --bin move-analyzer + mkdir -p ~/.iota/bin + cp ./target/debug/move-analyzer* ~/.iota/bin + + - name: Run npm test + working-directory: ./external-crates/move/crates/move-analyzer/editors/code + shell: bash + run: DISPLAY=:99.0 npm run test + + move-ide-build: + name: Move IDE build + runs-on: [self-hosted] + + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1 + with: + ref: ${{ github.event.inputs.iota_repo_ref || github.ref }} + + - name: Setup Node + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # pin@v4.0.2 + with: + node-version: "20" + + - name: Install dependencies + working-directory: ./external-crates/move/crates/move-analyzer/editors/code + run: npm install && npm install --save-dev @types/node @types/semver + + - name: Build VSCode extension + working-directory: ./external-crates/move/crates/move-analyzer/editors/code + run: npm run package + + move-ide-build-with-binaries: + name: Move IDE build with released binaries + runs-on: [self-hosted] + + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1 + with: + ref: ${{ github.event.inputs.iota_repo_ref || github.ref }} + + - name: Setup Node + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # pin@v4.0.2 + with: + node-version: "20" + + - name: Install dependencies + working-directory: ./external-crates/move/crates/move-analyzer/editors/code + run: | + npm install + npm install --save-dev @types/node @types/semver + npm install -g vsce + sudo apt install zsh -y + + - name: Build VSCode extensions + working-directory: ./external-crates/move/crates/move-analyzer/editors/code + run: ./scripts/create.sh -pkg + + - name: Print built files + working-directory: ./external-crates/move/crates/move-analyzer/editors/code + run: echo *.vsix diff --git a/.github/workflows/hierarchy.yml b/.github/workflows/hierarchy.yml index 309d1e93e72..3735164361d 100644 --- a/.github/workflows/hierarchy.yml +++ b/.github/workflows/hierarchy.yml @@ -22,6 +22,7 @@ jobs: isMove: ${{ steps.diff.outputs.isMove }} isDoc: ${{ steps.diff.outputs.isDoc }} isReleaseNotesEligible: ${{ steps.diff.outputs.isReleaseNotesEligible }} + isMoveIDE: ${{ steps.diff.outputs.isMoveIDE }} isWallet: ${{ (steps.turbo.outputs.packages && contains(fromJson(steps.turbo.outputs.packages), 'iota-wallet')) }} isExplorer: ${{ (steps.turbo.outputs.packages && contains(fromJson(steps.turbo.outputs.packages), 'iota-explorer')) }} isTypescriptSDK: ${{ (steps.turbo.outputs.packages && contains(fromJson(steps.turbo.outputs.packages), '@iota/iota-sdk')) }} @@ -175,3 +176,14 @@ jobs: - typos uses: ./.github/workflows/_ledgernano.yml secrets: inherit + + move-ide-tests: + if: (!cancelled() && !failure()) && needs.diff.outputs.isMoveIDE == 'true' + # TODO: use this line + # if: (!cancelled() && !failure()) && needs.diff.outputs.isMoveIDE == 'true' && github.event.pull_request.draft == false + needs: + - diff + - dprint-format + - license-check + - typos + uses: ./.github/workflows/_move_ide_tests.yml diff --git a/external-crates/move/crates/move-analyzer/editors/code/scripts/create.sh b/external-crates/move/crates/move-analyzer/editors/code/scripts/create.sh index a63c8adc9fa..f94940ab8fa 100755 --- a/external-crates/move/crates/move-analyzer/editors/code/scripts/create.sh +++ b/external-crates/move/crates/move-analyzer/editors/code/scripts/create.sh @@ -43,9 +43,8 @@ do fi done -# these will have to change if we want a different network/version -NETWORK="alphanet" -VERSION="0.4.0" +# these will have to change if we want a different version +VERSION="0.7.2-rc" # a map from os version identifiers in Iota's binary distribution to os version identifiers # representing VSCode's target platforms used for creating platform-specific plugin distributions @@ -55,7 +54,7 @@ SUPPORTED_OS[macos-arm64]=darwin-arm64 SUPPORTED_OS[linux-x86_64]=linux-x64 #SUPPORTED_OS[windows-x86_64]=win32-x64 -TMP_DIR=$( mktemp -d -t vscode-create ) +TMP_DIR=$( mktemp -d -t vscode-createXXX ) trap "clean_tmp_dir $TMP_DIR" EXIT LANG_SERVER_DIR="language-server" @@ -64,21 +63,21 @@ rm -rf $LANG_SERVER_DIR mkdir $LANG_SERVER_DIR for DIST_OS VSCODE_OS in "${(@kv)SUPPORTED_OS}"; do - # Iota distribution identifier - IOTA_DISTRO=$NETWORK"-v"$VERSION - # name of the Iota distribution archive file, for example iota-testnet-v1.0.0-macos-arm64.tgz - IOTA_ARCHIVE="iota-"$IOTA_DISTRO"-"$DIST_OS".tgz" + # IOTA distribution identifier + IOTA_VERSION="v"$VERSION + # name of the Iota distribution archive file, for example iota-v1.0.0-macos-arm64.tgz + IOTA_ARCHIVE="iota-"$IOTA_VERSION"-"$DIST_OS".tgz" # a path to downloaded Iota archive IOTA_ARCHIVE_PATH=$TMP_DIR"/"$IOTA_ARCHIVE - # download Iota archive file to a given location and uncompress it - curl https://github.com/iotaledger/iota/releases/download/"$IOTA_DISTRO"/"$IOTA_ARCHIVE" -L -o $IOTA_ARCHIVE_PATH + # download IOTA archive file to a given location and uncompress it + curl https://github.com/iotaledger/iota/releases/download/"$IOTA_VERSION"/"$IOTA_ARCHIVE" -L -o $IOTA_ARCHIVE_PATH tar -xf $IOTA_ARCHIVE_PATH --directory $TMP_DIR # names of the move-analyzer binary, both the one becoming part of the extension ($SERVER_BIN) # and the one in the Iota archive ($ARCHIVE_SERVER_BIN) SERVER_BIN="move-analyzer" - ARCHIVE_SERVER_BIN=$SERVER_BIN"-"$DIST_OS + ARCHIVE_SERVER_BIN=$SERVER_BIN if [[ "$DIST_OS" == *"windows"* ]]; then SERVER_BIN="$SERVER_BIN".exe ARCHIVE_SERVER_BIN="$ARCHIVE_SERVER_BIN".exe @@ -86,7 +85,7 @@ for DIST_OS VSCODE_OS in "${(@kv)SUPPORTED_OS}"; do # copy move-analyzer binary to the appropriate location where it's picked up when bundling the # extension - SRC_SERVER_BIN_LOC=$TMP_DIR"/external-crates/move/target/release/"$ARCHIVE_SERVER_BIN + SRC_SERVER_BIN_LOC=$TMP_DIR"/"$ARCHIVE_SERVER_BIN DST_SERVER_BIN_LOC=$LANG_SERVER_DIR"/"$SERVER_BIN cp $SRC_SERVER_BIN_LOC $DST_SERVER_BIN_LOC From 35858c96c70aa5ee136c6c24baca7f298cc039d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoralf=20M=C3=BCller?= Date: Tue, 26 Nov 2024 16:05:18 +0100 Subject: [PATCH 2/5] don't run move-ide-test if draft --- .github/workflows/hierarchy.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/hierarchy.yml b/.github/workflows/hierarchy.yml index 3735164361d..b72425979d1 100644 --- a/.github/workflows/hierarchy.yml +++ b/.github/workflows/hierarchy.yml @@ -178,9 +178,7 @@ jobs: secrets: inherit move-ide-tests: - if: (!cancelled() && !failure()) && needs.diff.outputs.isMoveIDE == 'true' - # TODO: use this line - # if: (!cancelled() && !failure()) && needs.diff.outputs.isMoveIDE == 'true' && github.event.pull_request.draft == false + if: (!cancelled() && !failure()) && needs.diff.outputs.isMoveIDE == 'true' && github.event.pull_request.draft == false needs: - diff - dprint-format From 9df0fc70fc9735649edd9706ebdcd657ef181e31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoralf=20M=C3=BCller?= Date: Thu, 28 Nov 2024 10:43:12 +0100 Subject: [PATCH 3/5] Address review comments --- .github/actions/diffs/action.yml | 5 +++ .../{_move_ide_tests.yml => _move_ide.yml} | 45 +++---------------- .github/workflows/hierarchy.yml | 4 +- 3 files changed, 14 insertions(+), 40 deletions(-) rename .github/workflows/{_move_ide_tests.yml => _move_ide.yml} (68%) diff --git a/.github/actions/diffs/action.yml b/.github/actions/diffs/action.yml index b3a7c2260b7..31499a74e16 100644 --- a/.github/actions/diffs/action.yml +++ b/.github/actions/diffs/action.yml @@ -61,6 +61,11 @@ runs: - ".github/workflows/_move_tests.yml" isMoveIDE: - "external-crates/move/crates/move-analyzer/**" + - "external-crates/move/crates/move-command-line-common/**" + - "external-crates/move/crates/move-compiler/**" + - "external-crates/move/crates/move-ir-types/**" + - "external-crates/move/crates/move-package/**" + - "external-crates/move/crates/move-symbol-pool/**" isReleaseNotesEligible: - "consensus/**" - "crates/**" diff --git a/.github/workflows/_move_ide_tests.yml b/.github/workflows/_move_ide.yml similarity index 68% rename from .github/workflows/_move_ide_tests.yml rename to .github/workflows/_move_ide.yml index eb002d9436a..7668e37c81a 100644 --- a/.github/workflows/_move_ide_tests.yml +++ b/.github/workflows/_move_ide.yml @@ -1,9 +1,9 @@ -name: Move IDE Tests +name: Move IDE on: workflow_call concurrency: - group: move-ide-tests-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: move-ide-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: @@ -46,7 +46,7 @@ jobs: with: node-version: "20" - - name: Install dependencies and start Xvfb (emulate display) + - name: Install dependencies and start Xvfb (emulate a display so VS Code can be started) working-directory: ./external-crates/move/crates/move-analyzer/editors/code run: | sudo apt install libgtk-3-0 -y @@ -56,10 +56,10 @@ jobs: /usr/bin/Xvfb :99 -screen 0 1024x768x24 & sleep 1 ps aux | grep Xvfb --color=always | grep -v grep - npm install && npm install --save-dev @types/node @types/semver sudo add-apt-repository ppa:kisak/kisak-mesa -y sudo apt update sudo apt upgrade -y + npm install && npm install --save-dev @types/node @types/semver - name: Build move-analyzer run: | @@ -70,10 +70,10 @@ jobs: - name: Run npm test working-directory: ./external-crates/move/crates/move-analyzer/editors/code shell: bash - run: DISPLAY=:99.0 npm run test + run: DISPLAY=:99.0 npm run pretest && npm run test - move-ide-build: - name: Move IDE build + move-vscode-extension-build: + name: Move VSCode extension build runs-on: [self-hosted] steps: @@ -94,34 +94,3 @@ jobs: - name: Build VSCode extension working-directory: ./external-crates/move/crates/move-analyzer/editors/code run: npm run package - - move-ide-build-with-binaries: - name: Move IDE build with released binaries - runs-on: [self-hosted] - - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # Pin v4.1.1 - with: - ref: ${{ github.event.inputs.iota_repo_ref || github.ref }} - - - name: Setup Node - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # pin@v4.0.2 - with: - node-version: "20" - - - name: Install dependencies - working-directory: ./external-crates/move/crates/move-analyzer/editors/code - run: | - npm install - npm install --save-dev @types/node @types/semver - npm install -g vsce - sudo apt install zsh -y - - - name: Build VSCode extensions - working-directory: ./external-crates/move/crates/move-analyzer/editors/code - run: ./scripts/create.sh -pkg - - - name: Print built files - working-directory: ./external-crates/move/crates/move-analyzer/editors/code - run: echo *.vsix diff --git a/.github/workflows/hierarchy.yml b/.github/workflows/hierarchy.yml index b72425979d1..87c4978a839 100644 --- a/.github/workflows/hierarchy.yml +++ b/.github/workflows/hierarchy.yml @@ -177,11 +177,11 @@ jobs: uses: ./.github/workflows/_ledgernano.yml secrets: inherit - move-ide-tests: + move-ide: if: (!cancelled() && !failure()) && needs.diff.outputs.isMoveIDE == 'true' && github.event.pull_request.draft == false needs: - diff - dprint-format - license-check - typos - uses: ./.github/workflows/_move_ide_tests.yml + uses: ./.github/workflows/_move_ide.yml From e0ca8959234a689f700879ffe927bfe50fb529f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoralf=20M=C3=BCller?= Date: Thu, 28 Nov 2024 12:35:39 +0100 Subject: [PATCH 4/5] Run on any change in external crates, fix test command --- .github/actions/diffs/action.yml | 7 +------ .github/workflows/_move_ide.yml | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/actions/diffs/action.yml b/.github/actions/diffs/action.yml index 31499a74e16..c52c900ce46 100644 --- a/.github/actions/diffs/action.yml +++ b/.github/actions/diffs/action.yml @@ -60,12 +60,7 @@ runs: - "iota_programmability/**" - ".github/workflows/_move_tests.yml" isMoveIDE: - - "external-crates/move/crates/move-analyzer/**" - - "external-crates/move/crates/move-command-line-common/**" - - "external-crates/move/crates/move-compiler/**" - - "external-crates/move/crates/move-ir-types/**" - - "external-crates/move/crates/move-package/**" - - "external-crates/move/crates/move-symbol-pool/**" + - "external-crates/move/crates/**" isReleaseNotesEligible: - "consensus/**" - "crates/**" diff --git a/.github/workflows/_move_ide.yml b/.github/workflows/_move_ide.yml index 7668e37c81a..5878489c9aa 100644 --- a/.github/workflows/_move_ide.yml +++ b/.github/workflows/_move_ide.yml @@ -70,7 +70,7 @@ jobs: - name: Run npm test working-directory: ./external-crates/move/crates/move-analyzer/editors/code shell: bash - run: DISPLAY=:99.0 npm run pretest && npm run test + run: npm run pretest && DISPLAY=:99.0 npm run test move-vscode-extension-build: name: Move VSCode extension build From cd88bc60886f01e705a383678ced2db77c3cc87a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoralf=20M=C3=BCller?= Date: Thu, 28 Nov 2024 12:38:36 +0100 Subject: [PATCH 5/5] Rename diff output to isExternalCrates --- .github/actions/diffs/action.yml | 8 ++++---- .github/workflows/hierarchy.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/actions/diffs/action.yml b/.github/actions/diffs/action.yml index c52c900ce46..ac54e779fdd 100644 --- a/.github/actions/diffs/action.yml +++ b/.github/actions/diffs/action.yml @@ -10,9 +10,9 @@ outputs: isMove: description: True when changes happened to the Move code value: "${{ steps.diff.outputs.isMove }}" - isMoveIDE: - description: True when changes happened in move-analyzer code - value: "${{ steps.diff.outputs.isMoveIDE }}" + isExternalCrates: + description: True when changes happened in external crates + value: "${{ steps.diff.outputs.isExternalCrates }}" isReleaseNotesEligible: description: True when changes happened in Release Notes eligible paths value: "${{ steps.diff.outputs.isReleaseNotesEligible }}" @@ -59,7 +59,7 @@ runs: - "examples/**" - "iota_programmability/**" - ".github/workflows/_move_tests.yml" - isMoveIDE: + isExternalCrates: - "external-crates/move/crates/**" isReleaseNotesEligible: - "consensus/**" diff --git a/.github/workflows/hierarchy.yml b/.github/workflows/hierarchy.yml index 87c4978a839..ec62cbf71d9 100644 --- a/.github/workflows/hierarchy.yml +++ b/.github/workflows/hierarchy.yml @@ -22,7 +22,7 @@ jobs: isMove: ${{ steps.diff.outputs.isMove }} isDoc: ${{ steps.diff.outputs.isDoc }} isReleaseNotesEligible: ${{ steps.diff.outputs.isReleaseNotesEligible }} - isMoveIDE: ${{ steps.diff.outputs.isMoveIDE }} + isExternalCrates: ${{ steps.diff.outputs.isExternalCrates }} isWallet: ${{ (steps.turbo.outputs.packages && contains(fromJson(steps.turbo.outputs.packages), 'iota-wallet')) }} isExplorer: ${{ (steps.turbo.outputs.packages && contains(fromJson(steps.turbo.outputs.packages), 'iota-explorer')) }} isTypescriptSDK: ${{ (steps.turbo.outputs.packages && contains(fromJson(steps.turbo.outputs.packages), '@iota/iota-sdk')) }} @@ -178,7 +178,7 @@ jobs: secrets: inherit move-ide: - if: (!cancelled() && !failure()) && needs.diff.outputs.isMoveIDE == 'true' && github.event.pull_request.draft == false + if: (!cancelled() && !failure()) && needs.diff.outputs.isExternalCrates == 'true' && github.event.pull_request.draft == false needs: - diff - dprint-format