Merge pull request #1882 from IntelPython/dependabot/github_actions/g… #4771
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate coverage data | |
on: | |
pull_request: | |
push: | |
branches: [master] | |
permissions: read-all | |
jobs: | |
generate-coverage: | |
name: Generate coverage and push to Coveralls.io | |
runs-on: ubuntu-latest | |
timeout-minutes: 150 | |
permissions: | |
pull-requests: write | |
env: | |
ONEAPI_ROOT: /opt/intel/oneapi | |
GTEST_ROOT: /home/runner/work/googletest-1.15.2/install | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/cancel-workflow-action@0.12.1 | |
with: | |
access_token: ${{ github.token }} | |
- name: Add Intel repository | |
run: | | |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | |
cat GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null | |
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | |
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list | |
sudo apt update | |
- name: Install latest Intel OneAPI | |
run: | | |
sudo apt install intel-oneapi-compiler-dpcpp-cpp | |
sudo apt install intel-oneapi-tbb | |
sudo apt install intel-oneapi-umf | |
sudo apt install hwloc | |
- name: Run SYCL list | |
run: | | |
source /opt/intel/oneapi/setvars.sh | |
sycl-ls --verbose | |
- name: Install CMake and Ninja | |
run: | | |
sudo apt-get install ninja-build | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
architecture: x64 | |
- name: Cache Gtest | |
id: cache-gtest | |
uses: actions/cache@v4 | |
with: | |
path: | | |
/home/runner/work/googletest-1.15.2/install | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('/home/runner/work/googletest-1.15.2/install/include/gtest/*') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install Gtest | |
if: steps.cache-gtest.outputs.cache-hit != 'true' | |
shell: bash -l {0} | |
run: | | |
cd /home/runner/work | |
wget https://github.com/google/googletest/archive/refs/tags/v1.15.2.tar.gz | |
tar xf v1.15.2.tar.gz | |
cd googletest-1.15.2 | |
mkdir build | |
cd build | |
cmake .. -DCMAKE_INSTALL_PREFIX=/home/runner/work/googletest-1.15.2/install | |
make && make install | |
- name: Checkout repo | |
uses: actions/checkout@v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Install Lcov | |
run: | | |
sudo apt-get install lcov | |
- name: Install dpctl dependencies | |
shell: bash -l {0} | |
run: | | |
pip install numpy cython setuptools pytest pytest-cov scikit-build cmake coverage[toml] versioneer[toml]==0.29 | |
- name: Build dpctl with coverage | |
shell: bash -l {0} | |
env: | |
SYCL_CACHE_PERSISTENT: 1 | |
run: | | |
source /opt/intel/oneapi/setvars.sh | |
python scripts/gen_coverage.py --verbose | |
- name: Install coverall dependencies | |
shell: bash -l {0} | |
run: | | |
sudo gem install coveralls-lcov | |
pip install coveralls | |
- name: Upload coverage data to coveralls.io | |
shell: bash -l {0} | |
run: | | |
echo "Processing c-api-coverage" | |
export DPCTL_LCOV_FN=$(find _skbuild -name dpctl.lcov) | |
grep "/tmp" $DPCTL_LCOV_FN | |
coveralls-lcov -v -n \ | |
$DPCTL_LCOV_FN > dpctl-c-api-coverage.json | |
echo "Processing pytest-coverage" | |
export DPCTL_PYTEST_LCOV=$(find . -name dpctl_pytest.lcov) | |
grep "/tmp" $DPCTL_PYTEST_LCOV | |
coveralls-lcov -v -n \ | |
$DPCTL_PYTEST_LCOV > pytest-dpctl-c-api-coverage.json | |
echo "Merging JSON files" | |
python -c "import json; \ | |
fh1 = open('dpctl-c-api-coverage.json', 'r'); \ | |
f1 = json.load(fh1); fh1.close(); \ | |
fh2 = open('pytest-dpctl-c-api-coverage.json', 'r'); \ | |
f2 = json.load(fh2); fh2.close(); \ | |
f3 = {'source_files': f1['source_files'] + f2['source_files']}; \ | |
fh3 = open('combined-dpctl-c-api-coverage.json', 'w'); \ | |
json.dump(f3, fh3); fh3.close()" || exit 1 | |
# merge combined file with coverage data and upload | |
ls -lh dpctl-c-api-coverage.json pytest-dpctl-c-api-coverage.json \ | |
combined-dpctl-c-api-coverage.json \ | |
$(find _skbuild -name dpctl.lcov) $(find . -name dpctl_pytest.lcov) | |
echo "Merging combined files with coverage data" | |
coveralls --service=github --merge=combined-dpctl-c-api-coverage.json | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
COVERALLS_PARALLEL: true | |
SYCL_QUEUE_THREAD_POOL_SIZE: 6 | |
coveralls: | |
name: Indicate completion to coveralls.io | |
needs: generate-coverage | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
container: python:3-slim | |
steps: | |
- name: Finished | |
run: | | |
pip3 install --upgrade coveralls | |
coveralls --finish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |