Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 5ed9ffc

Browse files
Develop (#5)
* refactor: rename verify -> test * ci: test compile and run hello world * refactor: don't cache install locations (unnecessary) * docs: update README Co-authored-by: jdhughes-usgs <[email protected]>
1 parent ecc99e5 commit 5ed9ffc

File tree

6 files changed

+68
-46
lines changed

6 files changed

+68
-46
lines changed

.github/workflows/commit.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: CI
22
on:
33
push:
44
branches:
5-
- master
5+
- main
66
- develop
77
pull_request:
88
branches:
9-
- master
9+
- main
1010
- develop
1111
jobs:
1212
test:
@@ -17,22 +17,22 @@ jobs:
1717
matrix:
1818
os: [ ubuntu-latest, macos-latest ]
1919
steps:
20-
- name: Checkout repo
20+
- name: Checkout
2121
uses: actions/checkout@v3
22-
- name: Install gfortran
22+
- name: Install
2323
uses: ./
24-
- name: Check installation
24+
- name: Test
2525
run: |
26-
./scripts/test/test_install.sh /usr/local/bin/gfortran
26+
./scripts/test/test.sh /usr/local/bin/gfortran
2727
test_windows:
2828
name: Test (Windows)
2929
runs-on: windows-latest
3030
steps:
31-
- name: Checkout repo
31+
- name: Checkout
3232
uses: actions/checkout@v3
33-
- name: Install gfortran
33+
- name: Install
3434
uses: ./
35-
- name: Check installation
35+
- name: Test
3636
shell: pwsh
3737
run: |
38-
./scripts/test/test_install.ps1
38+
./scripts/test/test.ps1

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ An action to install the [GNU Fortran](https://gcc.gnu.org/fortran/) compiler.
1313
- [Linux](#linux)
1414
- [MacOS](#macos)
1515
- [Windows](#windows)
16-
- [Disclaimer](#disclaimer)
1716

1817
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
1918

@@ -26,6 +25,8 @@ To use this action, add a step like the following to your workflow:
2625
uses: modflowpy/[email protected]
2726
```
2827
28+
GNU fortran is pre-installed on runners for all three platforms, so there is no need to install it fresh &mdash; 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.
29+
2930
## Install location
3031
3132
### Linux
@@ -39,7 +40,3 @@ On MacOS `gfortran` version 11 is installed to `/usr/local/bin/gfortran-11` and
3940
### Windows
4041

4142
On Windows `gfortran` is installed via Chocolatey.
42-
43-
## Disclaimer
44-
45-
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.

action.yml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,6 @@ description: Install & cache GNU Fortran
33
runs:
44
using: composite
55
steps:
6-
- name: Cache gfortran (Linux)
7-
if: runner.os == 'Linux'
8-
id: cache-install-linux
9-
uses: actions/cache@v3
10-
with:
11-
path: |
12-
/usr/bin/gfortran-10
13-
/usr/bin/gcc-10
14-
/usr/bin/g++-10
15-
key: gfortran-${{ runner.os }}-${{ hashFiles('action.yml') }}
16-
176
- name: Symlink to gfortran (Linux)
187
if: runner.os == 'Linux'
198
shell: bash
@@ -22,17 +11,6 @@ runs:
2211
sudo ln -fs /usr/bin/gcc-10 /usr/local/bin/gcc
2312
sudo ln -fs /usr/bin/g++-10 /usr/local/bin/g++
2413
25-
- name: Cache gfortran (MacOS)
26-
if: runner.os == 'macOS'
27-
id: cache-install-macos
28-
uses: actions/cache@v3
29-
with:
30-
path: |
31-
/usr/local/bin/gfortran-11
32-
/usr/local/bin/gcc-11
33-
/usr/local/bin/g++-11
34-
key: gfortran-${{ runner.os }}-${{ hashFiles('action.yml') }}
35-
3614
- name: Symlink to gfortran (MacOS)
3715
if: runner.os == 'macOS'
3816
shell: bash
@@ -41,15 +19,6 @@ runs:
4119
sudo ln -fs /usr/local/bin/gcc-11 /usr/local/bin/gcc
4220
sudo ln -fs /usr/local/bin/g++-11 /usr/local/bin/g++
4321
44-
- name: Cache gfortran (Windows)
45-
if: runner.os == 'Windows'
46-
id: cache-install-windows
47-
uses: actions/cache@v3
48-
with:
49-
path: |
50-
/c/ProgramData/Chocolatey/
51-
key: gfortran-${{ runner.os }}-${{ hashFiles('action.yml', 'scripts/install/link-gfortranlib5.sh') }}
52-
5322
- name: Workaround for windows-2022 v20220626.1 gfortran executable run failures
5423
if: runner.os == 'Windows'
5524
shell: bash

scripts/test/hw.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
program hello
2+
print *, 'hello world'
3+
end program hello

scripts/test/test.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
if ((get-command "gfortran" -ErrorAction SilentlyContinue) -eq $null) {
2+
write-output "Command gfortran not available"
3+
exit 1
4+
} else {
5+
write-output "Command gfortran found"
6+
}
7+
8+
gfortran scripts/test/hw.f90 -o hw
9+
write-output "Compile succeeded"
10+
11+
$output=$(./hw)
12+
if ($output -match "hello world") {
13+
write-output $output
14+
} else {
15+
write-output "Unexpected output: $output"
16+
exit 1
17+
}

scripts/test/test.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
path="$1"
4+
if [ -z "$path" ]
5+
then
6+
echo "Must specify path argument"
7+
exit 1
8+
fi
9+
10+
if [ -L "$path" ] # install dir is symlinked
11+
then
12+
echo "Install location exists: $path"
13+
else
14+
echo "Install location doesn't exist: $path"
15+
exit 1
16+
fi
17+
18+
if command -v gfortran &> /dev/null
19+
then
20+
echo "Command gfortran available"
21+
else
22+
echo "Command gfortran not available"
23+
exit 1
24+
fi
25+
26+
gfortran scripts/test/hw.f90 -o hw
27+
echo "Compile succeeded"
28+
29+
output=$(./hw '2>&1')
30+
if [[ "$output" == *"hello world"* ]]
31+
then
32+
echo "$output"
33+
else
34+
echo "Unexpected output: $output"
35+
exit 1
36+
fi

0 commit comments

Comments
 (0)