Improve CI/CD Test Coverage #178
Workflow file for this run
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: Run Tests | |
on: [pull_request] | |
env: | |
POETRY_VERSION: "1.6.1" | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
test-clang-format: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install clang-format and make | |
run: | | |
set -ex | |
sudo apt-get update | |
sudo apt-get install -y clang-format make | |
clang-format --version | |
- name: Check C++ source code formatting | |
run: | | |
make format-cpp | |
# Check if there are any changes after formatting | |
if ! git diff --quiet; then | |
echo "Formatting changes detected. Committing and pushing the changes." | |
# Set up git user for commit | |
git config user.name "GitHub Action Bot" | |
git config user.email "[email protected]" | |
# Add, commit, and push the changes | |
git add . | |
git commit -m "chore: auto-format C++ code via clang-format" | |
# Push to the current branch | |
git push origin HEAD:${{ github.head_ref || github.ref_name }} | |
else | |
echo "No formatting changes needed." | |
fi | |
test-python-library: | |
strategy: | |
# Ensure that failure for one test does not cancel other actions | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install libomp (macOS only) | |
if: runner.os == 'macOS' | |
run: | | |
brew install libomp | |
- name: Set up Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: ${{ env.POETRY_VERSION }} | |
- name: Install dependencies | |
run: | | |
cd flatnav_python | |
poetry install | |
- name: Build flatnav | |
run: | | |
cd flatnav_python | |
export NO_SIMD_VECTORIZATION=1 | |
./install_flatnav.sh | |
- name: Run Unit Tests | |
run: | | |
make run-python-unit-tests | |
run-cpp-unit-tests: | |
needs: test-clang-format | |
strategy: | |
# Ensure that failure for one test does not cancel other actions | |
fail-fast: false | |
matrix: | |
# TODO: Would love to add macos here. | |
os: [ubuntu-latest, macos-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
- name: Install dependencies | |
run: | | |
# Install CMake, Clang and LibOMP | |
make setup-clang-cmake-libomp | |
- name: Build and Run C++ Unit Tests | |
run: | | |
set -ex | |
make run-cpp-unit-tests |