Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Add Rust support #477

Merged
merged 27 commits into from
Dec 7, 2020
Merged

Add Rust support #477

merged 27 commits into from
Dec 7, 2020

Conversation

cecton
Copy link
Contributor

@cecton cecton commented Oct 1, 2020

Hello @fool

I just started recently a new OSS project supported by Netlify: https://yewprint.rm.rs (https://github.com/cecton/yewprint) which got approved today 🎉

I'm using Rust and the build time is not short (I don't really mind personally) but I still have build time limit for the sponsored OSS account. So here I am checking if I can help getting Rust support to the Netlify image.

There was already a PR (#320) but it seems to have been closed because of lack of attention. I want to bring this back to life and add wasm-pack and wasm-bindgen support (I suppose everybody who does Rust on Netlify are here to use WASM).

Mandatory gif:

it's-alive-gif

cc @jamen @JeanBarriere @ultrasaurus

Tasks:

  • Bring it back to life
  • Update
  • Add wasm-pack and wasm-bindgen

Closes #293
Related to #320
Blocked by #476

@cecton
Copy link
Contributor Author

cecton commented Oct 3, 2020

I can't even build the branch xenial locally. There is already an issue #476

\e[1mdownloading: wasmer-linux-amd64
Latest release: 1.0.0-alpha3
Downloading archive from https://github.com/wasmerio/wasmer/releases/download/1.0.0-alpha3/wasmer-linux-amd64.tar.gz
######################################################################## 100.0%
\e[1minstalling: /opt/buildhome/.wasmer
Updating bash profile /opt/buildhome/.profile
we've added the following to your /opt/buildhome/.profile
If you have a different profile please add the following:
\e[2m
# Wasmer
export WASMER_DIR="/opt/buildhome/.wasmer"
[ -s "$WASMER_DIR/wasmer.sh" ] && source "$WASMER_DIR/wasmer.sh"
/opt/buildhome/.wasmer/bin/wasmer: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.27' not found (required by /opt/buildhome/.wasmer/bin/wasmer)
\e[1merror: wasmer was installed, but doesn't seem to be working :(
The command '/bin/sh -c curl https://get.wasmer.io -sSfL | sh' returned a non-zero code: 1
[1] [10:41:40] ~/r/build-image xenial > 

@calavera
Copy link
Contributor

calavera commented Oct 3, 2020

Hi @cecton. It might be easier for you to wait until we release #474.

We've tested it already successfully, but we're hosting a conference next week and we want to give ourselves some time to validate it widely. It should not be more than a matter of a few weeks.

@cecton
Copy link
Contributor Author

cecton commented Oct 3, 2020

Hello 👋

Yes that was my intention! When the issue will be fixed I will complete the PR with wasm-pack and test on my own repo.

Also we might want to fix the version of Rust to avoid the same issue than wasmer.

Thanks a lot for the answer

@cecton
Copy link
Contributor Author

cecton commented Oct 4, 2020

Also we might want to fix the version of Rust to avoid the same issue than wasmer.

We actually don't need to. rustup ensures rustc is compiled for glibc 2.11+ (64-bit Linux (kernel 2.6.32+, glibc 2.11+)). See https://doc.rust-lang.org/nightly/rustc/platform-support.html

So we can just install rust stable with rustup

run-build-functions.sh Outdated Show resolved Hide resolved
run-build-functions.sh Outdated Show resolved Hide resolved
@@ -39,4 +39,6 @@ echo "Executing user command: $cmd"
eval "$cmd"
CODE=$?

cache_artifacts
Copy link
Member

Choose a reason for hiding this comment

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

why are you adding this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know, I'm not the author. Should I remove it?

Copy link
Member

Choose a reason for hiding this comment

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

yeah, i'd remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e4e7354

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah funny I have re-added this!

I know why the author added this. It's because when you run the test, the cache is restored (by install_dependencies in line 29) but it is not saved after the job.

@@ -55,11 +55,19 @@ mkdir -p $NETLIFY_CACHE_DIR/.composer
mkdir -p $NETLIFY_CACHE_DIR/.gimme_cache/gopath
mkdir -p $NETLIFY_CACHE_DIR/.gimme_cache/gocache
mkdir -p $NETLIFY_CACHE_DIR/.wasmer/cache
mkdir -p $NETLIFY_CACHE_DIR/.cargo/registry
mkdir -p $NETLIFY_CACHE_DIR/repo/target
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should be replaced by:

 mkdir -p $NETLIFY_REPO_DIR/target 

Copy link
Member

Choose a reason for hiding this comment

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

i think it can be removed entirely. cargo will create target if it doesn't exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 5cd8e76

run-build-functions.sh Outdated Show resolved Hide resolved
@calavera calavera added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Nov 5, 2020
@mraerino
Copy link
Member

mraerino commented Dec 3, 2020

or you merge master in which won't require re-approval

@cecton
Copy link
Contributor Author

cecton commented Dec 4, 2020

i think this looks great!

would you want to test this on a netlify site before we merge? i can internally set this as the build image for any site you want, you'd just have to give me a site name or id

Sure! Can you do it on yewprint? https://github.com/cecton/yewprint

The build should be fixed on master now. Unfortunately, you'll have to rebase this branch to get it green @cecton

or you merge master in which won't require re-approval

I use a merge workflow. It's fixed.

✔️ CI is green! cc @calavera @mraerino

@mraerino
Copy link
Member

mraerino commented Dec 4, 2020

@cecton I updated your site to run with this PR. let us know if it works for you 🙂

@cecton
Copy link
Contributor Author

cecton commented Dec 4, 2020

I tested, works like a charm @mraerino 👌

@mraerino
Copy link
Member

mraerino commented Dec 4, 2020

the team that owns the build process will give this a final look and likely release it next week. in the meantime i'll leave your site configured to use it and will switch it to the regular image once we rolled this.

@cecton
Copy link
Contributor Author

cecton commented Dec 4, 2020

the team that owns the build process will give this a final look and likely release it next week. in the meantime i'll leave your site configured to use it and will switch it to the regular image once we rolled this.

Thanks! But don't worry about that because I'm stuck with manual deployment for a little longer because of some other issues. You can change it back now if that makes your life easier @mraerino

@vbrown608
Copy link
Contributor

vbrown608 commented Dec 4, 2020

Thanks for your contribution! The changes to the image and install script look good to me. Could you update the Languages section of the included software doc? https://github.com/netlify/build-image/blob/xenial/included_software.md#languages. For the version you can say Not installed by default.

(I think Languages makes more sense than Included Software, since we don't list rvm, nvm, etc. there, but open to other ideas on this.)

We're planning to automate this (#441) but in the meantime I'm going to be the bot and note the image size change, which looks reasonable:

$ docker image inspect cecton-rust:latest --format='{{.Size}}'
4427251610
$ docker image inspect netlify/build:xenial --format='{{.Size}}'
4398783842

@rstavchansky I believe we'll also need a change to https://docs.netlify.com/configure-builds/manage-dependencies/#dependency-cache, though I don't think it needs to block merging this PR and it might even be better to run it in production as an alpha for a while before adding it to the docs site. Adding the needs docs label.

@cecton cecton dismissed stale reviews from mraerino and calavera via 7f1e907 December 5, 2020 14:25
@cecton
Copy link
Contributor Author

cecton commented Dec 5, 2020

Could you update the Languages section of the included software doc? https://github.com/netlify/build-image/blob/xenial/included_software.md#languages. For the version you can say Not installed by default.

Done

(I think Languages makes more sense than Included Software, since we don't list rvm, nvm, etc. there, but open to other ideas on this.)

Fair enough

Copy link
Contributor

@vbrown608 vbrown608 left a comment

Choose a reason for hiding this comment

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

Looks good 🦀 ! We'll include this in the next release of the build image and make a note here when it's live. Thanks again for your work on this.

@vbrown608 vbrown608 merged commit 53b83b6 into netlify:xenial Dec 7, 2020
@vbrown608
Copy link
Contributor

This is live in our Xenial build image 👍

@mraerino
Copy link
Member

mraerino commented Dec 9, 2020

@cecton i reset the build image on your site. let me know if there is anything amiss.

hawkw pushed a commit to tokio-rs/tracing that referenced this pull request Dec 10, 2020
## Motivation

At Netlify we recently introduced native Rust support in the build
system: netlify/build-image#477

## Solution

This PR cleans up the Netlify build config to use a more
straight-forward way of building rust docs.

This also introduces a workaround for
netlify/build-image#505

## Kudos

We're big fans of the `tracing` crate at Netlify and using it for many
new systems recently. Very happy we can give something back!

Closes #1130
hawkw pushed a commit to tokio-rs/tracing that referenced this pull request Dec 14, 2020
## Motivation

At Netlify we recently introduced native Rust support in the build
system: netlify/build-image#477

## Solution

This PR cleans up the Netlify build config to use a more
straight-forward way of building rust docs.

This also introduces a workaround for
netlify/build-image#505

## Kudos

We're big fans of the `tracing` crate at Netlify and using it for many
new systems recently. Very happy we can give something back!

Closes #1130
hawkw pushed a commit to tokio-rs/tracing that referenced this pull request Dec 14, 2020
## Motivation

At Netlify we recently introduced native Rust support in the build
system: netlify/build-image#477

## Solution

This PR cleans up the Netlify build config to use a more
straight-forward way of building rust docs.

This also introduces a workaround for
netlify/build-image#505

## Kudos

We're big fans of the `tracing` crate at Netlify and using it for many
new systems recently. Very happy we can give something back!

Closes #1130
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs docs type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Rust to build-image
5 participants