Skip to content

Commit d496884

Browse files
Add Github Action Pipeline and Fixed INITIALIZE_SUBMODULES (#64)
* Github action test * Continue testing * Continue testing * Continue testing * Continue testing * Continue testing * Continue testing * Continue testing * Continue testing * Continue testing * Continue testing * Add missing .o * Fix * Revert "Add missing .o" This reverts commit c95605c. * Revert "Fix" This reverts commit ff6b82b. * Need to add dev
1 parent 43bb10a commit d496884

File tree

4 files changed

+118
-7
lines changed

4 files changed

+118
-7
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Docker Build and Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
pull_request:
9+
branches:
10+
- main
11+
- dev
12+
13+
env:
14+
ACR: jbpfpipeline
15+
IMAGE_TAG: ${{ github.run_id }}-${{ github.sha }}
16+
17+
jobs:
18+
build-and-test:
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
dockerType: [ "mariner", "ubuntu22.04", "ubuntu24.04" ]
23+
testCase: [ "test0", "test1", "test2", "test3", "test4", "test5", "test6", "test7" ]
24+
25+
steps:
26+
- name: Checkout Repository
27+
uses: actions/checkout@v4
28+
29+
- name: Set Build Parameters
30+
id: set_params
31+
run: |
32+
case "${{ matrix.testCase }}" in
33+
test0) echo "staticBuildParam=" >> "$GITHUB_ENV"; echo "sanitizerBuildParam=" >> "$GITHUB_ENV";;
34+
test1) echo "staticBuildParam=-e JBPF_STATIC=1" >> "$GITHUB_ENV"; echo "sanitizerBuildParam=" >> "$GITHUB_ENV";;
35+
test2) echo "staticBuildParam=" >> "$GITHUB_ENV"; echo "sanitizerBuildParam=-e SANITIZER=1" >> "$GITHUB_ENV";;
36+
test3) echo "staticBuildParam=-e JBPF_STATIC=1" >> "$GITHUB_ENV"; echo "sanitizerBuildParam=-e SANITIZER=1" >> "$GITHUB_ENV";;
37+
test4) echo "staticBuildParam=" >> "$GITHUB_ENV"; echo "sanitizerBuildParam=-e SANITIZER=1 -e JBPF_EXPERIMENTAL_FEATURES=1" >> "$GITHUB_ENV";;
38+
test5) echo "staticBuildParam=-e JBPF_STATIC=1 -e JBPF_EXPERIMENTAL_FEATURES=1" >> "$GITHUB_ENV"; echo "sanitizerBuildParam=-e SANITIZER=1" >> "$GITHUB_ENV";;
39+
test6) echo "staticBuildParam=" >> "$GITHUB_ENV"; echo "sanitizerBuildParam=-e JBPF_EXPERIMENTAL_FEATURES=1" >> "$GITHUB_ENV";;
40+
test7) echo "staticBuildParam=-e JBPF_STATIC=1 -e JBPF_EXPERIMENTAL_FEATURES=1" >> "$GITHUB_ENV"; echo "sanitizerBuildParam=" >> "$GITHUB_ENV";;
41+
esac
42+
43+
- name: Display Build Parameters
44+
run: |
45+
echo "Docker Type: ${{ matrix.dockerType }}"
46+
echo "Test Case: ${{ matrix.testCase }}"
47+
echo "Static Build Param: ${{ env.staticBuildParam }}"
48+
echo "Sanitizer Build Param: ${{ env.sanitizerBuildParam }}"
49+
50+
- name: Disable Git SSL Verification (Temporary)
51+
run: |
52+
git config --global http.sslVerify false
53+
54+
- name: Build Docker Image
55+
run: |
56+
docker build \
57+
-t ${{ env.ACR }}/jbpf-lib-${{ matrix.dockerType }}:${{ env.IMAGE_TAG }} \
58+
-f deploy/${{ matrix.dockerType }}.Dockerfile .
59+
docker tag ${{ env.ACR }}/jbpf-lib-${{ matrix.dockerType }}:${{ env.IMAGE_TAG }} jbpf_lib
60+
61+
- name: Run Container to Build JBPF
62+
run: |
63+
set -ex
64+
source setup_jbpf_env.sh
65+
./init_and_patch_submodules.sh
66+
docker run \
67+
-v "$(pwd)"/3p:/jbpf/3p \
68+
-v "$(pwd)":/jbpf_out_lib \
69+
-e INITIALIZE_SUBMODULES=0 \
70+
${{ env.staticBuildParam }} ${{ env.sanitizerBuildParam }} jbpf_lib
71+
72+
- name: Run Tests
73+
run: |
74+
set -x
75+
source setup_jbpf_env.sh
76+
docker run --init --privileged --network host --cap-add=SYS_ADMIN --shm-size=1g \
77+
--mount type=tmpfs,destination=/dev/shm \
78+
-v "$(pwd)":/jbpf_out_lib -v "$(pwd)"/build:/jbpf/build \
79+
-v "$(pwd)"/3p:/jbpf/3p \
80+
-e JBPF_PATH=/jbpf \
81+
-e INITIALIZE_SUBMODULES=0 \
82+
${{ env.staticBuildParam }} ${{ env.sanitizerBuildParam }} \
83+
-e RUN_TESTS=1 jbpf_lib
84+
85+
TEST_OUTCOME=$?
86+
mkdir -p ${{ github.workspace }}/artifacts
87+
cp ./build/Testing/Temporary/LastTest.log ${{ github.workspace }}/artifacts/ || true
88+
cp "$(pwd)"/out/jbpf_tests.xml ${{ github.workspace }}/artifacts/ || true
89+
90+
if [ "$TEST_OUTCOME" -ne 0 ]; then
91+
echo "Error running tests, result code is $TEST_OUTCOME"
92+
exit 1
93+
fi

azure-pipelines.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@ pool:
1515
# demands: Agent.CPU -equals 8
1616

1717
schedules:
18-
- cron: "0 0 1 * *"
19-
displayName: Monthly scheduled build
20-
branches:
21-
include:
22-
- main
23-
always: true
2418
- cron: "0 0 * * *"
2519
displayName: Daily scheduled build
2620
branches:
2721
include:
28-
- stable
22+
- main
2923
always: true
3024

3125
variables:

helper_build_files/build_utils.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
### env parameter: CLANG_FORMAT_CHECK
1414
### env parameter: CPP_CHECK
1515
### env parameter: BUILD_TESTING
16+
### env parameter: INITIALIZE_SUBMODULES
1617
get_flags() {
1718
FLAGS=""
1819
OUTPUT=""
@@ -83,4 +84,11 @@ get_flags() {
8384
else
8485
OUTPUT="$OUTPUT Skipping building tests\n"
8586
fi
87+
if [[ "$INITIALIZE_SUBMODULES" == "1" || "$INITIALIZE_SUBMODULES" == "" ]]; then
88+
OUTPUT="$OUTPUT Initializing submodules\n"
89+
FLAGS="$FLAGS -DINITIALIZE_SUBMODULES=on"
90+
else
91+
OUTPUT="$OUTPUT Skipping initializing submodules\n"
92+
FLAGS="$FLAGS -DINITIALIZE_SUBMODULES=off"
93+
fi
8694
}

helper_build_files/test_build_utils.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,20 @@ if ! test_flags "-DBUILD_TESTING=on" "When BUILD_TESTING is unset flags should c
240240
exit 1
241241
fi
242242

243+
### env parameter: INITIALIZE_SUBMODULES
244+
INITIALIZE_SUBMODULES=1
245+
if ! test_flags "-DINITIALIZE_SUBMODULES=on" "When INITIALIZE_SUBMODULES=1 flags should contain -DINITIALIZE_SUBMODULES=on"; then
246+
exit 1
247+
fi
248+
249+
INITIALIZE_SUBMODULES=0
250+
if ! test_flags "-DINITIALIZE_SUBMODULES=off" "When INITIALIZE_SUBMODULES=0 flags should contain -DINITIALIZE_SUBMODULES=off"; then
251+
exit 1
252+
fi
253+
254+
INITIALIZE_SUBMODULES=
255+
if ! test_flags "-DINITIALIZE_SUBMODULES=on" "When INITIALIZE_SUBMODULES is unset flags should contain -DINITIALIZE_SUBMODULES=on"; then
256+
exit 1
257+
fi
258+
243259
echo ---------------- All Passed ----------------

0 commit comments

Comments
 (0)