Skip to content
Open
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
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Program repos pin the release actions (actions/) at a devtools release, so
# updates to the actions they use land here once instead of in every program
# repo.
version: 2
updates:
- package-ecosystem: github-actions
directories:
- /
- /actions/*
schedule:
interval: monthly
groups:
actions:
patterns:
- "*"
149 changes: 149 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Tests for the release actions (actions/) and modules
# (modflow_devtools/release/): the modules, including the release workflow's
# stages against a local git remote and a fake gh, the workflow syntax, and
# the composite actions against a small Fortran program (autotest/release) on
# each released platform.
name: Release actions
on:
push:
paths:
- 'actions/**'
- 'modflow_devtools/release/**'
- 'autotest/release/**'
- 'autotest/test_release.py'
- 'docs/examples/**'
- '.github/workflows/actions.yml'
pull_request:
branches:
- main
- develop
paths:
- 'actions/**'
- 'modflow_devtools/release/**'
- 'autotest/release/**'
- 'autotest/test_release.py'
- 'docs/examples/**'
- '.github/workflows/actions.yml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PIXI_BETA_WARNING_OFF: true
jobs:
scripts:
name: Scripts
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7

- name: Setup uv
uses: astral-sh/setup-uv@v7

# the changelog tests run git-cliff with pipx
- name: Install
run: uv sync --group test

- name: Test
working-directory: autotest
run: uv run pytest -v test_release.py

lint:
name: Lint workflows
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7

- name: Run actionlint
run: |
bash <(curl -sSfL https://raw.githubusercontent.com/rhysd/actionlint/v1.7.7/scripts/download-actionlint.bash) 1.7.7
./actionlint -color .github/workflows/actions.yml

# the examples call each other, so lint them as a repo's workflows
- name: Lint examples
run: |
mkdir -p "$RUNNER_TEMP/examples/.github/workflows"
cp docs/examples/*.yml "$RUNNER_TEMP/examples/.github/workflows/"
git init -q "$RUNNER_TEMP/examples"
cd "$RUNNER_TEMP/examples" && "$GITHUB_WORKSPACE/actionlint" -color

actions:
name: Actions ${{ matrix.os }} ${{ matrix.compiler }} ${{ matrix.version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- {os: ubuntu-22.04, compiler: intel, version: "2025.0"}
- {os: macos-15, compiler: gcc, xcode-version: "16.4"}
- {os: windows-2022, compiler: intel, version: "2025.0"}
- {os: ubuntu-22.04, compiler: gcc}
- {os: windows-2022, compiler: gcc}
steps:
- name: Checkout
uses: actions/checkout@v7

- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: "3.12"

- name: Set version
shell: bash
working-directory: autotest/release
env:
PYTHONPATH: ${{ github.workspace }}
run: |
python -P -m modflow_devtools.release.version --set 1.2.3
[[ "$(python -P -m modflow_devtools.release.version --get)" == "1.2.3" ]]
grep -q "VERSION = '1.2.3 " src/hello.f90

- name: Setup
uses: ./actions/setup
with:
path: autotest/release
compiler: ${{ matrix.compiler }}
compiler-version: ${{ matrix.version }}
xcode-version: ${{ matrix.xcode-version }}

- name: Build and test
shell: bash
working-directory: autotest/release
run: |
pixi run setup builddir
pixi run build builddir
pixi run setup builddir-dble -Ddouble=true
pixi run build builddir-dble
pixi run test
pixi run meson test --no-rebuild -C builddir-dble

- name: Check linkage
uses: ./actions/check-linkage
with:
path: autotest/release/bin

- name: Package
id: package
uses: ./actions/package
with:
path: autotest/release

- name: Check archives
shell: bash
env:
DIST: ${{ steps.package.outputs.dist }}
OSTAG: ${{ steps.package.outputs.ostag }}
run: |
ls -l "$DIST"
python - "$DIST/$OSTAG.zip" <<'EOF'
import sys, zipfile
names = sorted(zipfile.ZipFile(sys.argv[1]).namelist())
print(names)
stems = sorted(n.removesuffix(".exe") for n in names)
assert stems == ["hello", "hellodbl"], names
EOF
if [[ "$RUNNER_OS" == "Linux" ]]; then
unzip -l "$DIST/hello_source.zip" | grep -q src/hello.f90
fi
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Python development tools for MODFLOW 6 and related projects.
- [`MODFLOW-ORG/modflow6-examples`](https://github.com/MODFLOW-ORG/modflow6-examples)
- [`MODFLOW-ORG/modflow6-testmodels`](https://github.com/MODFLOW-ORG/modflow6-testmodels)
- [`MODFLOW-ORG/modflow6-largetestmodels`](https://github.com/MODFLOW-ORG/modflow6-largetestmodels)
* GitHub Actions for building, packaging and releasing MODFLOW programs, see [release actions](docs/md/release.md)

## Requirements

Expand Down
29 changes: 29 additions & 0 deletions actions/check-linkage/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Check linkage
description: >
Check that every executable and shared library in a directory links only
libraries the operating system provides, so compiler runtimes must be
linked statically. On Linux, also require glibc 2.34 (RHEL 9) or older; on
macOS, require arm64 and a minimum macOS of 14.0. Fails if no binaries are
found or a file can't be inspected. See
modflow_devtools/release/linkage.py.
inputs:
path:
description: Directory holding the executables, searched recursively
default: bin
runs:
using: composite
steps:
- name: Setup Python
id: python
uses: actions/setup-python@v7
with:
python-version: "3.12"
update-environment: false

- name: Check linkage
shell: bash
env:
PYTHON: ${{ steps.python.outputs.python-path }}
PYTHONPATH: ${{ github.action_path }}/../..
BINDIR: ${{ inputs.path }}
run: '"$PYTHON" -P -m modflow_devtools.release.linkage "$BINDIR"'
68 changes: 68 additions & 0 deletions actions/package/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Package a MODFLOW program
description: >
Zip everything in bin/ as <ostag>.zip (linux, macarm or win64), with the
files at the archive root, and on Linux also zip the source as
<name>_source.zip, with the name from release.toml. The archives are made
the same way on every platform, with modflow_devtools/release/package.py.
Outputs the directory holding the archives, and optionally uploads them as
artifact dist-<ostag> for the release-finish action.
inputs:
path:
description: Directory holding the program, if not the repo root
default: .
source-paths:
description: >
Space-separated paths to put in the source archive, or `none` to skip
it; by default meson.build, meson.options (if present) and src
default: ""
upload:
description: >
Upload the archives as artifact dist-<ostag>; do this from one job per
platform in a release build
default: "false"
outputs:
ostag:
description: The platform tag
value: ${{ steps.package.outputs.ostag }}
dist:
description: Directory holding the archives
value: ${{ steps.package.outputs.dist }}
runs:
using: composite
steps:
- name: Setup Python
id: python
uses: actions/setup-python@v7
with:
python-version: "3.12"
update-environment: false

- name: Zip archives
id: package
shell: bash
working-directory: ${{ inputs.path }}
env:
PYTHON: ${{ steps.python.outputs.python-path }}
PYTHONPATH: ${{ github.action_path }}/../..
SOURCE_PATHS: ${{ inputs.source-paths }}
run: |
dist="$RUNNER_TEMP/dist"
args=(--dist "$dist")
if [[ "$SOURCE_PATHS" == "none" ]]; then
args+=(--source-paths)
elif [[ -n "$SOURCE_PATHS" ]]; then
read -ra paths <<< "$SOURCE_PATHS"
args+=(--source-paths "${paths[@]}")
fi
ostag=$("$PYTHON" -P -m modflow_devtools.release.package "${args[@]}")
ls -l "$dist"
echo "ostag=$ostag" >> "$GITHUB_OUTPUT"
echo "dist=$dist" >> "$GITHUB_OUTPUT"

- name: Upload archives
if: inputs.upload == 'true'
uses: actions/upload-artifact@v7
with:
name: dist-${{ steps.package.outputs.ostag }}
path: ${{ steps.package.outputs.dist }}/*.zip
if-no-files-found: error
82 changes: 82 additions & 0 deletions actions/release-finish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Finish a release
description: >
Last step of a release workflow, after the release-start action and the
build. For stage `prepare`, open the release pull request into the main
branch. For stage `publish`, download the dist-* artifacts uploaded by the
package action, check them, publish the GitHub release with them and any
extra assets, and open a pull request setting the next development version
on the development branch. Steps already done by an earlier run are
skipped, so a failed run can be rerun. Expects a checkout of the commit
being released. See modflow_devtools/release/workflow.py.
inputs:
path:
description: Directory holding the program, if not the repo root
default: .
stage:
description: The release-start action's stage output
required: true
ref:
description: The release-start action's ref output
required: true
version:
description: The release-start action's version output
required: true
main-branch:
description: Branch releases are merged into and tagged on
default: main
develop-branch:
description: Branch development happens on, if not the main branch
default: ""
extra-assets:
description: >
Newline-separated globs of other files to attach to the release, e.g.
documentation, matched relative to the checkout and to the downloaded
dist-* artifacts, so files built in other jobs can be uploaded as
dist-* artifacts. Each must match a file. These must include the
release notes asset, if release.toml names one.
default: ""
github-token:
description: Token for creating the release and pull requests
default: ${{ github.token }}
runs:
using: composite
steps:
- name: Setup Python
id: python
uses: actions/setup-python@v7
with:
python-version: "3.12"
update-environment: false

- name: Download archives
if: inputs.stage == 'publish'
uses: actions/download-artifact@v8
with:
pattern: dist-*
merge-multiple: true
path: ${{ runner.temp }}/dist

- name: Finish release
shell: bash
working-directory: ${{ inputs.path }}
env:
GH_TOKEN: ${{ inputs.github-token }}
PYTHON: ${{ steps.python.outputs.python-path }}
PYTHONPATH: ${{ github.action_path }}/../..
DIST: ${{ runner.temp }}/dist
STAGE: ${{ inputs.stage }}
REF: ${{ inputs.ref }}
VERSION: ${{ inputs.version }}
MAIN_BRANCH: ${{ inputs.main-branch }}
DEVELOP_BRANCH: ${{ inputs.develop-branch }}
EXTRA_ASSETS: ${{ inputs.extra-assets }}
run: |
extra=()
while IFS= read -r line; do
if [[ -n "${line//[[:space:]]/}" ]]; then extra+=("$line"); fi
done <<< "$EXTRA_ASSETS"
"$PYTHON" -P -m modflow_devtools.release.workflow \
--repository "$GITHUB_REPOSITORY" \
--main-branch "$MAIN_BRANCH" --develop-branch "$DEVELOP_BRANCH" \
finish --stage "$STAGE" --ref "$REF" --version "$VERSION" \
--dist "$DIST" --extra-assets "${extra[@]}"
Loading
Loading