Skip to content

Commit

Permalink
feat(ostag): add ostag input (#24)
Browse files Browse the repository at this point in the history
Support the ostag option for the get-modflow utility. Also a bit of cleanup in action.yml.
  • Loading branch information
wpbonelli authored Jun 24, 2024
1 parent 38062ce commit 3cf72d9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 16 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
tag: [ 'latest', '13.0' ]
tag: [ 'latest', '19.0' ]
defaults:
run:
shell: bash
Expand Down Expand Up @@ -213,4 +213,20 @@ jobs:
script_path="$RUNNER_TEMP/get_modflow.py"
python test/test.py "$TEST_BINDIR" "executables"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install with ostag (macOS)
if: runner.os == 'macOS'
uses: ./
with:
path: ${{ env.TEST_BINDIR}}
tag: latest
ostag: mac

- name: Test ostag (macOS)
if: runner.os == 'macOS'
run: |
script_path="$RUNNER_TEMP/get_modflow.py"
python test/test.py "$TEST_BINDIR" "executables"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39 changes: 25 additions & 14 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ inputs:
description: Tag of the release version to install
required: false
default: 'latest'
ostag:
description: Operating system tag; default is to automatically choose.
required: false
default: ''

outputs:
cache-hit:
Expand Down Expand Up @@ -121,6 +125,10 @@ runs:
subset=${subset//,/-} # replace commas with dashes
key="$key-$subset"
fi
if [[ "${{ inputs.ostag }}" != "" ]]; then
ostag="${{ inputs.ostag }}"
key="$key-$ostag"
fi
echo "key=$key" >> "$GITHUB_OUTPUT"
- name: Cache executables
Expand All @@ -135,26 +143,29 @@ runs:
if: inputs.cache != 'true' || steps.cache-modflow.outputs.cache-hit != 'true'
shell: bash
run: |
# compose arguments
args="--owner ${{ inputs.owner }} --repo ${{ inputs.repo }} --release-id ${{ inputs.tag }} --force"
if [[ "${{ inputs.subset }}" != "" ]]; then
args="$args --subset ${{ inputs.subset }}"
fi
if [[ "${{ inputs.ostag}}" != "" ]]; then
args="$args --ostag ${{ inputs.ostag }}"
fi
# download the installation script if necessary
if command -v get-modflow &> /dev/null
then
echo "get-modflow command is available, running get-modflow"
if [ "${{ inputs.subset }}" == "" ]; then
get-modflow "$MODFLOW_BIN_PATH" --owner "${{ inputs.owner }}" --repo "${{ inputs.repo }}" --release-id "${{ inputs.tag }}" --force
else
get-modflow "$MODFLOW_BIN_PATH" --owner "${{ inputs.owner }}" --repo "${{ inputs.repo }}" --release-id "${{ inputs.tag }}" --subset "${{ inputs.subset }}" --force
fi
echo "get-modflow command is available"
cmd="get-modflow"
else
echo "get-modflow command not available, downloading get_modflow.py"
echo "get-modflow command not available, downloading install script"
script_path="$RUNNER_TEMP/get_modflow.py"
curl https://raw.githubusercontent.com/modflowpy/flopy/develop/flopy/utils/get_modflow.py -o "$script_path"
echo "running get_modflow.py"
if [ "${{ inputs.subset }}" == "" ]; then
python3 $script_path "$MODFLOW_BIN_PATH" --owner "${{ inputs.owner }}" --repo "${{ inputs.repo }}" --release-id "${{ inputs.tag }}"
else
python3 $script_path "$MODFLOW_BIN_PATH" --owner "${{ inputs.owner }}" --repo "${{ inputs.repo }}" --release-id "${{ inputs.tag }}" --subset "${{ inputs.subset }}"
fi
cmd="python3 $script_path"
fi
echo "starting installation"
$cmd $MODFLOW_BIN_PATH $args
env:
GITHUB_TOKEN: ${{ steps.set-github-token.outputs.token }}

Expand Down

0 comments on commit 3cf72d9

Please sign in to comment.