Skip to content
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

Build neovim nightly on download failure #18

Merged
merged 1 commit into from
Oct 1, 2021
Merged

Build neovim nightly on download failure #18

merged 1 commit into from
Oct 1, 2021

Conversation

glacambre
Copy link
Contributor

As described in the commit message, Neovim is often failing to publish nightly releases these days. When this happens, it would be nice to have action-setup-vim fall back to building neovim. I know that you said in #9 that you thought there wasn't much of point to doing this as when Neovim fails to publish a nightly release this means that HEAD is broken, but I think the situation has changed since this comment. Indeed, as described in neovim/neovim#15709 , the recent failures are caused by Neovim's CI failing to publish artifacts that built fine. In this case, building Neovim is a perfect workaround.

This commit implements building neovim nightly in case of download failures on linux. If you are okay with this approach, I'll try to implement OSX and Windows support.

core.debug(`Building and installing Neovim to ${installDir}.`);
const dir = path.join(await makeTmpdir(), 'neovim');

await exec('git', ['clone', '--depth=1', 'https://github.com/neovim/neovim', dir]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be better to install dependencies in this function so that user don't always need to install them. Installing packages via apt-get takes time because many network requests happen. I think avoiding them as much as possible would be great.

await exec('sudo', ['apt-get', 'install', '-y', 'ninja-build', 'gettext', 'libtool', 'libtool-bin', 'autoconf', 'automake', 'cmake', 'g++', 'pkg-config', 'unzip', 'curl']);

try {
return downloadNeovim(config.version, 'linux');
} catch (e) {
core.debug(`Neovim download failure: ${e.message}.`);
Copy link
Owner

@rhysd rhysd Sep 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
core.debug(`Neovim download failure: ${e.message}.`);
const err = ensureError(e);
core.debug(`Neovim download failure: ${err.message}.`);

ensureError() is necessary to make TypeScript compiler happy.

src/neovim.ts Outdated
await exec('git', ['clone', '--depth=1', 'https://github.com/neovim/neovim', dir]);

const opts = { cwd: dir };
await exec('make', ['-j', `CMAKE_EXTRA_FLAGS=-DCMAKE_INSTALL_PREFIX=${installDir}`], opts);
Copy link
Owner

@rhysd rhysd Sep 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await exec('make', ['-j', `CMAKE_EXTRA_FLAGS=-DCMAKE_INSTALL_PREFIX=${installDir}`], opts);
await exec('make', ['-j', `CMAKE_EXTRA_FLAGS=-DCMAKE_INSTALL_PREFIX=${installDir}`, 'CMAKE_BUILD_TYPE=RelWithDebug'], opts);

Please add CMAKE_BUILD_TYPE. Otherwise it builds Neovim in debug mode.

Neovim nightly downloads are currently very flaky. This is not caused by
Neovim's build being broken but by the github actions uploading the
build artifacts to github encountering issues.
@rhysd
Copy link
Owner

rhysd commented Oct 1, 2021

Thank you for the updates. Looks good now.

@rhysd rhysd merged commit 4803534 into rhysd:master Oct 1, 2021
@rhysd
Copy link
Owner

rhysd commented Oct 1, 2021

I'll add some small follow up (e.g. add tests)

rhysd added a commit that referenced this pull request Oct 1, 2021
rhysd added a commit that referenced this pull request Oct 1, 2021
I confirmed all fallback logics worked fine by throwing an exception
from `downloadNeovim()` function temporarily. Jobs installing Neovim
nightly on Linux and macOS could fallback to building Neovim from
source.

https://github.com/rhysd/action-setup-vim/runs/3767376843?check_suite_focus=true
@rhysd
Copy link
Owner

rhysd commented Oct 1, 2021

I added tests for this. And I also added the similar logic for macOS. Now it can fallback to building Neovim from source on macOS also.

2acc821

@glacambre
Copy link
Contributor Author

Great, thank you for taking care of all this - I planned on doing it myself but had little time to do it :).

@glacambre glacambre deleted the build_neovim_nightly_on_download_failure branch October 1, 2021 17:37
@rhysd
Copy link
Owner

rhysd commented Oct 2, 2021

This feature was included in new release v1.2.8.

@glacambre
Copy link
Contributor Author

glacambre commented Oct 2, 2021

I can confirm that it works! https://github.com/glacambre/firenvim/pull/1211/checks?check_run_id=3776936017#step:9:15

Thanks a lot for this wonderful action :).

@rhysd
Copy link
Owner

rhysd commented Oct 2, 2021

Yes, Neovim nightly release failed yesterday actually so we can confirm the fallback logic works fine 💯

Julian added a commit to Julian/lean.nvim that referenced this pull request Oct 13, 2021
Julian added a commit to Julian/lean.nvim that referenced this pull request Oct 13, 2021
Julian added a commit to Julian/lean.nvim that referenced this pull request Oct 13, 2021
Julian added a commit to Julian/lean.nvim that referenced this pull request Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants