Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# ==========================================================================
# Copyright (C) 2022 Intel Corporation
#
# SPDX-License-Identifier: MIT
# ==========================================================================

name: gcc/clang build and functional testing

on:
pull_request:
branches: [ develop ]

env:
# (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
# Each PR reuses its own testing seed when rerunning jobs
seed_linux:
runs-on: ubuntu-latest

steps:
- name: Check if seed exists
id: cache-seed
uses: actions/cache@v3
with:
path: PR${{ github.event.pull_request.number }}_seed.txt
key: seed

# TODO: The datatype of seed is supposed to be uint32_t, but the seed becomes 0
# when it is greater than or equal to 2^31. This needs to be fixed so that
# we can use randrange(2**32) here.
- name: Generate seed
if: ${{ steps.cache-seed.outputs.cache-hit != 'true' }}
run: python -c 'from random import randrange; print(randrange(2**31))' > PR${{ github.event.pull_request.number }}_seed.txt

# For Windows support
- name: Upload seed
if: ${{ steps.cache-seed.outputs.cache-hit != 'true' }}
uses: actions/upload-artifact@v3
with:
name: PR${{ github.event.pull_request.number }}_seed
path: PR${{ github.event.pull_request.number }}_seed.txt

# Cache seed on Windows
seed_windows:
needs: seed_linux
runs-on: windows-latest

steps:
- name: Check if seed exists
id: cache-seed
uses: actions/cache@v3
with:
path: PR${{ github.event.pull_request.number }}_seed.txt
key: seed

- name: Download seed
if: ${{ steps.cache-seed.outputs.cache-hit != 'true' }}
uses: actions/download-artifact@v3
with:
name: PR${{ github.event.pull_request.number }}_seed

ci:
needs: seed_linux

# Latest is >= 20.04 which has required GNU >= 8.2
runs-on: ubuntu-latest

strategy:
matrix:
compiler: [ gcc, clang ]
# If one job fails, the other can carry on
fail-fast: false

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

# QPL requirement
- name: Install nasm
run: |
sudo apt-get update -y
sudo apt-get install -y nasm

- name: Setup clang
if: ${{ matrix.compiler == 'clang' }}
id: setup_clang
run: |
sudo apt-get update -y
sudo apt-get -y install clang-12
echo "::set-output name=c_comp::clang"
echo "::set-output name=cpp_comp::clang++"

- name: Configure cmake
env:
CC: ${{steps.setup_clang.outputs.c_comp}}
CXX: ${{steps.setup_clang.outputs.cpp_comp}}
run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=installation

- name: Build
id: build
run: cmake --build build --target install --parallel 2

- name: Cache seed
uses: actions/cache@v3
with:
path: PR${{ github.event.pull_request.number }}_seed.txt
key: seed

- name: Obtain seed
id: obtain_seed
run: |
seed=`cat PR${{ github.event.pull_request.number }}_seed.txt`
echo "Seed $seed"
echo "::set-output name=seed::$seed"

- name: Functional tests (Algorithmic tests)
if: ${{ always() && steps.build.outcome == 'success' }}
id: ta_tests
timeout-minutes: 90
run: ./installation/bin/tests --seed=${{ steps.obtain_seed.outputs.seed }} --gtest_filter=ta_* --dataset=tools/testdata/

- name: Functional tests (Bad argument tests)
if: ${{ always() && steps.build.outcome == 'success' }}
id: tb_tests
timeout-minutes: 90
run: ./installation/bin/tests --seed=${{ steps.obtain_seed.outputs.seed }} --gtest_filter=tb_* --dataset=tools/testdata/

- name: Functional tests (Negative tests)
if: ${{ always() && steps.build.outcome == 'success' }}
id: tn_tests
timeout-minutes: 90
run: ./installation/bin/tests --seed=${{ steps.obtain_seed.outputs.seed }} --gtest_filter=tn_* --dataset=tools/testdata/

- name: Functional tests (Thread tests)
if: ${{ always() && steps.build.outcome == 'success' }}
id: tt_tests
timeout-minutes: 90
run: ./installation/bin/tests --seed=${{ steps.obtain_seed.outputs.seed }} --gtest_filter=tt_* --dataset=tools/testdata/