Skip to content

Commit

Permalink
[ci-macos] improve ci speed by using precompiled Erlang
Browse files Browse the repository at this point in the history
  • Loading branch information
cocoa-xu committed Jan 6, 2024
1 parent 4cec86a commit 3e6ebdc
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,56 @@ jobs:
runs-on: macos-11
env:
MIX_ENV: test
OTP_VERSION: "26.2.1"
ELIXIR_VERSION: "1.15.7"

steps:
- uses: actions/checkout@v3

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

- name: Download OTP
if: steps.cache-otp.outputs.cache-hit != 'true'
run: |
mkdir -p ./cache/otp
curl -fSL https://cocoa.build/otp/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@v3
with:
path: ./cache/elixir
key: ${{ runner.os }}-elixir-${{ env.ELIXIR_VERSION }}

- name: Download and Compile Elixir
if: steps.cache-elixir.outputs.cache-hit != 'true'
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
- name: macOS setup
run: |
brew install erlang elixir
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

0 comments on commit 3e6ebdc

Please sign in to comment.