Skip to content

Use Task to build pinned CLI for IDE #1315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/check-i18n-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions arduino-ide-extension/scripts/download-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -82,6 +82,6 @@
shell.exit(1);
}
} else {
goBuildFromGit(version, destinationPath, 'CLI');
taskBuildFromGit(version, destinationPath, 'CLI');
}
})();
22 changes: 20 additions & 2 deletions arduino-ide-extension/scripts/utils.js
Original file line number Diff line number Diff line change
@@ -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`.
*
Expand All @@ -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');
Expand Down Expand Up @@ -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.`);
Expand All @@ -89,4 +107,4 @@ exports.goBuildFromGit = (version, destinationPath, taskName) => {
shell.exit(1);
}
shell.echo(`>>> Verified ${taskName}.`);
};
}