diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml index 0abd163..350708e 100644 --- a/.github/workflows/commit.yml +++ b/.github/workflows/commit.yml @@ -2,11 +2,11 @@ name: CI on: push: branches: - - master + - main - develop pull_request: branches: - - master + - main - develop jobs: test: @@ -17,22 +17,22 @@ jobs: matrix: os: [ ubuntu-latest, macos-latest ] steps: - - name: Checkout repo + - name: Checkout uses: actions/checkout@v3 - - name: Install gfortran + - name: Install uses: ./ - - name: Check installation + - name: Test run: | - ./scripts/test/test_install.sh /usr/local/bin/gfortran + ./scripts/test/test.sh /usr/local/bin/gfortran test_windows: name: Test (Windows) runs-on: windows-latest steps: - - name: Checkout repo + - name: Checkout uses: actions/checkout@v3 - - name: Install gfortran + - name: Install uses: ./ - - name: Check installation + - name: Test shell: pwsh run: | - ./scripts/test/test_install.ps1 \ No newline at end of file + ./scripts/test/test.ps1 diff --git a/README.md b/README.md index 498c486..5bc140a 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ An action to install the [GNU Fortran](https://gcc.gnu.org/fortran/) compiler. - [Linux](#linux) - [MacOS](#macos) - [Windows](#windows) -- [Disclaimer](#disclaimer) @@ -26,6 +25,8 @@ To use this action, add a step like the following to your workflow: uses: modflowpy/install-gfortran-action@v0.0.1 ``` +GNU fortran is pre-installed on runners for all three platforms, so there is no need to install it fresh — this action simply symlinks the compiler executable to a common location on Linux and MacOS and works around a Windows Server 2022 error preventing the default installation from working properly. + ## Install location ### Linux @@ -39,7 +40,3 @@ On MacOS `gfortran` version 11 is installed to `/usr/local/bin/gfortran-11` and ### Windows On Windows `gfortran` is installed via Chocolatey. - -## Disclaimer - -This software is preliminary or provisional and is subject to revision. It is being provided to meet the need for timely best science. The software has not received final approval by the U.S. Geological Survey (USGS). No warranty, expressed or implied, is made by the USGS or the U.S. Government as to the functionality of the software and related material nor shall the fact of release constitute any such warranty. The software is provided on the condition that neither the USGS nor the U.S. Government shall be held liable for any damages resulting from the authorized or unauthorized use of the software. diff --git a/action.yml b/action.yml index 918f17a..6a1f3cc 100644 --- a/action.yml +++ b/action.yml @@ -3,17 +3,6 @@ description: Install & cache GNU Fortran runs: using: composite steps: - - name: Cache gfortran (Linux) - if: runner.os == 'Linux' - id: cache-install-linux - uses: actions/cache@v3 - with: - path: | - /usr/bin/gfortran-10 - /usr/bin/gcc-10 - /usr/bin/g++-10 - key: gfortran-${{ runner.os }}-${{ hashFiles('action.yml') }} - - name: Symlink to gfortran (Linux) if: runner.os == 'Linux' shell: bash @@ -22,17 +11,6 @@ runs: sudo ln -fs /usr/bin/gcc-10 /usr/local/bin/gcc sudo ln -fs /usr/bin/g++-10 /usr/local/bin/g++ - - name: Cache gfortran (MacOS) - if: runner.os == 'macOS' - id: cache-install-macos - uses: actions/cache@v3 - with: - path: | - /usr/local/bin/gfortran-11 - /usr/local/bin/gcc-11 - /usr/local/bin/g++-11 - key: gfortran-${{ runner.os }}-${{ hashFiles('action.yml') }} - - name: Symlink to gfortran (MacOS) if: runner.os == 'macOS' shell: bash @@ -41,15 +19,6 @@ runs: sudo ln -fs /usr/local/bin/gcc-11 /usr/local/bin/gcc sudo ln -fs /usr/local/bin/g++-11 /usr/local/bin/g++ - - name: Cache gfortran (Windows) - if: runner.os == 'Windows' - id: cache-install-windows - uses: actions/cache@v3 - with: - path: | - /c/ProgramData/Chocolatey/ - key: gfortran-${{ runner.os }}-${{ hashFiles('action.yml', 'scripts/install/link-gfortranlib5.sh') }} - - name: Workaround for windows-2022 v20220626.1 gfortran executable run failures if: runner.os == 'Windows' shell: bash diff --git a/scripts/test/hw.f90 b/scripts/test/hw.f90 new file mode 100644 index 0000000..01a6865 --- /dev/null +++ b/scripts/test/hw.f90 @@ -0,0 +1,3 @@ +program hello + print *, 'hello world' +end program hello \ No newline at end of file diff --git a/scripts/test/test.ps1 b/scripts/test/test.ps1 new file mode 100755 index 0000000..5e8d7c8 --- /dev/null +++ b/scripts/test/test.ps1 @@ -0,0 +1,17 @@ +if ((get-command "gfortran" -ErrorAction SilentlyContinue) -eq $null) { + write-output "Command gfortran not available" + exit 1 +} else { + write-output "Command gfortran found" +} + +gfortran scripts/test/hw.f90 -o hw +write-output "Compile succeeded" + +$output=$(./hw) +if ($output -match "hello world") { + write-output $output +} else { + write-output "Unexpected output: $output" + exit 1 +} \ No newline at end of file diff --git a/scripts/test/test.sh b/scripts/test/test.sh new file mode 100755 index 0000000..74ecf7d --- /dev/null +++ b/scripts/test/test.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +path="$1" +if [ -z "$path" ] +then + echo "Must specify path argument" + exit 1 +fi + +if [ -L "$path" ] # install dir is symlinked +then + echo "Install location exists: $path" +else + echo "Install location doesn't exist: $path" + exit 1 +fi + +if command -v gfortran &> /dev/null +then + echo "Command gfortran available" +else + echo "Command gfortran not available" + exit 1 +fi + +gfortran scripts/test/hw.f90 -o hw +echo "Compile succeeded" + +output=$(./hw '2>&1') +if [[ "$output" == *"hello world"* ]] +then + echo "$output" +else + echo "Unexpected output: $output" + exit 1 +fi \ No newline at end of file