diff --git a/.github/workflows/cleanup-caches.yml b/.github/workflows/cleanup-caches.yml new file mode 100644 index 000000000..2f666007a --- /dev/null +++ b/.github/workflows/cleanup-caches.yml @@ -0,0 +1,28 @@ +name: Cleanup caches on closed PRs +# From https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#matching-a-cache-key +on: + pull_request: + types: [ closed ] +jobs: + cleanup: + runs-on: ubuntu-latest + permissions: + actions: write + steps: + - name: Cleanup + run: | + echo "Fetching list of cache keys" + cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id') + + ## Setting this to not fail the workflow while deleting cache keys. + set +e + echo "Deleting caches..." + for cacheKey in $cacheKeysForPR + do + gh cache delete $cacheKey + done + echo "Done" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 6580569e7..5129fd87d 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -4,6 +4,17 @@ on: branches: [ develop ] pull_request: branches: [ develop ] + paths: + - .github/workflows/cmake.yml + - .gitmodules + - '**/CMakeLists.txt' + - '**/*.cmake' + - '**/*.in' + - '**/*.h' + - '**/*.c' + - '**/*.cc' + - '**/*.cpp' + - '**/*.f' jobs: build: # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix @@ -18,6 +29,18 @@ jobs: no_mpi: [OFF, ON] cxx_standard: [11, 20] metis: [OFF, ON] + exclude: + - compiler: { name: LLVM } + build_type: Release + - cxx_standard: 20 + build_type: Release + env: + CCACHE_DIR: ${{github.workspace}}/.ccache + CCACHE_BASEDIR: ${{github.workspace}} + CCACHE_COMPRESS: true + CCACHE_MAXSIZE: 100M + CMAKE_C_COMPILER_LAUNCHER: ccache + CMAKE_CXX_COMPILER_LAUNCHER: ccache steps: - uses: actions/checkout@v4 @@ -32,6 +55,31 @@ jobs: if: matrix.metis == 'ON' run: sudo apt install libmetis-dev + - name: setup ccache + id: setup-ccache + run: | + sudo apt-get install ccache + ccache -p # Print ccache config + echo timestamp=$(date -u '+%Y-%m-%dT%T') >> "$GITHUB_OUTPUT" + + - name: ccache + uses: actions/cache@v4 + with: + path: ${{github.workspace}}/.ccache + key: "${{matrix.compiler.name}}-\ + cxx:${{matrix.cxx_standard}}-\ + ${{matrix.build_type}}-\ + nompi:${{matrix.no_mpi}}-\ + ccache-${{steps.setup-ccache.outputs.timestamp}}" + restore-keys: "${{matrix.compiler.name}}-\ + cxx:${{matrix.cxx_standard}}-\ + ${{matrix.build_type}}-\ + nompi:${{matrix.no_mpi}}-\ + ccache-" + + - name: Clear ccache statistics + run: ccache -z + - name: Configure CMake env: MPICH_CXX: ${{matrix.compiler.CXX}} @@ -53,14 +101,14 @@ jobs: env: MPICH_CXX: ${{matrix.compiler.CXX}} MPICH_CC: ${{matrix.compiler.CC}} - run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -j --target install + run: cmake --build ${{github.workspace}}/build --target install - name: Test env: MPICH_CXX: ${{matrix.compiler.CXX}} MPICH_CC: ${{matrix.compiler.CC}} working-directory: ${{github.workspace}}/build - run: ctest --output-on-failure -C ${{matrix.build_type}} + run: ctest --output-on-failure - name: Build User Project # only need to test with a single build config if the installed cmake config files work @@ -68,8 +116,11 @@ jobs: env: MPICH_CXX: ${{matrix.compiler.CXX}} MPICH_CC: ${{matrix.compiler.CC}} - run: | - cmake -S ${{github.workspace}}/doc -B ${{github.workspace}}/buildExample -DCMAKE_CXX_COMPILER=mpicxx -DSCOREC_PREFIX=${{github.workspace}}/build/install + run: > + cmake + -S ${{github.workspace}}/doc -B ${{github.workspace}}/buildExample + -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx + -DSCOREC_PREFIX=${{github.workspace}}/build/install ; cmake --build ${{github.workspace}}/buildExample - name: Build MPI-NoMPI Example @@ -81,10 +132,17 @@ jobs: MPICH_CXX: ${{matrix.compiler.CXX}} MPICH_CC: ${{matrix.compiler.CC}} run: > - cmake -S ${{github.workspace}}/example/mpi-nompi + cmake + -S ${{github.workspace}}/example/mpi-nompi -B ${{github.workspace}}/example/mpi-nompi/build - -DCMAKE_CXX_COMPILER=mpicxx + -DCMAKE_C_COMPILER=mpicxx -DCMAKE_CXX_COMPILER=mpicxx -DSCOREC_PREFIX=${{github.workspace}}/build/install ; cmake --build ${{github.workspace}}/example/mpi-nompi/build ; ctest --test-dir ${{github.workspace}}/example/mpi-nompi/build --output-on-failure + + - name: CCache statistics and recompression + run: | + ccache -sv + ccache -X 5 + diff --git a/.github/workflows/python-api-test.yml b/.github/workflows/python-api-test.yml index 2d2d645b0..423f3f458 100644 --- a/.github/workflows/python-api-test.yml +++ b/.github/workflows/python-api-test.yml @@ -13,21 +13,57 @@ jobs: env: PYTHONPATH: ${{ github.workspace }}/build/python_wrappers LD_LIBRARY_PATH: ${{ github.workspace }}/libs/install/lib:${LD_LIBRARY_PATH} + CCACHE_DIR: ${{github.workspace}}/.ccache + CCACHE_BASEDIR: ${{github.workspace}} + CCACHE_COMPRESS: true + CCACHE_MAXSIZE: 100M + CMAKE_C_COMPILER_LAUNCHER: ccache + CMAKE_CXX_COMPILER_LAUNCHER: ccache steps: - name: Checkout repository uses: actions/checkout@v3 + - name: setup cache timestamp + id: setup-cache + run: | + echo timestamp=$(date -u '+%Y-%m-%dT%T') >> "$GITHUB_OUTPUT" + + - name: Cache pip + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: "pyapi-pip-${{steps.setup-cache.outputs.timestamp}}" + restore-keys: pyapi-pip- + - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y cmake mpich build-essential libbz2-dev + sudo apt-get install -y mpich libbz2-dev ccache + mkdir -p /opt/ccache/libexec + ln -s $(which ccache) /opt/ccache/libexec/gcc + ln -s $(which ccache) /opt/ccache/libexec/g++ + ln -s $(which ccache) /opt/ccache/libexec/cc + ln -s $(which ccache) /opt/ccache/libexec/c++ pip3 install mpi4py - + + - name: ccache + uses: actions/cache@v4 + with: + path: ${{github.workspace}}/.ccache + key: "pyapi-ccache-${{steps.setup-cache.outputs.timestamp}}" + restore-keys: "pyapi-ccache-" + + - name: Clear ccache statistics + run: | + ccache -p # Print ccache config + ccache -z + - name: Build SWIG run: | git clone https://github.com/swig/swig.git cd swig + export PATH=/opt/ccache/libexec:$PATH ./autogen.sh ./configure --prefix=${{ github.workspace }}/libs/install make @@ -56,10 +92,9 @@ jobs: - name: Build Zoltan from Trilinos (minimal) run: | - git clone https://github.com/trilinos/Trilinos.git - mkdir build-zoltan - cd build-zoltan - cmake ../Trilinos \ + git clone --depth 1 https://github.com/trilinos/Trilinos.git + cmake -S Trilinos -B build-zoltan \ + -GNinja \ -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/libs/install \ -DTPL_ENABLE_MPI:BOOL=ON \ -DCMAKE_C_FLAGS="-O3 -fPIC" \ @@ -71,12 +106,12 @@ jobs: -DZoltan_ENABLE_ParMETIS:BOOL=ON \ -DParMETIS_INCLUDE_DIRS=${{ github.workspace }}/libs/install \ -DParMETIS_LIBRARY_DIRS=${{ github.workspace }}/libs/install - make - make install + cmake --build build-zoltan -t install - name: Configure PUMI run: | cmake -S . -B build \ + -GNinja \ -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build/install \ -DCMAKE_C_COMPILER=mpicc \ -DCMAKE_CXX_COMPILER=mpicxx \ @@ -93,11 +128,16 @@ jobs: -DPARMETIS_PREFIX=${{ github.workspace }}/libs/install \ -DENABLE_SIMMETRIX=OFF - - name: Build and install + - name: Build and install PUMI run: | - cmake --build build -j 4 --target install + cmake --build build --target install - name: Run Python test working-directory: ${{github.workspace}}/python_wrappers run: | python3 test_pyCore.py -g input/cube.dmg -m input/cube.smb + + - name: Ccache statistics and recompression + run: | + ccache -sv + ccache -X 5