From fc8685d24e1b66bc16fc58833e1d4684b6df2a58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Tue, 21 Jul 2020 15:56:30 -0600 Subject: Compile src/fpm.f90 only if it exists This now compiles hello_world --- fpm/src/fpm.f90 | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/fpm/src/fpm.f90 b/fpm/src/fpm.f90 index e1e52e9..85597c0 100644 --- a/fpm/src/fpm.f90 +++ b/fpm/src/fpm.f90 @@ -20,11 +20,24 @@ if (stat /= 0) then end if end subroutine +logical function exists(filename) result(r) +character(len=*), intent(in) :: filename +inquire(file=filename, exist=r) +end function + subroutine cmd_build() +logical :: src print *, "# Building project" -call run("gfortran -c src/fpm.f90 -o fpm.o") +src = exists("src/fpm.f90") +if (src) then + call run("gfortran -c src/fpm.f90 -o fpm.o") +end if call run("gfortran -c app/main.f90 -o main.o") -call run("gfortran main.o fpm.o -o fpm") +if (src) then + call run("gfortran main.o fpm.o -o fpm") +else + call run("gfortran main.o -o hello_world") +end if end subroutine end module fpm -- cgit v1.2.3 From 6de7f236b3784c7e2cf3b8cf3efc06ee5e84f2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Tue, 21 Jul 2020 16:00:00 -0600 Subject: Test hello_world at the CI --- .github/workflows/CI.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0de8b3e..574c565 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -88,3 +88,6 @@ jobs: fpm build fpm run fpm run --args build + cd ../test/example_packages/hello_world + ../../../fpm/fpm build + ./hello_world -- cgit v1.2.3 From 3bb8b39eccafc5acb0ee08a201c09aa0e828ce28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Tue, 21 Jul 2020 16:19:01 -0600 Subject: Extract the CI tests into a Bash and Batch files --- .github/workflows/CI.yml | 16 ++++++++-------- ci/run_tests.bat | 19 +++++++++++++++++++ ci/run_tests.sh | 10 ++++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) create mode 100755 ci/run_tests.bat create mode 100755 ci/run_tests.sh diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 574c565..784a0d6 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -82,12 +82,12 @@ jobs: cd bootstrap stack test - - name: Build and run Fortran fpm + - name: Build and run Fortran fpm (Linux / macOS) + if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos') run: | - cd fpm - fpm build - fpm run - fpm run --args build - cd ../test/example_packages/hello_world - ../../../fpm/fpm build - ./hello_world + ci/run_tests.sh + + - name: Build and run Fortran fpm (Windows) + if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos') + run: | + call ci/run_tests.bat diff --git a/ci/run_tests.bat b/ci/run_tests.bat new file mode 100755 index 0000000..258eae8 --- /dev/null +++ b/ci/run_tests.bat @@ -0,0 +1,19 @@ +@echo on + +cd fpm +if errorlevel 1 exit 1 + +fpm build +if errorlevel 1 exit 1 + +fpm run +if errorlevel 1 exit 1 + +fpm run --args build +if errorlevel 1 exit 1 + +cd ..\test\example_packages\hello_world +if errorlevel 1 exit 1 + +..\..\..\fpm\fpm build +if errorlevel 1 exit 1 diff --git a/ci/run_tests.sh b/ci/run_tests.sh new file mode 100755 index 0000000..9767c9a --- /dev/null +++ b/ci/run_tests.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -ex + +cd fpm +fpm build +fpm run +fpm run --args build +cd ../test/example_packages/hello_world +../../../fpm/fpm build -- cgit v1.2.3 From 62401a9a9d92b3f04c7faa5fbb828f978dfc82ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Tue, 21 Jul 2020 16:21:53 -0600 Subject: Use \ on Windows --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 784a0d6..a0d99d3 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -90,4 +90,4 @@ jobs: - name: Build and run Fortran fpm (Windows) if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos') run: | - call ci/run_tests.bat + call ci\run_tests.bat -- cgit v1.2.3 From 706f8a606ae42c162faff4def29cdd187f3b020a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Tue, 21 Jul 2020 16:22:47 -0600 Subject: CI: Use the correct condition on Windows --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a0d99d3..172806b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -88,6 +88,6 @@ jobs: ci/run_tests.sh - name: Build and run Fortran fpm (Windows) - if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos') + if: contains(matrix.os, 'windows') run: | call ci\run_tests.bat -- cgit v1.2.3 From 2506e0a8c1ffff60a7058142ac2f2d5325395085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Tue, 21 Jul 2020 16:26:49 -0600 Subject: Run hello_world --- ci/run_tests.bat | 3 +++ ci/run_tests.sh | 1 + 2 files changed, 4 insertions(+) diff --git a/ci/run_tests.bat b/ci/run_tests.bat index 258eae8..dcc9a8a 100755 --- a/ci/run_tests.bat +++ b/ci/run_tests.bat @@ -17,3 +17,6 @@ if errorlevel 1 exit 1 ..\..\..\fpm\fpm build if errorlevel 1 exit 1 + +.\hello_world +if errorlevel 1 exit 1 diff --git a/ci/run_tests.sh b/ci/run_tests.sh index 9767c9a..8f99a2c 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -8,3 +8,4 @@ fpm run fpm run --args build cd ../test/example_packages/hello_world ../../../fpm/fpm build +./hello_world -- cgit v1.2.3 From 3bd6db28fbd1392c2c883b48e7beb783114d0d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Tue, 21 Jul 2020 16:38:22 -0600 Subject: CI: Execute the bat file without "call" --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 172806b..4666022 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -90,4 +90,4 @@ jobs: - name: Build and run Fortran fpm (Windows) if: contains(matrix.os, 'windows') run: | - call ci\run_tests.bat + ci\run_tests.bat -- cgit v1.2.3