From c864c81e4a957228d932f554ae9924aa4c256cda Mon Sep 17 00:00:00 2001 From: "clara.bayley" Date: Wed, 30 Oct 2024 10:53:51 +0100 Subject: [PATCH] refactor: seperate steps in build CI --- .github/workflows/CI.yml | 6 +- .github/workflows/build.yml | 266 +++++++++++++++++++++---------- .github/workflows/pre-commit.yml | 4 +- .pre-commit-config.yaml | 5 +- 4 files changed, 190 insertions(+), 91 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4276177a4..6636d41a6 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,4 +1,4 @@ -name: Python test +name: CI (pytest and documentation) on: [push, pull_request] @@ -39,7 +39,7 @@ jobs: run: | cd docs && make html - name: Archive build artifacts (i.e. documentation) - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: html-docs path: docs/build/html/ @@ -58,7 +58,7 @@ jobs: name: html-docs path: docs/build/html/ - name: Publish docs on GitHub pages - uses: peaceiris/actions-gh-pages@v3 + uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: docs/build/html diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 41ed017fd..b5851b5ed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build +name: build on: pull_request @@ -6,87 +6,183 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup - run: | - sudo apt-get update - sudo apt-get install -y \ - cmake libnetcdff-dev liblapack-dev python3-dev \ - python3-numpy python3-mpi4py python3-pip curl \ - libfyaml-dev libopenmpi-dev openmpi-bin - - - name: Build YAXT - run: | - curl -s -L https://swprojects.dkrz.de/redmine/attachments/download/534/yaxt-0.11.1.tar.gz | tar xvz - cd yaxt-0.11.1 - ./configure --without-regard-for-quality --without-example-programs --without-perf-programs --with-pic \ - --prefix=$HOME/yaxt - make -j 4 - make install - - - name: Build YAC - run: | - curl -s -L https://gitlab.dkrz.de/dkrz-sw/yac/-/archive/v3.2.0/yac-v3.2.0.tar.gz | tar xvz - cd yac-v3.2.0 - ./configure CFLAGS="-fPIC" CC=mpicc FC=mpif90 --disable-mpi-checks --with-yaxt-root=${HOME}/yaxt \ - --prefix=$HOME/yac - make -j 4 - make install - - - name: Build main - run: | - mkdir build && cd build - cmake \ - -DCMAKE_C_COMPILER=gcc \ - -DCMAKE_CXX_COMPILER=g++ \ - -DCMAKE_CXX_FLAGS="-Werror -Wall -pedantic -O3" \ - -DKokkos_ENABLE_SERIAL=ON \ - -DENABLE_YAC_COUPLING=ON \ - -DYAXT_ROOT=${HOME}/yaxt \ - -DYAC_ROOT=${HOME}/yac \ - -DCMAKE_MODULE_PATH=${PWD}/../libs/coupldyn_yac/cmake .. - make - - - name: Build example adia0d - run: cd build && make adia0d - - - name: Build example golcolls - run: cd build && make golcolls - - - name: Build example longcolls - run: cd build && make longcolls - - - name: Build example lowlistcolls - run: cd build && make lowlistcolls - - - name: Build example szakallurbichcolls - run: cd build && make szakallurbichcolls - - - name: Build example testikstraubcolls - run: cd build && make testikstraubcolls - - - name: Build example const2d - run: cd build && make const2d - - - name: Build example divfree2d - run: cd build && make divfree2d - - - name: Build example eurec4a1d - run: cd build && make eurec4a1d - - - name: Build example rshaft1d - run: cd build && make rshaft1d - - - name: Build example spdtest - run: cd build && make spdtest - - - name: Build example bubble3d - run: cd build && make bubble3d - - - name: Build example fromfile - run: cd build && make fromfile - - - name: Build example fromfile_irreg - run: cd build && make fromfile_irreg + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup + run: | + sudo apt-get update + sudo apt-get install -y \ + cmake libnetcdff-dev liblapack-dev python3-dev \ + python3-numpy python3-mpi4py python3-pip curl \ + libfyaml-dev libopenmpi-dev openmpi-bin + + - name: Cache YAXT + id: cache_yaxt + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/yaxt/ + key: ${{ runner.os }}-yaxt-cache-v0.11.1 + restore-keys: | + ${{ runner.os }}-yaxt- + + - name: Cache YAC + id: cache_yac + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/yac/ + key: ${{ runner.os }}-yac-cache-v3.2.0 + restore-keys: | + ${{ runner.os }}-yac- + + - name: Build YAXT + if: steps.cache_yaxt.outputs.cache-hit != 'true' + run: | + curl -s -L https://swprojects.dkrz.de/redmine/attachments/download/534/yaxt-0.11.1.tar.gz | tar xvz + cd yaxt-0.11.1 + ./configure --without-regard-for-quality --without-example-programs \ + --without-perf-programs --with-pic --prefix=${{ runner.temp }}/yaxt + make -j 4 + make install + + - name: Build YAC + if: steps.cache_yac.outputs.cache-hit != 'true' + run: | + curl -s -L https://gitlab.dkrz.de/dkrz-sw/yac/-/archive/v3.2.0/yac-v3.2.0.tar.gz | tar xvz + cd yac-v3.2.0 + ./configure CFLAGS="-fPIC" CC=mpicc FC=mpif90 --disable-mpi-checks \ + --with-yaxt-root=${{ runner.temp }}/yaxt --prefix=${{ runner.temp }}/yac + make -j 4 + make install + + - name: Build main + run: | + mkdir build + cmake -S ./ -B ./build \ + -DCMAKE_C_COMPILER=gcc \ + -DCMAKE_CXX_COMPILER=g++ \ + -DCMAKE_CXX_FLAGS="-Werror -Wall -pedantic -O3" \ + -DKokkos_ENABLE_SERIAL=ON \ + -DENABLE_YAC_COUPLING=ON \ + -DYAXT_ROOT=${{ runner.temp }}/yaxt \ + -DYAC_ROOT=${{ runner.temp }}/yac \ + -DCMAKE_MODULE_PATH=${PWD}/libs/coupldyn_yac/cmake + + - name: Compile main + run: cd build && make + + - name: Cache CLEO build + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/build/ + key: ${{ runner.os }}-cleo-build-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-cleo-build- + + compile_adia0d: + runs-on: ubuntu-latest + needs: build + steps: + - name: Setup + run: | + sudo apt-get update + sudo apt-get install -y \ + cmake libopenmpi-dev openmpi-bin + + - name: Restore YAXT Cache + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/yaxt/ + key: ${{ runner.os }}-yaxt-cache-v0.11.1 + + - name: Restore YAC Cache + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/yac/ + key: ${{ runner.os }}-yac-cache-v3.2.0 + + - name: Restore CLEO Build Cache + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/build/ + key: ${{ runner.os }}-cleo-build-${{ github.sha }} + + - name: Build adia0d + run: cd build && make adia0d + + compile_examples: + runs-on: ubuntu-latest + needs: build + strategy: + matrix: + target: [adia0d, golcolls, longcolls, lowlistcolls, szakallurbichcolls, testikstraubcolls, + const2d, divfree2d, eurec4a1d, rshaft1d, spdtest] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup + run: | + sudo apt-get update + sudo apt-get install -y \ + cmake libopenmpi-dev openmpi-bin + + - name: Restore YAXT Cache + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/yaxt/ + key: ${{ runner.os }}-yaxt-cache-v0.11.1 + + - name: Restore YAC Cache + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/yac/ + key: ${{ runner.os }}-yac-cache-v3.2.0 + + - name: Restore CLEO Build Cache + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/build/ + key: ${{ runner.os }}-cleo-build-${{ github.sha }} + + - name: Build + run: cd build && make ${{ matrix.target }} + + compile_yac_examples: + runs-on: ubuntu-latest + needs: build + strategy: + matrix: + target: [bubble3d, fromfile, fromfile_irreg] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup + run: | + sudo apt-get update + sudo apt-get install -y \ + cmake libnetcdff-dev liblapack-dev python3-dev \ + python3-numpy python3-mpi4py python3-pip curl \ + libfyaml-dev libopenmpi-dev openmpi-bin + + - name: Restore YAXT Cache + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/yaxt/ + key: ${{ runner.os }}-yaxt-cache-v0.11.1 + + - name: Restore YAC Cache + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/yac/ + key: ${{ runner.os }}-yac-cache-v3.2.0 + + - name: Restore CLEO Build Cache + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/build/ + key: ${{ runner.os }}-cleo-build-${{ github.sha }} + + - name: Build + run: cd build && make ${{ matrix.target }} diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index f5c1dc769..dff3535c6 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -10,7 +10,7 @@ jobs: uses: actions/checkout@v4 - name: Python setup - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 - name: Pre-commit run - uses: pre-commit/action@v3.0.0 + uses: pre-commit/action@v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3a3c8d026..8cd16e87a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,7 +39,10 @@ repos: rev: 0.8.0 hooks: - id: cpplint - args: [--linelength=100, "--filter=-runtime/references,-readability/braces,-build/include,-build/c++17"] + args: + - --linelength=100 + - --filter=-runtime/references,-readability/braces,-whitespace/indent_namespace, + -build/include,-build/c++11,-build/c++17 types_or: [c, c++, cuda] - repo: https://github.com/compilerla/conventional-pre-commit rev: v3.4.0