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

WIP: New build system #3529

Merged
merged 27 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0a0b0f7
WIP: Save progress
Sep 17, 2023
c272236
Add support for quicktest
Sep 18, 2023
1e54447
Save work
Sep 18, 2023
03bb7bf
WIP: VSCode devcontainer setup
Sep 20, 2023
ff89a6f
Add VSCode devcontainer + fix various errors
Sep 21, 2023
0e2a766
Add extebsion to the devcontainer + workaround dsm installation script
Sep 22, 2023
c7f2e49
Port integration tests
Sep 22, 2023
b401006
Fix standalone tests
Sep 24, 2023
1eb6288
Split Standalone tests into their own category
Sep 25, 2023
2184f85
Move compiled destination from build to temp
Sep 26, 2023
9de9643
Move files from build2 to build folder
Sep 26, 2023
f2b1c3c
Fixes following move from build to temp folder
Sep 26, 2023
9ff366e
Fix Fable.sln
Sep 26, 2023
4dbd727
Publish tasks + simplify fsproj version handling
Sep 27, 2023
ef570fe
Expose some env form the host and restore tools when attaching to the…
Sep 28, 2023
de634d4
Add GithubRelease to the build process + follow naming convention fro…
Sep 28, 2023
6601cf9
Remove ported code from build.fsx
Sep 28, 2023
b221135
Use more explicit name for the flags + update Github workflow
Sep 28, 2023
c46259a
Fix devcontainer post attach command
Sep 28, 2023
c9b2ea9
Fix running tests on a fresh workspace + try to debug rust workflow f…
Sep 28, 2023
97e70de
Fix TypeScript tests target + try fix Rust
Sep 28, 2023
df3adb1
Fix standalone fable-library folder for local test
Sep 28, 2023
31d2af8
Try running rust tests in sequence
Sep 28, 2023
780468c
Fix casing of Cargo.toml
Sep 28, 2023
145ebd0
Update instruction in the README.md
Sep 28, 2023
7d25c60
Improve error message when fable-library is not build. I got hit by i…
Sep 28, 2023
bd1fb50
Clean VSCode tasks + add new tasks & launch configuation
Sep 29, 2023
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
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"version": 1,
"isRoot": true,
"tools": {
"fantomas-tool": {
"version": "4.7.9",
"fantomas": {
"version": "6.2.0",
"commands": [
"fantomas"
]
Expand Down
106 changes: 106 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# We use a custom dev container for Fable, because we want to be able to
# control the version of each target language we use.
# This also allow to have a consistent development environment for
# contributors and avoid problems like having some tools not compilable
# because of .NET specificities on OSX ARM for example.

# To debug this DockerFile, you can use the following commands:
#
# Should be run from the .devcontainer folder
#
# Build the docker file with the fable-dev tag
# docker build --tag fable-dev .
# or if you want to see the progress (useful for debugging)
# docker build --tag fable-dev . --progress=plain
#
# Run the docker file and delete it on exit:
# docker run -it --rm fable-dev

# Use x86_64 architecture to avoid all the small pains
# coming from alpine over ARM --platform=linux/amd64
FROM mcr.microsoft.com/devcontainers/base:debian
# Install the xz-utils package
RUN apt-get update && apt-get install -y xz-utils

# Options
# Let it here to avoid conflicts with Microsoft options !!!
ARG DOTNET_VERSION=6.0.406
ARG NODE_VERSION=18.8.0
ARG PYTHON_VERSION=3.11.5
ARG DART_VERSION=3.1.2

USER vscode

# Change the default shell to zsh
SHELL ["/bin/zsh", "-c"]

# # Install .NET
WORKDIR /home/vscode
RUN sudo apt install wget
RUN wget -qO- https://dot.net/v1/dotnet-install.sh | bash -s - --version $DOTNET_VERSION
RUN echo "# Load dotnet path" >> .zshrc
RUN echo "export PATH=$PATH:/home/vscode/.dotnet" >> .zshrc
# Trigger the dotnet first run experience by running a command
RUN source .zshrc && dotnet --help
# Add dotnet zsh completion
COPY scripts/zsh_dotnet_completion.sh /home/vscode/zsh_dotnet_completion.sh
RUN cat /home/vscode/zsh_dotnet_completion.sh >> .zshrc
RUN rm /home/vscode/zsh_dotnet_completion.sh

# Install Node.js
RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
# Even, if we changed the default shell to ZSH, nvm install script
# still uses bash, so we manually need to add the nvm path to zsh
RUN echo "# Load nvm path" >> .zshrc
RUN echo 'export NVM_DIR="$HOME/.nvm"' >> .zshrc
RUN echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm' >> .zshrc
RUN echo '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion"' >> .zshrc
# We need to source the zshrc and execute nvm install in the same RUN command
# Otherwise, the nvm command will not be available
RUN source .zshrc && nvm install $NODE_VERSION

# Install python
# Install Python build dependencies
RUN sudo apt-get install -y build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
# Install pyenv
RUN curl https://pyenv.run | bash
RUN echo "# Load pyenv path" >> .zshrc
RUN echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
RUN echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
RUN echo 'eval "$(pyenv init -)"' >> ~/.zshrc
RUN source .zshrc && pyenv install $PYTHON_VERSION
# Make python point to the installed version
RUN source .zshrc && pyenv global $PYTHON_VERSION
RUN source .zshrc && curl -sSL https://install.python-poetry.org | python
RUN echo "# Load poetry path" >> .zshrc
RUN echo 'export PATH="$HOME/.local/bin:$PATH"' >> .zshrc

# Install rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s - -y
RUN echo "# Load rust path" >> .zshrc
RUN echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> .zshrc

# Instal dart
# Use custom dsm install script, because we broke it while
# trying to fix another issue with dsm
# See https://github.com/Yakiyo/dsm/issues/26
COPY scripts/install_dsm.sh /home/vscode/install_dsm.sh
RUN sudo chmod +x /home/vscode/install_dsm.sh
RUN /home/vscode/install_dsm.sh
# RUN curl -fsSL https://dsm-vm.vercel.app/install.sh | bash
RUN echo "# Load dart path" >> .zshrc
RUN echo 'export PATH="/home/vscode/.dsm:$PATH"' >> .zshrc
RUN echo 'eval "`dsm env zsh`"' >> .zshrc
# Workaround dsm bug (see script for more details)
COPY scripts/install_dart.sh /home/vscode/install_dart.sh
RUN sudo chmod +x /home/vscode/install_dart.sh
RUN source .zshrc && /home/vscode/install_dart.sh $DART_VERSION
RUN source .zshrc && dsm use $DART_VERSION
RUN rm /home/vscode/install_dsm.sh
RUN rm /home/vscode/install_dart.sh

# Force docker to load the zsh profile
# This should be the last steps
CMD [ "/bin/zsh" ]
72 changes: 72 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-outside-of-docker
{
"name": "Docker outside of Docker",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
// "image": "mcr.microsoft.com/devcontainers/base:bullseye",
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"extensions": [
"Ionide.Ionide-fsharp",
"adpyke.codesnap",
"Dart-Code.dart-code",
"EditorConfig.EditorConfig",
"GitHub.copilot",
"christian-kohler.npm-intellisense",
"ionutvmi.path-autocomplete",
"ms-python.vscode-pylance",
"rust-lang.rust-analyzer",
"tintoy.msbuild-project-tools",
"eamodio.gitlens",
"tamasfe.even-better-toml"
],
"settings": {
"terminal.integrated.defaultProfile.linux": "zsh",
// I don't know why but Ionide and C# extension don't find
// the installed dotnet version.
// For Ionide, we guide it using the following setting
"FSharp.dotnetRoot": "/home/vscode/.dotnet",
// For C#, we disable the warning as we don't seems to need it.
// If this is a problem, we can probably use the C#/F# dockerfile
// as the base and keep our way to install the different target version
// .NET included to respect the global.json requirements
"csharp.suppressDotnetInstallWarning": true
}
}
},

"mounts": [
// Mount .npmrc from the host machine, to be able to use the host session
// This allow the user to login on their own machine once and not each time
// they build a new devcontainer
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.npmrc,target=/home/vscode/.npmrc,type=bind,consistency=cached"
],

"containerEnv": {
// Expose the local environment variable to the container
// They are used for releasing and publishing from the container
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}",
"FABLE_NUGET_KEY": "${localEnv:FABLE_NUGET_KEY}"
},

// Restore the dotnet tools when the container is attached
// This makes fanomas available directly without having the user needing to
// run `dotnet tool restore` or build the project once
"postAttachCommand": "/bin/zsh -c 'source ~/.zshrc && dotnet tool restore'"

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "docker --version",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root",

}
11 changes: 11 additions & 0 deletions .devcontainer/scripts/install_dart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/zsh

