From b4ac9e916080a329e51298c4e8ac31bfafb9eab2 Mon Sep 17 00:00:00 2001 From: w-bonelli Date: Wed, 7 Sep 2022 16:58:35 -0400 Subject: [PATCH 1/2] ci: initial implementation --- .github/workflows/commit.yml | 38 ++++++++++++++ .gitignore | 3 ++ README.md | 29 ++++++++++- action.yml | 73 +++++++++++++++++++++++++++ scripts/install/install-python-std.sh | 6 +++ scripts/install/link-gfortranlib5.sh | 7 +++ scripts/verify/verify_install.ps1 | 7 +++ scripts/verify/verify_install.sh | 24 +++++++++ 8 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/commit.yml create mode 100644 action.yml create mode 100755 scripts/install/install-python-std.sh create mode 100755 scripts/install/link-gfortranlib5.sh create mode 100755 scripts/verify/verify_install.ps1 create mode 100755 scripts/verify/verify_install.sh diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml new file mode 100644 index 0000000..46febee --- /dev/null +++ b/.github/workflows/commit.yml @@ -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/verify/verify_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/verify/verify_install.ps1 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5d947ca..650a8b1 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/README.md b/README.md index ef14b10..4edf630 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,29 @@ # 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. + +## Usage + +To use this action, add a step like the following to your workflow: + +```yaml +- name: Install GNU Fortran + uses: modflowpy/install-gfortran-action@v1 +``` + +### 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. \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..918f17a --- /dev/null +++ b/action.yml @@ -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 \ No newline at end of file diff --git a/scripts/install/install-python-std.sh b/scripts/install/install-python-std.sh new file mode 100755 index 0000000..e4ebc7f --- /dev/null +++ b/scripts/install/install-python-std.sh @@ -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 diff --git a/scripts/install/link-gfortranlib5.sh b/scripts/install/link-gfortranlib5.sh new file mode 100755 index 0000000..275c2f9 --- /dev/null +++ b/scripts/install/link-gfortranlib5.sh @@ -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 diff --git a/scripts/verify/verify_install.ps1 b/scripts/verify/verify_install.ps1 new file mode 100755 index 0000000..2463020 --- /dev/null +++ b/scripts/verify/verify_install.ps1 @@ -0,0 +1,7 @@ + +echo "Checking gfortran command" +if ((get-command "gfortran" -ErrorAction SilentlyContinue) -eq $null) { + echo "gfortran command is not available" + exit 1 +} + diff --git a/scripts/verify/verify_install.sh b/scripts/verify/verify_install.sh new file mode 100755 index 0000000..7541804 --- /dev/null +++ b/scripts/verify/verify_install.sh @@ -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 \ No newline at end of file From a8b1c30c4603a7263c618a50cf4e5c57f3e8148b Mon Sep 17 00:00:00 2001 From: w-bonelli Date: Thu, 8 Sep 2022 11:29:03 -0400 Subject: [PATCH 2/2] refactor: rename verify -> test, update README (#2) --- .github/workflows/commit.yml | 4 +-- README.md | 28 +++++++++++++++---- .../test_install.ps1} | 0 .../test_install.sh} | 0 4 files changed, 24 insertions(+), 8 deletions(-) rename scripts/{verify/verify_install.ps1 => test/test_install.ps1} (100%) rename scripts/{verify/verify_install.sh => test/test_install.sh} (100%) diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml index 46febee..0abd163 100644 --- a/.github/workflows/commit.yml +++ b/.github/workflows/commit.yml @@ -23,7 +23,7 @@ jobs: uses: ./ - name: Check installation run: | - ./scripts/verify/verify_install.sh /usr/local/bin/gfortran + ./scripts/test/test_install.sh /usr/local/bin/gfortran test_windows: name: Test (Windows) runs-on: windows-latest @@ -35,4 +35,4 @@ jobs: - name: Check installation shell: pwsh run: | - ./scripts/verify/verify_install.ps1 \ No newline at end of file + ./scripts/test/test_install.ps1 \ No newline at end of file diff --git a/README.md b/README.md index 4edf630..498c486 100644 --- a/README.md +++ b/README.md @@ -5,25 +5,41 @@ An action to install the [GNU Fortran](https://gcc.gnu.org/fortran/) compiler. + + + +- [Usage](#usage) +- [Install location](#install-location) + - [Linux](#linux) + - [MacOS](#macos) + - [Windows](#windows) +- [Disclaimer](#disclaimer) + + + ## Usage To use this action, add a step like the following to your workflow: ```yaml - name: Install GNU Fortran - uses: modflowpy/install-gfortran-action@v1 + uses: modflowpy/install-gfortran-action@v0.0.1 ``` -### Install location +## Install location -#### Linux +### Linux On Linux `gfortran` version 10 is installed to `/usr/bin/gfortran-10` and symlinked to `/usr/local/bin/gfortran`. -#### MacOS +### MacOS On MacOS `gfortran` version 11 is installed to `/usr/local/bin/gfortran-11` and symlinked to `/usr/local/bin/gfortran`. -#### Windows +### Windows + +On Windows `gfortran` is installed via Chocolatey. + +## Disclaimer -On Windows `gfortran` is installed via Chocolatey. \ No newline at end of file +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/scripts/verify/verify_install.ps1 b/scripts/test/test_install.ps1 similarity index 100% rename from scripts/verify/verify_install.ps1 rename to scripts/test/test_install.ps1 diff --git a/scripts/verify/verify_install.sh b/scripts/test/test_install.sh similarity index 100% rename from scripts/verify/verify_install.sh rename to scripts/test/test_install.sh