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

Commit

Permalink
Develop (#3)
Browse files Browse the repository at this point in the history
* ci: initial implementation
* refactor: rename verify -> test, update README (#2)

Co-authored-by: jdhughes-usgs <jdhughes@usgs.gov>
  • Loading branch information
wpbonelli and jdhughes-usgs authored Sep 8, 2022
1 parent d8b576e commit ecc99e5
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 1 deletion.
38 changes: 38 additions & 0 deletions .github/workflows/commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI
on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Install gfortran
uses: ./
- name: Check installation
run: |
./scripts/test/test_install.sh /usr/local/bin/gfortran
test_windows:
name: Test (Windows)
runs-on: windows-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Install gfortran
uses: ./
- name: Check installation
shell: pwsh
run: |
./scripts/test/test_install.ps1
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ bin-release/
# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties`
# should NOT be excluded as they contain compiler settings and other important
# information for Eclipse / Flash Builder.

# IDE
.idea
45 changes: 44 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,45 @@
# install-gfortran-action
action to install gfortran compiler

[![CI](https://github.com/modflowpy/install-gfortran-action/actions/workflows/commit.yml/badge.svg?branch=develop)](https://github.com/modflowpy/install-gfortran-action/actions/workflows/commit.yml)
![Status](https://img.shields.io/badge/-under%20development-yellow?style=flat-square)

An action to install the [GNU Fortran](https://gcc.gnu.org/fortran/) compiler.

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Usage](#usage)
- [Install location](#install-location)
- [Linux](#linux)
- [MacOS](#macos)
- [Windows](#windows)
- [Disclaimer](#disclaimer)

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

## Usage

To use this action, add a step like the following to your workflow:

```yaml
- name: Install GNU Fortran
uses: modflowpy/install-gfortran-action@v0.0.1
```
## Install location
### Linux
On Linux `gfortran` version 10 is installed to `/usr/bin/gfortran-10` and symlinked to `/usr/local/bin/gfortran`.

### MacOS

On MacOS `gfortran` version 11 is installed to `/usr/local/bin/gfortran-11` and symlinked to `/usr/local/bin/gfortran`.

### 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.
73 changes: 73 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Install GNU Fortran
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
run: |
sudo ln -fs /usr/bin/gfortran-10 /usr/local/bin/gfortran
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
run: |
sudo ln -fs /usr/local/bin/gfortran-11 /usr/local/bin/gfortran
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
run: |
scripts/install/link-gfortranlib5.sh
- name: Print GNU compiler versions
if: runner.os != 'Windows'
shell: bash
run: |
gfortran --version
gcc --version
g++ --version
- name: Print GNU compiler versions (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
gfortran --version
gcc --version
g++ --version
6 changes: 6 additions & 0 deletions scripts/install/install-python-std.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

pip install wheel
pip install requests appdirs numpy matplotlib pytest pytest-xdist meson!=0.63.0 ninja
pip install https://github.com/modflowpy/flopy/zipball/develop
pip install https://github.com/modflowpy/pymake/zipball/master
7 changes: 7 additions & 0 deletions scripts/install/link-gfortranlib5.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/bash

FCDIR=/c/ProgramData/Chocolatey/bin
LNDIR=/c/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin
if [ -d "$FCDIR" ] && [ -f "$LNDIR/libgfortran-5.dll" ] && [ ! -f "$FCDIR/libgfortran-5.dll" ]; then
ln -s "$LNDIR/libgfortran-5.dll" "$FCDIR/libgfortran-5.dll"
fi
7 changes: 7 additions & 0 deletions scripts/test/test_install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

echo "Checking gfortran command"
if ((get-command "gfortran" -ErrorAction SilentlyContinue) -eq $null) {
echo "gfortran command is not available"
exit 1
}

24 changes: 24 additions & 0 deletions scripts/test/test_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

path="$1"
if [ -z "$path" ]
then
echo "Must specify path argument"
exit 1
fi

# check install location
echo "Checking install location: $path"
if [ ! -L "$path" ] # install dir is symlinked
then
echo "Install location does not exist: $path"
exit 1
fi

# check ifort executable
echo "Checking gfortran command"
if ! command -v gfortran &> /dev/null
then
echo "gfortran command is not available"
exit 1
fi

0 comments on commit ecc99e5

Please sign in to comment.