# dsm seems to incorrectly detect the architecture on Mac M1
# The if statement below is a workaround for this issue
# See https://github.com/Yakiyo/dsm/issues/26

if [[ $(uname -m) == 'aarch64' ]]; then
dsm install --arch arm64 $1;
else
dsm install $1;
fi
191 changes: 191 additions & 0 deletions .devcontainer/scripts/install_dsm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
#!/bin/bash

# set -e

OS=$(echo `uname -s`|tr '[:upper:]' '[:lower:]')

case "$OS" in
mingw*) OS='windows';;
msys*) OS='windows';;
esac

VERSION="latest"
INSTALL_DIR="$HOME/.dsm"
FILE=""

# TODO: Implement this
show_help() {
echo "dsm installation script"
echo ""
echo "USAGE:"
echo " ./install.sh [OPTIONS]"
echo ""
echo "OPTIONS:"
echo " -d, --install-dir Directory to install to."
echo " -s, --skip-shell Skip shell setup"
echo " -v, --version The version of dsm to install"
echo " -F, --filename Manually override the filename of dsm to use."
echo ""
echo "For any queries, help or bug, please open an issue at https://github.com/Yakiyo/dsm/issues"

exit 0
}

clap() {
while [[ $# -gt 0 ]]; do
key="$1"

case $key in
-h | --help)
show_help
;;
-d | --install-dir)
INSTALL_DIR="$2"
shift
shift
;;
-s | --skip-shell)
SKIP_SHELL="true"
shift
;;
-v | --version)
VERSION="v$2"
shift
shift
;;
-F | --filename)
FILENAME="$2"
shift
shift
;;
*)
echo "Unrecognized argument $key. Use the `--help` flag to see usage"
exit 1
;;
esac
done
}

