Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ostag): add ostag input #24

Merged
merged 4 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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