Skip to content

Commit

Permalink
fix: CI, tests & modpathfile
Browse files Browse the repository at this point in the history
* fix ci.yml -> commit.yml
* fix modflowpy#1491: workaround intermittent macos CI matplotlib failures
* fix modflowpy#1479: sort in child's ctor instead of _ModpathSeries.get_data()
* don't plt.show() in tests
* add comments to conftest.py
* give test_mt3d.py::test_mfnwt_CrnkNic more retries
* skip ex-gwtgwt-mt3dms-p10 mf6 example (per MODFLOW-USGS/modflow6#1008)
* rename release/ to scripts/
* move pull_request_prepare.py to scripts/
* add postprocess_benchmarks.py to scripts/
* separate CI workflows for benchmarks, examples and regression tests
* name benchmark CI artifacts benchmarks-<system>-python version>-<run ID>
* add CI job to post-process benchmarks (creates artifact benchmarks-<run ID>)
* add cross-platform CI action to cache modflow exes & invalidate on new release
* reenable PathlineFile.get_destination_pathline_data() benchmark
* don't upload coverage after smoke tests, benchmarks, regression tests and example tests
* upload coverage on PR as well as push (fix codecov bot comments)
* decrease coverage precision to 1 decimal place (avoid small deltas)
* update to codecov action v3
  • Loading branch information
wpbonelli committed Aug 19, 2022
1 parent c9e6f61 commit 9444ea9
Show file tree
Hide file tree
Showing 25 changed files with 1,043 additions and 749 deletions.
111 changes: 111 additions & 0 deletions .github/actions/cache_exes/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Cache Modflow executables
description: 'Cache MODFLOW executables from the MODFLOW-USGS/executables repository'
inputs:
path:
description: 'The path to store the executables (e.g. a bin directory)'
required: true
default: 'bin'
os:
description: 'The runner operating system'
required: true
github_token:
description: 'The GitHub API access token'
required: true
runs:
using: "composite"
steps:
- name: Make bin directory
if: runner.os != 'Windows'
shell: bash
run: |
mkdir -p ${{ inputs.path }}
- name: Make bin directory (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
md -Force ${{ inputs.path }}
- name: Check release
if: runner.os != 'Windows'
shell: bash
run: |
# get info for the executables repository's latest release
release_json=$(gh api -X GET -H "Accept: application/vnd.github+json" /repos/MODFLOW-USGS/executables/releases/latest)
# get asset ID of the release's metadata file, if one exists
get_asset_id="
import json
import sys
release = json.load(sys.stdin, strict=False)
metadata = next(iter([a for a in release['assets'] if a['name'] == 'code.json']), None)
print(dict(metadata)['id'] if metadata else '')
"
asset_id=$(echo "$release_json" | python -c "$get_asset_id")
# asset_id is empty if metadata file asset wasn't found
if [ ${#asset_id} -gt 0 ]; then
gh api -H "Accept: application/octet-stream" "/repos/MODFLOW-USGS/executables/releases/assets/$asset_id" >> executables.json
else
# give hashFiles an empty file to hash
touch executables.json
fi
env:
GH_TOKEN: ${{ inputs.github_token }}

- name: Check release (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
# get info for the executables repository's latest release
$release_json=(gh api -X GET -H "Accept: application/vnd.github+json" /repos/MODFLOW-USGS/executables/releases/latest)
# get asset ID of the release's metadata file, if one exists
$pattern="code.json"
$release=(echo $release_json | ConvertFrom-Json)
$asset_id=($release.assets | Where-Object {$_.name -match "$pattern"} | % {echo $_.id})
# asset_id is empty if metadata file asset wasn't found
if ($asset_id.Length -gt 0) {
gh api -H "Accept: application/octet-stream" "/repos/MODFLOW-USGS/executables/releases/assets/$asset_id" >> executables.json
} else {
# give hashFiles an empty file to hash
New-Item -Name "executables.json" -ItemType File
}
env:
GH_TOKEN: ${{ inputs.github_token }}

- name: Cache executables
id: cache_executables
uses: actions/cache@v3
with:
path: ${{ inputs.path }}
key: modflow-exes-${{ inputs.os }}-${{ hashFiles('executables.json') }}

- name: Install executables
if: runner.os != 'Windows' && steps.cache_executables.outputs.cache-hit != 'true'
shell: bash
run: |
get-modflow ${{ inputs.path }}
env:
GITHUB_TOKEN: ${{ inputs.github_token }}

- name: Install executables (Windows)
if: runner.os == 'Windows' && steps.cache_executables.outputs.cache-hit != 'true'
shell: pwsh
run: |
get-modflow ${{ inputs.path }}
env:
GITHUB_TOKEN: ${{ inputs.github_token }}

- name: Add executables to path
if: runner.os != 'Windows'
shell: bash
run: |
echo ${{ inputs.path }} >> $GITHUB_PATH
- name: Add executables to path (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
echo ${{ inputs.path }} | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
62 changes: 62 additions & 0 deletions .github/actions/cache_exes_win/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 'Cache executables (Windows)'
description: 'Cache MODFLOW executables from the MODFLOW-USGS/executables repository (Windows)'
inputs:
path:
description: 'The path to store the executables (e.g. a bin directory)'
required: true
default: 'bin'
os:
description: 'The runner operating system'
required: true
github_token:
description: 'The GitHub API access token'
required: true
runs:
using: "composite"
steps:
- name: Make bin directory
shell: pwsh
run: |
md -Force ${{ inputs.path }}
- name: Check release
shell: pwsh
run: |
# get info for the executables repository's latest release
$release_json=(gh api -X GET -H "Accept: application/vnd.github+json" /repos/MODFLOW-USGS/executables/releases/latest)
# get asset ID of the release's metadata file, if one exists
$pattern="code.json"
$release=(echo $release_json | ConvertFrom-Json)
$asset_id=($release.assets | Where-Object {$_.name -match "$pattern"} | % {echo $_.id})
# asset_id is empty if metadata file asset wasn't found
if ($asset_id.Length -gt 0) {
gh api -H "Accept: application/octet-stream" "/repos/MODFLOW-USGS/executables/releases/assets/$asset_id" >> executables.json
} else {
# give hashFiles an empty file to hash
New-Item -Name "executables.json" -ItemType File
}
env:
GH_TOKEN: ${{ inputs.github_token }}

- name: Cache executables
id: cache_executables
uses: actions/cache@v3
with:
path: ${{ inputs.path }}
key: modflow-exes-${{ inputs.os }}-${{ hashFiles('executables.json') }}

- name: Install executables (Windows)
if: steps.cache_executables.outputs.cache-hit != 'true'
shell: pwsh
run: |
get-modflow ${{ inputs.path }}
env:
GITHUB_TOKEN: ${{ inputs.github_token }}

- name: Add executables to path (Windows)
if: runner.os == "Windows"
shell: pwsh
run: |
echo ${{ inputs.path }} | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
Loading

0 comments on commit 9444ea9

Please sign in to comment.