From f9aa341004b77253800f64e5a4debcb4fc2f8b83 Mon Sep 17 00:00:00 2001 From: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> Date: Thu, 28 Nov 2024 13:10:27 +0100 Subject: [PATCH] feat(CI): add Move IDE Tests workflow (#4226) * feat(CI): add Move IDE Tests workflow * don't run move-ide-test if draft * Address review comments * Run on any change in external crates, fix test command * Rename diff output to isExternalCrates --- .github/actions/diffs/action.yml | 5 + .github/workflows/_move_ide.yml | 96 +++++++++++++++++++ .github/workflows/hierarchy.yml | 10 ++ .../editors/code/scripts/create.sh | 23 +++-- 4 files changed, 122 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/_move_ide.yml diff --git a/.github/actions/diffs/action.yml b/.github/actions/diffs/action.yml index 4e6922ba60f..ac54e779fdd 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 }}" + 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 }}" @@ -56,6 +59,8 @@ runs: - "examples/**" - "iota_programmability/**" - ".github/workflows/_move_tests.yml" + isExternalCrates: + - "external-crates/move/crates/**" isReleaseNotesEligible: - "consensus/**" - "crates/**" diff --git a/.github/workflows/_move_ide.yml b/.github/workflows/_move_ide.yml new file mode 100644 index 00000000000..5878489c9aa --- /dev/null +++ b/.github/workflows/_move_ide.yml @@ -0,0 +1,96 @@ +name: Move IDE + +on: workflow_call + +concurrency: + group: move-ide-${{ 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 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 + 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 + 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: | + 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: npm run pretest && DISPLAY=:99.0 npm run test + + move-vscode-extension-build: + name: Move VSCode extension 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 diff --git a/.github/workflows/hierarchy.yml b/.github/workflows/hierarchy.yml index 88862232da1..6456b3e033a 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 }} + 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')) }} @@ -148,3 +149,12 @@ jobs: - typos uses: ./.github/workflows/_ledgernano.yml secrets: inherit + + move-ide: + if: (!cancelled() && !failure()) && needs.diff.outputs.isExternalCrates == 'true' && github.event.pull_request.draft == false + needs: + - diff + - dprint-format + - license-check + - typos + uses: ./.github/workflows/_move_ide.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