Skip to content

Commit 5abfd23

Browse files
authored
[ci] speed up macos ci and precompile builds (#18)
1 parent 8d7f410 commit 5abfd23

File tree

2 files changed

+90
-17
lines changed

2 files changed

+90
-17
lines changed

.github/workflows/ci.yml

+47-3
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,62 @@ jobs:
6060
runs-on: macos-11
6161
env:
6262
MIX_ENV: test
63+
ELIXIR_VERSION: "1.16.0"
64+
strategy:
65+
matrix:
66+
otp_version: ["25.3.2.8", "26.2.2"]
67+
68+
name: macOS x86_64 - OTP ${{ matrix.otp_version }}
6369

6470
steps:
65-
- uses: actions/checkout@v3
71+
- uses: actions/checkout@v4
72+
73+
- name: Cache OTP
74+
uses: actions/cache@v3
75+
id: cache-otp
76+
with:
77+
path: ./cache/otp
78+
key: ${{ runner.os }}-otp-${{ matrix.otp_version }}
79+
80+
- name: Download OTP
81+
if: steps.cache-otp.outputs.cache-hit != 'true'
82+
run: |
83+
mkdir -p ./cache/otp
84+
curl -fSL https://github.com/cocoa-xu/otp-build/releases/download/v${{ matrix.otp_version }}/otp-x86_64-apple-darwin.tar.gz -o ./cache/otp/otp-v${{ matrix.otp_version }}-x86_64-apple-darwin.tar.gz
85+
cd ./cache/otp
86+
tar -xzf otp-v${{ matrix.otp_version }}-x86_64-apple-darwin.tar.gz
87+
88+
- name: Cache Elixir
89+
id: cache-elixir
90+
uses: actions/cache@v3
91+
with:
92+
path: ./cache/elixir
93+
key: ${{ runner.os }}-elixir-${{ env.ELIXIR_VERSION }}
94+
95+
- name: Download and Compile Elixir
96+
if: steps.cache-elixir.outputs.cache-hit != 'true'
97+
run: |
98+
export PATH=$(pwd)/./cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ env.ELIXIR_VERSION }}/bin:${PATH}
99+
export ERL_ROOTDIR=$(pwd)/./cache/otp/usr/local/lib/erlang
100+
mkdir -p ./cache/elixir
101+
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
102+
cd ./cache/elixir
103+
tar -xzf elixir-${{ env.ELIXIR_VERSION }}.tar.gz
104+
cd elixir-${{ env.ELIXIR_VERSION }}
105+
make -j$(sysctl -n hw.ncpu) install
66106
67-
- name: macOS setup
107+
- name: Install Mix and Rebar
68108
run: |
69-
brew install erlang elixir
109+
export PATH=$(pwd)/./cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ env.ELIXIR_VERSION }}/bin:${PATH}
110+
export ERL_ROOTDIR=$(pwd)/./cache/otp/usr/local/lib/erlang
70111
mix local.hex --force
71112
mix local.rebar --force
72113
73114
- name: Compile and Test
74115
run: |
116+
export PATH=$(pwd)/./cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ env.ELIXIR_VERSION }}/bin:${PATH}
117+
export ERL_ROOTDIR=$(pwd)/./cache/otp/usr/local/lib/erlang
118+
75119
mix deps.get
76120
mix elixir_make.precompile
77121
mix test

.github/workflows/precompile.yml

+43-14
Original file line numberDiff line numberDiff line change
@@ -58,33 +58,62 @@ jobs:
5858
runs-on: macos-11
5959
env:
6060
MIX_ENV: prod
61-
elixir_version: "1.15.2"
61+
ELIXIR_VERSION: "1.16.0"
6262
strategy:
6363
matrix:
64-
otp_version: ["25.3.2.3", "26.0.2"]
64+
otp_version: ["25.3.2.8", "26.2.2"]
6565

6666
name: macOS - OTP ${{ matrix.otp_version }}
6767

6868
steps:
69-
- uses: actions/checkout@v3
69+
- uses: actions/checkout@v4
70+
71+
- name: Cache OTP
72+
uses: actions/cache@v3
73+
id: cache-otp
74+
with:
75+
path: ./cache/otp
76+
key: ${{ runner.os }}-otp-${{ matrix.otp_version }}
7077

71-
- name: Install erlang and elixir
78+
- name: Download OTP
79+
if: steps.cache-otp.outputs.cache-hit != 'true'
7280
run: |
73-
brew install autoconf coreutils curl git openssl asdf
74-
asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git
75-
asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git
76-
export KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac"
77-
asdf install erlang ${{ matrix.otp_version }}
78-
asdf install elixir ${{ env.elixir_version }}
79-
asdf global erlang ${{ matrix.otp_version }}
80-
asdf global elixir ${{ env.elixir_version }}
81-
source $(brew --prefix asdf)/libexec/asdf.sh
81+
mkdir -p ./cache/otp
82+
curl -fSL https://github.com/cocoa-xu/otp-build/releases/download/v${{ matrix.otp_version }}/otp-x86_64-apple-darwin.tar.gz -o ./cache/otp/otp-v${{ matrix.otp_version }}-x86_64-apple-darwin.tar.gz
83+
cd ./cache/otp
84+
tar -xzf otp-v${{ matrix.otp_version }}-x86_64-apple-darwin.tar.gz
85+
86+
- name: Cache Elixir
87+
id: cache-elixir
88+
uses: actions/cache@v3
89+
with:
90+
path: ./cache/elixir
91+
key: ${{ runner.os }}-elixir-${{ env.ELIXIR_VERSION }}
92+
93+
- name: Download and Compile Elixir
94+
if: steps.cache-elixir.outputs.cache-hit != 'true'
95+
run: |
96+
export PATH=$(pwd)/./cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ env.ELIXIR_VERSION }}/bin:${PATH}
97+
export ERL_ROOTDIR=$(pwd)/./cache/otp/usr/local/lib/erlang
98+
mkdir -p ./cache/elixir
99+
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
100+
cd ./cache/elixir
101+
tar -xzf elixir-${{ env.ELIXIR_VERSION }}.tar.gz
102+
cd elixir-${{ env.ELIXIR_VERSION }}
103+
make -j$(sysctl -n hw.ncpu) install
104+
105+
- name: Install Mix and Rebar
106+
run: |
107+
export PATH=$(pwd)/./cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ env.ELIXIR_VERSION }}/bin:${PATH}
108+
export ERL_ROOTDIR=$(pwd)/./cache/otp/usr/local/lib/erlang
82109
mix local.hex --force
83110
mix local.rebar --force
84111
85112
- name: Precompile
86113
run: |
87-
source $(brew --prefix asdf)/libexec/asdf.sh
114+
export PATH=$(pwd)/./cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ env.ELIXIR_VERSION }}/bin:${PATH}
115+
export ERL_ROOTDIR=$(pwd)/./cache/otp/usr/local/lib/erlang
116+
88117
export ELIXIR_MAKE_CACHE_DIR=$(pwd)/cache
89118
mkdir -p "${ELIXIR_MAKE_CACHE_DIR}"
90119
mix deps.get

0 commit comments

Comments
 (0)