From 335522072006429fd7827bfd4d5b4c6c1041f8af Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Wed, 10 Aug 2022 13:56:05 +0200 Subject: [PATCH] Use `Task` to build pinned CLI for IDE2. Closes #1313 Signed-off-by: Akos Kitta --- .github/workflows/build.yml | 6 +++++ .github/workflows/check-i18n-task.yml | 6 +++++ arduino-ide-extension/scripts/download-cli.js | 4 ++-- arduino-ide-extension/scripts/utils.js | 22 +++++++++++++++++-- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3dceb0c85..9db90ff52 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,6 +66,12 @@ jobs: with: python-version: '3.x' + - name: Install Taskfile + uses: arduino/setup-task@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x + - name: Package shell: bash env: diff --git a/.github/workflows/check-i18n-task.yml b/.github/workflows/check-i18n-task.yml index e8c01a8b6..1ba1aca5c 100644 --- a/.github/workflows/check-i18n-task.yml +++ b/.github/workflows/check-i18n-task.yml @@ -31,6 +31,12 @@ jobs: node-version: '14.x' registry-url: 'https://registry.npmjs.org' + - name: Install Taskfile + uses: arduino/setup-task@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x + - name: Install dependencies run: yarn diff --git a/arduino-ide-extension/scripts/download-cli.js b/arduino-ide-extension/scripts/download-cli.js index 4121bbcb5..531e22a50 100755 --- a/arduino-ide-extension/scripts/download-cli.js +++ b/arduino-ide-extension/scripts/download-cli.js @@ -6,7 +6,7 @@ const semver = require('semver'); const moment = require('moment'); const downloader = require('./downloader'); - const { goBuildFromGit } = require('./utils'); + const { taskBuildFromGit } = require('./utils'); const version = (() => { const pkg = require(path.join(__dirname, '..', 'package.json')); @@ -82,6 +82,6 @@ shell.exit(1); } } else { - goBuildFromGit(version, destinationPath, 'CLI'); + taskBuildFromGit(version, destinationPath, 'CLI'); } })(); diff --git a/arduino-ide-extension/scripts/utils.js b/arduino-ide-extension/scripts/utils.js index 42e6114cc..c7ca7851e 100644 --- a/arduino-ide-extension/scripts/utils.js +++ b/arduino-ide-extension/scripts/utils.js @@ -1,3 +1,14 @@ +/** + * Clones something from GitHub and builds it with [`Task`](https://taskfile.dev/). + * + * @param version {object} the version object. + * @param destinationPath {string} the absolute path of the output binary. For example, `C:\\folder\\arduino-cli.exe` or `/path/to/arduino-language-server` + * @param taskName {string} for the CLI logging . Can be `'CLI'` or `'language-server'`, etc. + */ +exports.taskBuildFromGit = (version, destinationPath, taskName) => { + return buildFromGit('task', version, destinationPath, taskName); +}; + /** * Clones something from GitHub and builds it with `Golang`. * @@ -6,6 +17,13 @@ * @param taskName {string} for the CLI logging . Can be `'CLI'` or `'language-server'`, etc. */ exports.goBuildFromGit = (version, destinationPath, taskName) => { + return buildFromGit('go', version, destinationPath, taskName); +}; + +/** + * The `command` is either `go` or `task`. + */ +function buildFromGit(command, version, destinationPath, taskName) { const fs = require('fs'); const path = require('path'); const temp = require('temp'); @@ -62,7 +80,7 @@ exports.goBuildFromGit = (version, destinationPath, taskName) => { } shell.echo(`>>> Building the ${taskName}...`); - if (shell.exec('go build', { cwd: tempRepoPath }).code !== 0) { + if (shell.exec(`${command} build`, { cwd: tempRepoPath }).code !== 0) { shell.exit(1); } shell.echo(`<<< Done ${taskName} build.`); @@ -89,4 +107,4 @@ exports.goBuildFromGit = (version, destinationPath, taskName) => { shell.exit(1); } shell.echo(`>>> Verified ${taskName}.`); -}; +}