diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2d99e27 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +# test based on ChatGPT's suggestion +name: CI + +on: [push, pull_request] # run for every push & PR + +jobs: + tests: + runs-on: ubuntu-latest # GitHub-hosted Linux runner + + steps: + # 1️⃣ Bring the source onto the runner + - name: Check out code + uses: actions/checkout@v4 + + # 2️⃣ System packages for build & tests + - name: Install build dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + build-essential gfortran make \ + libfftw3-dev liblapack-dev \ + python3 python3-numpy + + # 3️⃣ Compile the QDyn executable (bin ends up in src/qdyn) + - name: Build qdyn + run: | + make -C src clean + make -C src \ + LIBS="-lfftw3 -lm -llapack" # override local path in Makefile + + # 4️⃣ Run the full regression-test suite + - name: Run test suite + run: | + cd tests + bash run_test_suite.sh | tee ../test_output.log + + # 5️⃣ Fail the workflow if any test reported an error + - name: Check for test failures + run: | + if grep "ERROR found" test_output.log; then + echo "Some tests failed — see log above." + exit 1 + fi diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..a8c41c5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,46 @@ +name: Build and Test QDyn +# Suggestion from ChatGPT + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + # Checkout the code + - name: Checkout code + uses: actions/checkout@v3 + + # Install dependencies + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y gfortran make wget tar + + # Download, build, and install FFTW library + - name: Build and install FFTW + run: | + # Specify the FFTW version + FFTW_VERSION=3.3.10 + wget http://www.fftw.org/fftw-${FFTW_VERSION}.tar.gz + tar -xzf fftw-${FFTW_VERSION}.tar.gz + cd fftw-${FFTW_VERSION} + ./configure --enable-shared --prefix=/usr/local + make -j$(nproc) + sudo make install + cd .. + + # Build the project using make + - name: Build the project + run: make + + # Run tests using make + - name: Run tests + run: make tests \ No newline at end of file diff --git a/.github/workflows/test_v2.yml b/.github/workflows/test_v2.yml new file mode 100644 index 0000000..7ed57c6 --- /dev/null +++ b/.github/workflows/test_v2.yml @@ -0,0 +1,65 @@ +name: CI + +on: + push: + branches: [ "main" ] + pull_request: + +permissions: + contents: read + +env: + FORCE_COLOR: 1 + +jobs: + intel_build: + name: Intel OneAPI build + runs-on: ubuntu-20.04 + env: + FC: mpiifort + APT_PACKAGES: >- + intel-oneapi-compiler-fortran + intel-oneapi-mpi + intel-oneapi-mpi-devel + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + + # - name: Install fftw + # run: | + # echo "Entering FFTW folder" + # cd fftw + # echo "Unpacking FFTW" + # tar -xf fftw.tar.gz + # echo "Compiling FFTW" + # cd fftw + # bash compile.sh + + - name: Add Intel repository + run: | + wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list + sudo apt-get update + + - name: Install Intel oneAPI compiler + run: | + sudo apt-get install ${{ env.APT_PACKAGES }} + source /opt/intel/oneapi/setvars.sh + printenv >> $GITHUB_ENV + + - name: Install fftw & build QDyn + run: | + echo "Entering FFTW folder" + cd fftw + echo "Unpacking FFTW" + tar -xf fftw.tar.gz + echo "Compiling FFTW" + cd fftw + bash compile.sh + echo "Compile QDyn" + cd ../../src + make clean && make diff --git a/fftw/fftw.tar.gz b/fftw/fftw.tar.gz index c6481e5..03a7e5c 100644 Binary files a/fftw/fftw.tar.gz and b/fftw/fftw.tar.gz differ diff --git a/src/Makefile b/src/Makefile index 068e09d..c2c1904 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,12 +3,13 @@ # Compiler FC = gfortran FFLAGS = -#FFTW library needed -# LIBS = -L/home/janos/Programs/fftw/fftw-3.3.10/lib -lfftw3 -lm -llapack -# LIBS = -L/Users/janosj/Documents/Programs/fftw/fftw-3.3.10/lib -lfftw3 -lm +# FFTW library needed LIBS = -L/Users/janosj/Documents/Programs/fftw/fftw-3.3.10/lib -lfftw3 -lm -llapack LDLIBS = -lfftw3 # This is necessary only on clusters, not on MacOS +# for Github tests, I use different fftw library path +GitHub_LIBS = -L/usr/local/lib -lfftw3 -lm -llapack + # Name of program OUT = qdyn @@ -18,7 +19,10 @@ OUT = qdyn OBJS = vars.o fparser.o fftw.o utils.o init.o propag.o qdyn.o myprogram: $(OBJS) - $(FC) -o $(OUT) ${LIBS} ${FFLAGS} $(OBJS) ${LDLIBS} + $(FC) -o $(OUT) ${FFLAGS} $(OBJS) ${LIBS} ${LDLIBS} + +github-build: $(OBJS) + $(FC) -o $(OUT) ${GitHub_LIBS} ${FFLAGS} $(OBJS) ${LDLIBS} clean: /bin/rm -f *.o *.mod $(OUT)