Skip to content

Commit

Permalink
chore(ci): use installer from elixir-lang.org
Browse files Browse the repository at this point in the history
Signed-off-by: Cocoa <i@uwucocoa.moe>
  • Loading branch information
cocoa-xu committed Feb 10, 2025
1 parent f16d86e commit 40d47e7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 70 deletions.
49 changes: 9 additions & 40 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,52 +77,21 @@ jobs:
ELIXIR_VERSION: "1.15.7"

steps:
- uses: actions/checkout@v4

- name: Cache OTP
uses: actions/cache@v4
id: cache-otp
with:
path: ./cache/otp
key: ${{ runner.os }}-otp-${{ env.OTP_VERSION }}
- name: Checkout
uses: actions/checkout@v4

- name: Download OTP
if: steps.cache-otp.outputs.cache-hit != 'true'
- name: Install OTP and Elixir
run: |
mkdir -p ./cache/otp
curl -fSL https://github.com/cocoa-xu/otp-build/releases/download/v${{ env.OTP_VERSION }}/otp-x86_64-apple-darwin.tar.gz -o ./cache/otp/otp-v${{ env.OTP_VERSION }}-x86_64-apple-darwin.tar.gz
cd ./cache/otp
tar -xzf otp-v${{ env.OTP_VERSION }}-x86_64-apple-darwin.tar.gz
- name: Cache Elixir
id: cache-elixir
uses: actions/cache@v4
with:
path: ./cache/elixir
key: ${{ runner.os }}-elixir-${{ env.ELIXIR_VERSION }}
curl -fsSO https://elixir-lang.org/install.sh
sh install.sh "elixir@${ELIXIR_VERSION}" "otp@${OTP_VERSION}"
- name: Download and Compile Elixir
if: steps.cache-elixir.outputs.cache-hit != 'true'
- name: Compile and Test
run: |
export PATH=$(pwd)/./cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ env.ELIXIR_VERSION }}/bin:${PATH}
export ERL_ROOTDIR=$(pwd)/./cache/otp/usr/local/lib/erlang
mkdir -p ./cache/elixir
curl -fSL https://github.com/elixir-lang/elixir/archive/refs/tags/v${{ env.ELIXIR_VERSION }}.tar.gz -o ./cache/elixir/elixir-${{ env.ELIXIR_VERSION }}.tar.gz
cd ./cache/elixir
tar -xzf elixir-${{ env.ELIXIR_VERSION }}.tar.gz
cd elixir-${{ env.ELIXIR_VERSION }}
make -j$(sysctl -n hw.ncpu) install
export OTP_MAIN_VER="${OTP_VERSION%%.*}"
export PATH=$HOME/.elixir-install/installs/otp/${OTP_VERSION}/bin:$PATH
export PATH=$HOME/.elixir-install/installs/elixir/${ELIXIR_VERSION}-otp-${OTP_MAIN_VER}/bin:$PATH
- name: macOS setup
run: |
export PATH=$(pwd)/./cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ env.ELIXIR_VERSION }}/bin:${PATH}
export ERL_ROOTDIR=$(pwd)/./cache/otp/usr/local/lib/erlang
mix local.hex --force
mix local.rebar --force
- name: Compile and Test
run: |
export PATH=$(pwd)/./cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ env.ELIXIR_VERSION }}/bin:${PATH}
export ERL_ROOTDIR=$(pwd)/./cache/otp/usr/local/lib/erlang
mix deps.get
mix test --exclude postgresql
43 changes: 13 additions & 30 deletions .github/workflows/precompile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,48 +57,31 @@ jobs:
runs-on: macos-13
env:
MIX_ENV: prod
elixir_version: "1.16.2"
strategy:
matrix:
job:
- { otp_version: "25.3.2.8", elixir: "1.16.2" }
ELIXIR_VERSION: "1.16.2"
OTP_VERSION: "25.3.2.8"

name: macOS - OTP ${{ matrix.job.otp_version }}
name: macOS

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install erlang and elixir
- name: Install OTP and Elixir
run: |
export ROOT_DIR=$(pwd)
mkdir -p ./cache/otp
curl -fSL https://github.com/cocoa-xu/otp-build/releases/download/v${{ matrix.job.otp_version }}/otp-x86_64-apple-darwin.tar.gz -o ./cache/otp/otp-v${{ matrix.job.otp_version }}-x86_64-apple-darwin.tar.gz
cd ./cache/otp
tar -xzf otp-v${{ matrix.job.otp_version }}-x86_64-apple-darwin.tar.gz
cd ${ROOT_DIR}
export PATH=$(pwd)/cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ matrix.job.elixir }}/bin:${PATH}
export ERL_ROOTDIR=$(pwd)/cache/otp/usr/local/lib/erlang
mkdir -p ./cache/elixir
curl -fSL https://github.com/elixir-lang/elixir/archive/refs/tags/v${{ matrix.job.elixir }}.tar.gz -o ./cache/elixir/elixir-${{ matrix.job.elixir }}.tar.gz
cd ./cache/elixir
tar -xzf elixir-${{ matrix.job.elixir }}.tar.gz
cd elixir-${{ matrix.job.elixir }}
make compile
make -j$(sysctl -n hw.ncpu) install
mix local.hex --force
mix local.rebar --force
curl -fsSO https://elixir-lang.org/install.sh
sh install.sh "elixir@${ELIXIR_VERSION}" "otp@${OTP_VERSION}"
- name: Precompile
run: |
export PATH=$(pwd)/cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ matrix.job.elixir }}/bin:${PATH}
export ERL_ROOTDIR=$(pwd)/cache/otp/usr/local/lib/erlang
export OTP_MAIN_VER="${OTP_VERSION%%.*}"
export PATH=$HOME/.elixir-install/installs/otp/${OTP_VERSION}/bin:$PATH
export PATH=$HOME/.elixir-install/installs/elixir/${ELIXIR_VERSION}-otp-${OTP_MAIN_VER}/bin:$PATH
export ELIXIR_MAKE_CACHE_DIR=$(pwd)/cache
mkdir -p "${ELIXIR_MAKE_CACHE_DIR}"
mix local.hex --force
mix local.rebar --force
mix deps.get
mix elixir_make.precompile
Expand Down

0 comments on commit 40d47e7

Please sign in to comment.