Skip to content

Commit

Permalink
ci(release): fix nightly build
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Jul 19, 2024
1 parent 1fd801d commit ff403c1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
12 changes: 12 additions & 0 deletions .build_rtd_docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@
dst = os.path.join(dstdir, fpth)
shutil.copy(src, dst)

# -- build the deprecations table --------------------------------------------
print("Build the deprecations markdown table")
pth = os.path.join("..", "doc", "mf6io", "mf6ivar")
args = (sys.executable, "deprecations.py")
# run the command
proc = Popen(args, stdout=PIPE, stderr=PIPE, cwd=pth)
stdout, stderr = proc.communicate()
if stdout:
print(stdout.decode("utf-8"))
if stderr:
print("Errors:\n{}".format(stderr.decode("utf-8")))

# -- copy deprecations markdown ---------------------------------------------
print("Copy the deprecations table")
dstdir = "_mf6run"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
version: ${{ inputs.compiler_version }}
optimization: 2
parallel: false
- os: macos-13
- os: macos-12
compiler: ${{ inputs.compiler_toolchain }}
version: ${{ inputs.compiler_version }}
optimization: 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ jobs:
echo "models=$models" >> $GITHUB_OUTPUT
make_dist:
name: Make distribution
uses: MODFLOW-USGS/modflow6/.github/workflows/release.yml@develop
uses: wpbonelli/modflow6/.github/workflows/release.yml@fix-nightly-build
needs: set_options
with:
# If the workflow is manually triggered, the maintainer must manually set approve=true to approve a release.
Expand Down
19 changes: 14 additions & 5 deletions distribution/build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from datetime import datetime
from os import PathLike, environ
from pathlib import Path
from pprint import pprint
from pprint import pformat, pprint
from tempfile import TemporaryDirectory
from typing import List, Optional
from urllib.error import HTTPError
Expand Down Expand Up @@ -266,12 +266,13 @@ def build_mf6io_tex_from_dfn(
if overwrite:
clean_tex_files()

def files_match(tex_path, dfn_path, ignored):
def files_match(tex_path, dfn_path, included, ignored):
dfn_names = [
f.stem
for f in dfn_path.glob("*")
if f.is_file()
and "dfn" in f.suffix
and any(pattern in f.name for pattern in included)
and not any(pattern in f.name for pattern in ignored)
]
tex_names = [
Expand All @@ -282,10 +283,18 @@ def files_match(tex_path, dfn_path, ignored):
and not any(pattern in f.name for pattern in ignored)
]

return set(tex_names) == set(dfn_names)
tex = set(tex_names)
dfn = set(dfn_names)
diff = tex ^ dfn
assert not any(diff), (
f"=> symmetric difference:\n{pformat(diff)}\n"
f"=> tex - dfn:\n{pformat(tex - dfn)}\n"
f"=> dfn - tex:\n{pformat(dfn - tex)}\n"
)

with set_dir(PROJ_ROOT_PATH / "doc" / "mf6io" / "mf6ivar"):
ignored = ["appendix", "common"]
included = models + ["sim", "utl", "exg", "sln"]
tex_pth = Path("tex")
dfn_pth = Path("dfn")
tex_files = [f for f in tex_pth.glob("*") if f.is_file()]
Expand All @@ -308,11 +317,11 @@ def files_match(tex_path, dfn_path, ignored):
if models is not None and any(models):
for model in models:
args += ["--model", model]
out, err, ret = run_cmd(*args)
out, err, ret = run_cmd(*args, verbose=True)
assert not ret, out + err

# check that dfn and tex files match
assert files_match(tex_pth, dfn_pth, ignored)
assert files_match(tex_pth, dfn_pth, included, ignored)


@no_parallel
Expand Down
11 changes: 7 additions & 4 deletions doc/mf6io/mf6ivar/deprecations.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import os
from pathlib import Path
from typing import List, Optional, Tuple

from packaging.version import Version

PROJ_ROOT_PATH = Path(__file__).parents[3]
MF6IVAR_PATH = PROJ_ROOT_PATH / "doc" / "mf6io" / "mf6ivar"


def get_deprecations(
dfndir,
Expand Down Expand Up @@ -33,7 +35,7 @@ def get_deprecations(

def create_deprecations_file(dfndir, mddir, verbose):
deprecations = get_deprecations(dfndir)
deps_path = (Path(mddir) / "deprecations.md").absolute()
deps_path = (mddir / "deprecations.md").absolute()
if verbose:
print(f"Found {len(deprecations)} deprecations, writing {deps_path}")
with open(deps_path, "w") as f:
Expand All @@ -50,6 +52,7 @@ def create_deprecations_file(dfndir, mddir, verbose):


if __name__ == "__main__":
dfndir = os.path.join(".", "dfn")
mddir = os.path.join(".", "md")
dfndir = MF6IVAR_PATH / "dfn"
mddir = MF6IVAR_PATH / "md"
mddir.mkdir(exist_ok=True)
create_deprecations_file(dfndir, mddir, verbose=True)

0 comments on commit ff403c1

Please sign in to comment.