-
Notifications
You must be signed in to change notification settings - Fork 4
191 lines (178 loc) · 6.27 KB
/
AsteriskBuildAndCache.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Build
on:
workflow_call:
inputs:
test_type:
description: 'nightly, prstatechange, prrecheck, cherry-pick'
required: true
type: string
asterisk_repo:
required: true
type: string
pr_number:
required: true
type: string
base_branch:
required: true
type: string
is_cherry_pick:
required: false
type: boolean
default: false
build_script:
required: false
type: string
default: "buildAsterisk.sh"
no_alembic:
required: false
type: boolean
default: false
build_options:
required: false
type: string
default: ""
modules_blacklist:
description: 'List of Asterisk modules to blacklist from the build'
type: string
default: ""
required: false
sipp_version:
required: false
type: string
default: v3.6.1
output_cache_dir:
type: string
required: false
default: cache
build_cache_dir:
type: string
required: false
default: ""
build_cache_key:
type: string
required: false
default: ""
debug:
required: false
type: boolean
default: false
job_name_extra:
required: false
type: string
default: ""
env:
ASTERISK_REPO: ${{ inputs.asterisk_repo }}
BASE_BRANCH: ${{ inputs.base_branch }}
IS_CHERRY_PICK: ${{ inputs.is_cherry_pick }}
PR_NUMBER: ${{ inputs.pr_number }}
NO_ALEMBIC: ${{ inputs.no_alembic }}
BUILD_SCRIPT: ${{ inputs.build_script }}
BUILD_OPTIONS: ${{ inputs.build_options }}
MODULES_BLACKLIST: ${{ inputs.modules_blacklist }}
SIPP_VERSION: ${{ inputs.sipp_version }}
CACHE_DIR: ${{ github.workspace }}/${{ inputs.output_cache_dir }}
REPO_NAME: ${{ github.event.repository.name }}
REPO_DIR: ${{ github.workspace }}/${{ github.event.repository.name }}
REPO_ORG: ${{ github.event.repository.owner.login }}
OUTPUT_DIR: ${{ github.workspace }}/${{ inputs.output_cache_dir }}/output
BUILD_CACHE_DIR: ${{ inputs.build_cache_dir }}
BUILD_CACHE_PATH: ${{ github.workspace }}/${{ inputs.build_cache_dir }}
BUILD_CACHE_KEY: ${{ inputs.build_cache_key }}
LOG_DIR: ${{ github.workspace }}/logs
LOG_FILE: ${{ github.workspace }}/logs/job_summary.txt
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
Build:
name: ${{ inputs.base_branch }}-build${{inputs.job_name_extra}}
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
# ACTIONS_PATH, SCRIPT_DIR, NORMALIZED_BRANCH env vars
- name: GetActionsRepo
uses: asterisk/asterisk-ci-actions/GetActionsRepo@main
- name: Setup Runner
run: |
# Setup
echo "::group::Installing software"
sudo ${SCRIPT_DIR}/setupRunner.sh --sipp-version=${SIPP_VERSION}
echo "::endgroup::"
mkdir -p ${REPO_DIR}
mkdir -p ${CACHE_DIR}
mkdir -p ${OUTPUT_DIR}
mkdir -p ${LOG_DIR}
- name: BuildAsterisk
run: |
# Building Asterisk
echo "::group::Checking out ${ASTERISK_REPO} to ${REPO_DIR}"
${SCRIPT_DIR}/checkoutRepo.sh --repo=${ASTERISK_REPO} \
--branch=${BASE_BRANCH} --is-cherry-pick=${IS_CHERRY_PICK} \
--pr-number=${PR_NUMBER} --repo-dir=${REPO_DIR} || {
echo "::endgroup::"
exit 1
}
echo "::endgroup::"
cd ${REPO_DIR}
if ! ${NO_ALEMBIC} ; then
echo "::group::Running Alembic Tests"
sudo ${SCRIPT_DIR}/setupDatabase.sh || {
echo "FAILED: Unable to set up database for alembic tests" >> ${LOG_FILE}
echo "::endgroup::"
exit 1
}
sudo ${SCRIPT_DIR}/runAlembicTests.sh || {
echo "FAILED: Alembic Tests" >> ${LOG_FILE}
sudo ${SCRIPT_DIR}/teardownDatabase.sh --stop-database
echo "::endgroup::"
exit 1
}
sudo ${SCRIPT_DIR}/teardownDatabase.sh --stop-database
echo "::endgroup::"
fi
echo "::group::Starting build"
${SCRIPT_DIR}/${BUILD_SCRIPT} --github --branch-name=${BASE_BRANCH} \
--ccache-disable ${BUILD_OPTIONS} \
--modules-blacklist="${MODULES_BLACKLIST// /}" \
--output-dir=${OUTPUT_DIR} \
--cache-dir=${CACHE_DIR} || {
echo "FAILED: Build" > ${LOG_FILE}
exit 1
}
echo "::endgroup::"
echo "::group::Cache"
if [ -z "${BUILD_CACHE_DIR}" ] ; then
echo "*** No build cache dir specified. Not caching"
echo "::endgroup::"
exit 0
fi
mkdir -p ${BUILD_CACHE_PATH}
echo "*** Installing binaries to ${BUILD_CACHE_PATH}"
make DESTDIR=${BUILD_CACHE_PATH} WGET_EXTRA_ARGS=-q install >/dev/null
echo "*** Installing samples to ${BUILD_CACHE_PATH}"
make DESTDIR=${BUILD_CACHE_PATH} samples >/dev/null
echo "*** Installing headers to ${BUILD_CACHE_PATH}"
make DESTDIR=${BUILD_CACHE_PATH} install-headers >/dev/null
echo "*** Caching source"
git archive --format=tar.gz -o ${BUILD_CACHE_PATH}/asterisk-source.tar.gz --prefix=${REPO_NAME}/ HEAD
ls -al ${BUILD_CACHE_PATH}/
echo "::endgroup::"
echo "::group::Deleting old cache (if any): ${BUILD_CACHE_KEY}"
# We don't care if it fails
gh cache delete ${BUILD_CACHE_KEY} || :
echo "::endgroup::"
- id: cache-build-output
if: success() && inputs.build_cache_dir != '' && inputs.build_cache_key != ''
name: CacheBuildProducts
uses: actions/cache/save@v4
with:
path: ${{ inputs.build_cache_dir }}
key: ${{ inputs.build_cache_key }}
- name: Save Output
if: ${{ always() }}
id: save-output
uses: actions/upload-artifact@v4
with:
name: ${{ env.NORMALIZED_BRANCH }}-build${{inputs.job_name_extra}}
if-no-files-found: ignore
path: ${{ env.LOG_DIR }}