-
Notifications
You must be signed in to change notification settings - Fork 8
148 lines (139 loc) · 5.26 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Build precompiled NIFs
on:
push:
branches:
- main
tags:
- "*"
pull_request:
branches: ["main"]
paths-ignore:
- "*.md"
- "**/*.md"
- "LICENSE*"
concurrency:
group: precompiled-${{ github.ref }}
cancel-in-progress: true
env:
PRE_BUILT_RELEASE_GITHUB_TOKEN: ${{ secrets.PRE_BUILT_RELEASE_GITHUB_TOKEN }}
jobs:
generate_id:
name: Generate ID of release
runs-on: ubuntu-latest
outputs:
formatted_date: ${{ steps.date.outputs.formatted_date }}
steps:
- name: Get current date
id: date
run: echo "formatted_date=$(date +'%Y-%m-%d-%H%M')" >> $GITHUB_OUTPUT
build_release:
needs: [generate_id]
name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
nif: ["2.16"]
job:
- { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04 }
steps:
- uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: "1.14.0" # Define the elixir version [required]
otp-version: "24.1" # Define the OTP version [required]
- name: Set up Zig
uses: goto-bus-stop/setup-zig@v1
with:
version: 0.11.0
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Install dependencies
run: mix deps.get
- uses: seanmiddleditch/gha-setup-ninja@master
- name: Install pre-build LLVM
run: |
python3 -m pip install -r dev-requirements.txt
echo "LLVM_CONFIG_PATH=$(python3 -c 'import mlir;print(mlir.__path__[0])')/bin/llvm-config" >> "$GITHUB_ENV"
- name: Production compile
env:
MIX_ENV: prod
run: |
BEAVER_BUILD_CMAKE=1 mix compile
- name: Run patchelf
env:
MIX_ENV: prod
run: |
set -u
find _build/${MIX_ENV}/lib/beaver/native_install/lib -name "*.so*" -maxdepth 1 -type f | while read sofile; do
echo "==> before replace needed"
patchelf --print-needed $sofile
patchelf --replace-needed libMLIRBeaver.so.17 libMLIRBeaver.so $sofile
echo "==> after"
patchelf --print-needed $sofile
echo "==> before set rpath"
patchelf --print-rpath $sofile
patchelf --set-rpath '$ORIGIN:$ORIGIN/lib:$ORIGIN/../../..' --force-rpath \
$sofile
echo "==> after"
patchelf --print-rpath $sofile
done
- name: Tar production native libraries
id: tar
env:
MIX_ENV: prod
run: |
set -u
ls _build/${MIX_ENV}/lib/beaver/native_install/lib
LIB_FINAL_SO=$(ls _build/${MIX_ENV}/lib/beaver/native_install/lib | grep -E "libbeaver.+so")
LIB_FINAL_NAME=${LIB_FINAL_SO}.tar.gz
tar --dereference -cvzf ${LIB_FINAL_NAME} \
-C $PWD/_build/${MIX_ENV}/lib/beaver/native_install/lib $(cd $PWD/_build/${MIX_ENV}/lib/beaver/native_install/lib && ls *.so) \
-C $PWD/_build/${MIX_ENV}/lib/beaver/native_install/lib $(cd $PWD/_build/${MIX_ENV}/lib/beaver/native_install/lib && ls *.dylib) \
-C $PWD/_build/${MIX_ENV}/lib/beaver/native_install $(cd $PWD/_build/${MIX_ENV}/lib/beaver/native_install && ls *.ex)
echo "LIB_FINAL_NAME=${LIB_FINAL_NAME}" >> $GITHUB_OUTPUT
- name: Purge artifacts
run: |
python3 -m pip uninstall -y mlir
mix clean
- name: Start mock server in the background
run: |
python3 -m http.server --directory . &> /dev/null &
- name: Replace test config
run: |
cp config/release-test.exs config/test.exs
- name: Run download task
env:
MIX_ENV: test
run: |
# run a force build to generate metadata of rustler_precompiled
mix compile --force || true
mix rustler_precompiled.download Beaver.MLIR.CAPI --only-local --print
- name: Run tests with prebuilt
run: |
mix clean
mix test --exclude vulkan --exclude todo
- name: Publish archives and packages
uses: softprops/action-gh-release@v1
if: ${{ github.repository == 'beaver-lodge/beaver' && env.PRE_BUILT_RELEASE_GITHUB_TOKEN != null }}
with:
files: |
${{ steps.tar.outputs.LIB_FINAL_NAME }}
repository: beaver-lodge/beaver-prebuilt
token: ${{ secrets.PRE_BUILT_RELEASE_GITHUB_TOKEN }}
tag_name: ${{ needs.generate_id.outputs.formatted_date }}
- name: Test dev compile
if: ${{ github.repository == 'beaver-lodge/beaver' && env.PRE_BUILT_RELEASE_GITHUB_TOKEN != null }}
run: |
rm config/dev.exs
echo 'import Config' >> config/dev.exs
echo 'config :beaver, :prebuilt_base_url, "https://github.com/beaver-lodge/beaver-prebuilt/releases/download/${{ needs.generate_id.outputs.formatted_date }}"' >> config/dev.exs
mix compile