# Duct taped this to somewhat work
filename() {
if [ "$OS" = "linux" ]; then
case "$(uname -m)" in
arm | armv7*)
FILENAME="arm-unknown-linux-gnueabihf"
;;
*)
FILENAME="x86_64-unknown-linux-musl"
esac
elif [ "$OS" = "darwin" ]; then
FILENAME="x86_64-apple-darwin"
elif [ "$OS" = "windows" ]; then
FILENAME="x86_64-pc-windows-msvc.exe"
else
echo "OS $OS is not supported."
echo "If you think that's a bug - please file an issue to https://github.com/Yakiyo/dsm/issues"
exit 1
fi
FILE="dsm-$FILENAME"
}

download () {
if [ "$VERSION" = "latest" ]; then
URL="https://github.com/Yakiyo/dsm/releases/latest/download/$FILE"
else
URL="https://github.com/Yakiyo/dsm/releases/download/$VERSION/$FILE"
fi
echo "Downloading from $URL ...."

TMP=$(mktemp -d)
mkdir -p "$INSTALL_DIR" &>/dev/null

if ! curl --progress-bar --fail -L "$URL" -o "$TMP/$FILE"; then
echo "Download failed. Check that the release/filename are correct."
exit 1
fi

EXE=""
if [ "$OS" = "windows" ]; then
EXE=".exe"
fi

mv "$TMP/$FILE" "$INSTALL_DIR/dsm$EXE"

chmod u+x "$INSTALL_DIR/dsm$EXE"
}

ensure_dir () {
local CONTAINING_DIR
CONTAINING_DIR="$(dirname "$1")"
if [ ! -d "$CONTAINING_DIR" ]; then
echo " >> Creating directory $CONTAINING_DIR"
mkdir -p "$CONTAINING_DIR"
fi
}

# Courtesy of https://github.com/Schniz/fnm/blob/master/.ci/install.sh
setup_shell() {
CURRENT_SHELL="$(basename "$SHELL")"

if [ "$CURRENT_SHELL" = "zsh" ]; then
CONF_FILE=${ZDOTDIR:-$HOME}/.zshrc
ensure_dir "$CONF_FILE"
echo "Installing for Zsh. Appending the following to $CONF_FILE:"
echo ""
echo ' # dsm'
echo ' export PATH="'"$INSTALL_DIR"':$PATH"'
echo ' eval "`dsm env zsh`"'

echo '' >>$CONF_FILE
echo '# dsm' >>$CONF_FILE
echo 'export PATH="'$INSTALL_DIR':$PATH"' >>$CONF_FILE
echo 'eval "`dsm env zsh`"' >>$CONF_FILE

elif [ "$CURRENT_SHELL" = "fish" ]; then
CONF_FILE=$HOME/.config/fish/conf.d/dsm.fish
ensure_dir "$CONF_FILE"
echo "Installing for Fish. Appending the following to $CONF_FILE:"
echo ""
echo ' # dsm'
echo ' set PATH "'"$INSTALL_DIR"'" $PATH'
echo ' dsm env fish | source'

echo '# dsm' >>$CONF_FILE
echo 'set PATH "'"$INSTALL_DIR"'" $PATH' >>$CONF_FILE
echo 'dsm env fish | source' >>$CONF_FILE

elif [ "$CURRENT_SHELL" = "bash" ]; then
if [ "$OS" = "darwin" ]; then
CONF_FILE=$HOME/.profile
else
CONF_FILE=$HOME/.bashrc
fi
ensure_dir "$CONF_FILE"
echo "Installing for Bash. Appending the following to $CONF_FILE:"
echo ""
echo ' # dsm'
echo ' export PATH="'"$INSTALL_DIR"':$PATH"'
echo ' eval "`dsm env bash`"'

echo '' >>$CONF_FILE
echo '# dsm' >>$CONF_FILE
echo 'export PATH="'"$INSTALL_DIR"':$PATH"' >>$CONF_FILE
echo 'eval "`dsm env bash`"' >>$CONF_FILE

else
echo "Could not infer shell type. Please set up manually."
exit 1
fi

echo ""
echo "In order to apply the changes, open a new terminal or run the following command:"
echo ""
echo " source $CONF_FILE"
}

filename
clap "$@"
download
if [ "$SKIP_SHELL" != "true" ]; then
setup_shell
fi
Loading
Loading