From 590ed206af995eba1495271571ea59418b2ddc82 Mon Sep 17 00:00:00 2001 From: Wojtek Mach Date: Thu, 15 Jun 2023 12:49:48 +0200 Subject: [PATCH] Standardize Elixir & OTP versions (#1979) --- .github/scripts/app/build_macos.sh | 11 ++++++--- .github/workflows/deploy.yml | 7 +++--- .github/workflows/test.yml | 36 +++++++++++++++++++---------- .github/workflows/uffizzi-build.yml | 8 +++---- docker/build_and_push.sh | 5 ++-- mix.exs | 11 +++++---- versions | 4 ++++ 7 files changed, 52 insertions(+), 30 deletions(-) create mode 100644 versions diff --git a/.github/scripts/app/build_macos.sh b/.github/scripts/app/build_macos.sh index af292f8ed..719318d66 100755 --- a/.github/scripts/app/build_macos.sh +++ b/.github/scripts/app/build_macos.sh @@ -15,6 +15,11 @@ set -euo pipefail main() { + . versions + OTP_VERSION="${OTP_VERSION:-$otp}" + ELIXIR_VERSION="${ELIXIR_VERSION:-$elixir}" + OPENSSL_VERSION="${OPENSSL_VERSION:-$openssl}" + bootstrap_otp download_elixir build_app @@ -23,16 +28,16 @@ main() { bootstrap_otp() { dir=$PWD cd elixirkit/otp_bootstrap - . ./build_macos_universal.sh $OTP_VERSION "1.1.1s" + . ./build_macos_universal.sh "$OTP_VERSION" "$OPENSSL_VERSION" cd $dir } download_elixir() { dir=$PWD - elixir_dir=$PWD/_build/elixir-$ELIXIR_VERSION + elixir_dir=$PWD/_build/elixir-"$ELIXIR_VERSION" if [ ! -d $elixir_dir ]; then - otp_release=$(erl -noshell -eval 'io:format("~s", [erlang:system_info(otp_release)]), halt().') + otp_release=`erl -noshell -eval 'io:format("~s", [erlang:system_info(otp_release)]), halt().'` elixir_zip=v${ELIXIR_VERSION}-otp-${otp_release}.zip url=https://builds.hex.pm/builds/elixir/$elixir_zip echo downloading $url diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 250c277c0..940ee0f8b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -5,9 +5,6 @@ on: - main tags: - "v*.*.*" -env: - otp: "25.3.2" - elixir: "1.15.0-rc.2" jobs: assets: outputs: @@ -15,6 +12,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - run: | + . versions + echo "elixir=$elixir" >> $GITHUB_ENV + echo "otp=$otp" >> $GITHUB_ENV - name: Install Erlang & Elixir uses: erlef/setup-beam@v1 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dfaacd362..07a13ad34 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,16 +4,19 @@ on: push: branches: - main -env: - otp: "25.3.2" - elixir: "1.15.0-rc.2" jobs: main: runs-on: ubuntu-latest env: MIX_ENV: test steps: - - uses: actions/checkout@v3 + - name: Checkout git repo + uses: actions/checkout@v3 + - run: | + . versions + echo "elixir=$elixir" >> $GITHUB_ENV + echo "otp=$otp" >> $GITHUB_ENV + echo "openssl=$openssl" >> $GITHUB_ENV - name: Install Erlang & Elixir uses: erlef/setup-beam@v1 with: @@ -55,13 +58,19 @@ jobs: run: npm test --prefix assets windows: runs-on: windows-latest - if: github.ref == 'refs/heads/main' + if: github.ref_name == 'main' env: MIX_ENV: test steps: - name: Configure Git run: git config --global core.autocrlf input - - uses: actions/checkout@v3 + - name: Checkout git repo + uses: actions/checkout@v3 + - run: | + . versions + echo "elixir=$elixir" >> $GITHUB_ENV + echo "otp=$otp" >> $GITHUB_ENV + echo "openssl=$openssl" >> $GITHUB_ENV - name: Install Erlang & Elixir uses: erlef/setup-beam@v1 with: @@ -93,9 +102,15 @@ jobs: macos: runs-on: macos-latest - if: github.ref == 'refs/heads/main' + if: github.ref_name == 'main' steps: - - uses: actions/checkout@v3 + - name: Checkout git repo + uses: actions/checkout@v3 + - run: | + . versions + echo "elixir=$elixir" >> $GITHUB_ENV + echo "otp=$otp" >> $GITHUB_ENV + echo "openssl=$openssl" >> $GITHUB_ENV - name: Cache Mix Deps uses: actions/cache@v3 with: @@ -104,7 +119,7 @@ jobs: - name: Cache Bootstrap OTP uses: actions/cache@v3 with: - path: elixirkit/otp_bootstrap/_build/otp-rel-${{ env.otp }}-openssl-1.1.1s-macos-universal + path: elixirkit/otp_bootstrap/_build/otp-rel-${{ env.otp }}-openssl-${{ env.openssl }}-macos-universal key: ${{ runner.os }}-bootstrap-${{ env.otp }}-${{ hashFiles('elixirkit/otp_bootstrap/build.sh') }} - name: Cache Elixir uses: actions/cache@v3 @@ -113,6 +128,3 @@ jobs: key: ${{ runner.os }}-elixir-${{ env.elixir }} - name: Build the app run: .github/scripts/app/build_macos.sh - env: - OTP_VERSION: ${{ env.otp }} - ELIXIR_VERSION: ${{ env.elixir }} diff --git a/.github/workflows/uffizzi-build.yml b/.github/workflows/uffizzi-build.yml index 6f9bde96a..a113f5f65 100644 --- a/.github/workflows/uffizzi-build.yml +++ b/.github/workflows/uffizzi-build.yml @@ -3,10 +3,6 @@ on: pull_request: types: [opened, synchronize, reopened, closed] -env: - otp: "25.3.2" - elixir: "1.15.0-rc.2" - jobs: build-application: name: Build PR image @@ -17,6 +13,10 @@ jobs: steps: - name: Checkout git repo uses: actions/checkout@v3 + - run: | + . versions + echo "elixir=$elixir" >> $GITHUB_ENV + echo "otp=$otp" >> $GITHUB_ENV # --- START build assets - name: Install Erlang & Elixir uses: erlef/setup-beam@v1 diff --git a/docker/build_and_push.sh b/docker/build_and_push.sh index eb1d34723..e78dca53a 100755 --- a/docker/build_and_push.sh +++ b/docker/build_and_push.sh @@ -5,14 +5,13 @@ set -ex cd "$(dirname "$0")/.." -elixir="1.15.0-rc.2" -erlang="25.3.2" +. versions ubuntu="focal-20230126" docker buildx build --push --platform linux/amd64,linux/arm64 \ -t ghcr.io/livebook-dev/utils:elixir-cuda11.8 \ --build-arg ELIXIR_VERSION=$elixir \ - --build-arg ERLANG_VERSION=$erlang \ + --build-arg ERLANG_VERSION=$otp \ --build-arg UBUNTU_VERSION=$ubuntu \ --build-arg CUDA_VERSION=11.8.0 \ -f docker/base/elixir-cuda.dockerfile \ diff --git a/mix.exs b/mix.exs index c815578e7..e15ec362b 100644 --- a/mix.exs +++ b/mix.exs @@ -5,9 +5,6 @@ defmodule Livebook.MixProject do @version "0.9.2" @description "Automate code & data workflows with interactive notebooks" - @app_elixir_version "1.15.0-rc.2" - @app_rebar3_version "3.22.0" - def project do [ app: :livebook, @@ -164,12 +161,16 @@ defmodule Livebook.MixProject do @compile {:no_warn_undefined, Standalone} defp standalone_erlang_elixir(release) do + {_, bindings} = Code.eval_file("versions") + elixir_version = bindings[:elixir] + rebar3_version = bindings[:rebar3] + Code.require_file("rel/app/standalone.exs") release |> Standalone.copy_otp() - |> Standalone.copy_elixir(@app_elixir_version) + |> Standalone.copy_elixir(elixir_version) |> Standalone.copy_hex() - |> Standalone.copy_rebar3(@app_rebar3_version) + |> Standalone.copy_rebar3(rebar3_version) end end diff --git a/versions b/versions new file mode 100644 index 000000000..8000f6988 --- /dev/null +++ b/versions @@ -0,0 +1,4 @@ +elixir="1.15.0-rc.2" +otp="25.3.2" +openssl="1.1.1s" +rebar3="3.22.0"