fix: ci #5
This file contains hidden or 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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ master, develop ] | |
| pull_request: | |
| branches: [ master ] | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| build-type: [Release, Debug] | |
| include: | |
| - os: ubuntu-latest | |
| compiler: gcc | |
| cxx_compiler: g++ | |
| - os: ubuntu-latest | |
| compiler: clang | |
| cxx_compiler: clang++ | |
| - os: macos-latest | |
| compiler: clang | |
| cxx_compiler: clang++ | |
| cxx_flags: "-stdlib=libc++" | |
| - os: windows-latest | |
| compiler: msvc | |
| cxx_compiler: cl | |
| generator: "Visual Studio 17 2022" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential cmake | |
| - name: Configure CMake (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| cmake -B build \ | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ | |
| -DCMAKE_C_COMPILER=${{ matrix.compiler }} \ | |
| -DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} | |
| - name: Configure CMake (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| cmake -B build \ | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ | |
| -DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}" | |
| - name: Configure CMake (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| cmake -B build -G "${{ matrix.generator }}" | |
| - name: Build (Linux) | |
| if: runner.os == 'Linux' | |
| run: cmake --build build -j$(nproc) | |
| - name: Build (macOS) | |
| if: runner.os == 'macOS' | |
| run: cmake --build build -j$(sysctl -n hw.ncpu) | |
| - name: Build (Windows) | |
| if: runner.os == 'Windows' | |
| env: | |
| CMAKE_BUILD_PARALLEL_LEVEL: $env:NUMBER_OF_PROCESSORS | |
| run: cmake --build build --config ${{ matrix.build-type }} | |
| - name: Run Tests (Linux/macOS) | |
| if: runner.os != 'Windows' | |
| run: | | |
| cd build | |
| ./hash_table_demo | |
| - name: Run Tests (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| cd build | |
| .\${{ matrix.build-type }}\hash_table_demo.exe | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| if: matrix.build-type == 'Release' | |
| with: | |
| name: hash_table_demo-${{ runner.os }}-${{ matrix.build-type }} | |
| path: ${{ runner.os == 'Windows' && 'build/Release/hash_table_demo.exe' || 'build/hash_table_demo' }} | |
| retention-days: 7 | |
| code-quality: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential cmake clang-format | |
| - name: Check code formatting | |
| run: | | |
| find include src -name "*.h" -o -name "*.cpp" | xargs clang-format --dry-run --Werror || true | |
| - name: Build with sanitizers | |
| run: | | |
| cmake -B build-sanitize \ | |
| -DCMAKE_BUILD_TYPE=Debug \ | |
| -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined" | |
| cmake --build build-sanitize | |
| cd build-sanitize | |
| ./hash_table_demo |