-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (93 loc) · 3.96 KB
/
reusable-build-on-ubuntu.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
name: Build on Ubuntu
on:
workflow_call:
inputs:
version:
type: string
required: true
matrix: # [ { name, runner, docker_tag }, ... ]
type: string
required: true
release:
type: boolean
jobs:
build_on_ubuntu:
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(inputs.matrix) }}
name: Build on ${{ matrix.name }} with ${{ matrix.compiler }} ${{ matrix.build_type }}
runs-on: ubuntu-latest
env:
BUILD_TESTS: OFF
container: wasmedge/wasmedge:${{ matrix.docker_tag }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Ensure git safe directory
run: |
git config --global --add safe.directory $(pwd)
- name: Set environment variables for tests
if: ${{ matrix.tests }}
run: |
echo "BUILD_TESTS=ON" | tee -a $GITHUB_ENV
- name: Grant the safe directory for git
run: |
git config --global --add safe.directory $(pwd)
- name: Build WasmEdge using ${{ matrix.compiler }} with ${{ matrix.build_type }} mode
if: ${{ ! matrix.coverage }}
shell: bash
env:
CMAKE_BUILD_TYPE: ${{ matrix.build_type }}
run: |
if [[ "${{ matrix.compiler }}" == "clang++" ]]; then
cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DWASMEDGE_LINK_LLVM_STATIC=ON -DWASMEDGE_BUILD_TESTS=$BUILD_TESTS -DWASMEDGE_BUILD_PACKAGE="TGZ" ${{ matrix.options }} .
else
cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -DWASMEDGE_BUILD_TESTS=$BUILD_TESTS -DWASMEDGE_BUILD_PACKAGE="TGZ" ${{ matrix.options }} .
fi
cmake --build build
cmake --build build --target package
- name: Test WasmEdge
if: ${{ !matrix.coverage && env.BUILD_TESTS }}
run: |
export LD_LIBRARY_PATH="$(pwd)/build/lib/api:$LD_LIBRARY_PATH"
cd build
./tools/wasmedge/wasmedge -v
ctest
cd -
- name: Build WasmEdge using ${{ matrix.compiler }} with Coverage mode
if: ${{ matrix.coverage }}
run: |
apt update
apt install -y gcovr
cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Debug -DWASMEDGE_BUILD_TESTS=ON -DWASMEDGE_BUILD_COVERAGE=ON .
cmake --build build
LD_LIBRARY_PATH=$(pwd)/build/lib/api cmake --build build --target codecov
- name: Upload artifact
if: ${{ !inputs.release && !matrix.coverage }}
uses: actions/upload-artifact@v3
with:
name: WasmEdge-${{ inputs.version }}-${{ matrix.name }}-${{ matrix.compiler }}-${{ matrix.build_type }}.tar.gz
path: build/WasmEdge-${{ inputs.version }}-Linux.tar.gz
- name: Upload package tarball
if: ${{ inputs.release }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
type -p curl >/dev/null || (apt update && apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& apt update \
&& apt install gh -y
mv build/WasmEdge-${{ inputs.version }}-Linux.tar.gz WasmEdge-${{ inputs.version }}-ubuntu20.04_x86_64.tar.gz
gh release upload ${{ inputs.version }} WasmEdge-${{ inputs.version }}-ubuntu20.04_x86_64.tar.gz --clobber
- name: Create and upload coverage report to Codecov
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./build/codecov.xml
name: codecov-wasmedge
fail_ci_if_error: true