Skip to content

Conda package attempt#75

Open
ilaflott wants to merge 49 commits intomainfrom
conda_package
Open

Conda package attempt#75
ilaflott wants to merge 49 commits intomainfrom
conda_package

Conversation

@ilaflott
Copy link
Copy Markdown
Member

@ilaflott ilaflott commented Jan 22, 2025

this PR:

  • adds meta.yaml and build.sh to define the conda build package recipe
  • adds environment.yml defining fully functional conda environment inwhich mkmf should work
  • puts all bin/ executables under a nested mkmf "package" directory for conda build recipe compatibility
  • adds a github workflow file to run conda build under github's CI/CD pipelines, conda build . --no-anaconda-upload version in .github/workflows/build_conda.yml, with uploading in .github/workflows/publish_conda.yml. run conditions identical to that of fre-cli
  • removes some old unused files (.travis.yaml, .gitlab-ci.yml)
  • adjust success condition of some tests, e.g. list_paths prints version regex reflect recent version strings
  • adjusts how t/t001-list_paths.sh does set-up, now creates t/src/file6.f90 symbolic link on-the-fly. removed at end of each of those tests
  • adjusts how every test does setup- checks PATH and adjusts only if needed. above file6.f90 link creation done on-the-fly for t/t003-mkmf.sh as well.
  • tests and package should work in the usual way with the usual level of functioning for all desired contexts

ilaflott and others added 2 commits January 22, 2025 17:05
…define build recipe in meta.yaml and relevant fields. define conda environment.
@ilaflott
Copy link
Copy Markdown
Member Author

green check, yes. note failures in pipeline...

…for test step. add git at dependency to see if it keeps the pipeline happy.
@ilaflott ilaflott marked this pull request as ready for review January 23, 2025 19:19
@ilaflott
Copy link
Copy Markdown
Member Author

ilaflott commented Jan 23, 2025

current testing state is odd.

In the pipeline, t/t001-list_paths.sh tests fail, tests #'s 1, 3, 5, 6, and 7 (see copied pipeline output). But, locally on my workstation, only the first test, 1 list_paths prints version fails.

+ bats t/t001-list_paths.sh
+ echo 'failure guard :-('

not ok 1 list_paths prints version
# (in test file t/t001-list_paths.sh, line 19)
#   `[[ "$output" =~ ^list_paths\ [0-9]+\.[0-9]+$ ]]' failed

not ok 3 list_paths using default out file
# (in test file t/t001-list_paths.sh, line 32)
#   `[ "$(wc -l < path_names)" -eq 6 ]' failed


not ok 5 list_paths find files in t and test_* directories
# (in test file t/t001-list_paths.sh, line 44)
#   `[ "$(wc -l < path_names)" -eq 8 ]' failed

not ok 6 list_paths find specific files in t or test_* directories
# (in test file t/t001-list_paths.sh, line 51)
#   `[ "$(wc -l < path_names)" -eq 7 ]' failed

not ok 7 list_paths with specified out file
# (in test file t/t001-list_paths.sh, line 59)
#   `[ "$(wc -l < $outFileName)" = "6" ]' failed

Additionally, in the pipeline, all t/t002-git-version-string.sh tests fail, and yet locally on my workstation, all of these tests pass. I suppose i'm not entirely surprised by this because i've seen github's CI/CD has been weird about calling git commands directly in the past.

+ bats t/t002-git-version-string.sh
+ echo 'failure guard :-('

…move most unneeded failure-guarding shell commands.
…nge approach to resolving binDir in t/t001-list_paths- should possibly keep the pipeline happier. include mkmf in source files for test step of conda build. more echos, switch spot of echo output to avoid adjusting status of last-called shell command.
…he testing approach makes perfect sense locally- so why isnt the pipeline happy?
…tween string and ints in test success condition checks
…slowing this pipeline down for its own good!! (maybe...)
@ilaflott
Copy link
Copy Markdown
Member Author

AHA! the failure in githhub's pipeline arises because the command there, for some reason, resolves the symbolic link file file6.linked in t/src to file file6.f90 with one of the targeted extensions.

a little more simply: locally, the test list_paths using default out file in t/t001-list_paths.sh should ignore a link and only find 6 files. In github CI/CD, the symbolic link is resolved and it finds 7 files resulting in failure.

@ilaflott
Copy link
Copy Markdown
Member Author

relatively sure that once conda build . enters the test phase, the source_files key specifying t/ likely copies the directory with a command ala cp -L -r t/ <target_dir>, and is de-referencing the link to file6.f90, changing the answers in the list_files tests. i adjusted the answers accordingly, but this is honestly bad practice.

the git based tests in t still do not work in the pipeline but work fine for me locally.

@ceblanton
Copy link
Copy Markdown
Contributor

It looks great, thanks!

The noaa-gfdl channel is not needed for building, is it?

What do you think about throwing in the noaa-gfdl anaconda channel key and having this pipeline publish as well as build. Too soon?

It's odd that the tests needing adjusting (but then again I hadn't realized there were mkmf tests. :)

@ilaflott
Copy link
Copy Markdown
Member Author

ilaflott commented Jan 23, 2025

The noaa-gfdl channel is not needed for building, is it?

nope!

What do you think about throwing in the noaa-gfdl anaconda channel key and having this pipeline publish as well as build. Too soon?

no we can do it- i'll maybe say it should stick with an alpha version tag for now... at most, beta

It's odd that the tests needing adjusting (but then again I hadn't realized there were mkmf tests. :)

100% conda build is derefencing links found in specified source files for the testing step! idk what the best way to deal with that is and not lose true quality control.

put conda-relevant things in README- adjust markdown, update dependencies discussed. put disclaimer+license at the bottom of the readme to emphasize usage, installation, featurres etc.
update badge
@ilaflott
Copy link
Copy Markdown
Member Author

Let's chat for a minute in-person on this when we can

@ilaflott
Copy link
Copy Markdown
Member Author

The templates should be a separate repository, as they're not really used by this repository out of necessity- they are a convenience for prospective users.

We're informing this view point with the following:

  1. all mkmf does with the value given to -t is stick the value as-is into the output Makefile, and the template is not read nor it's contents used programmatically by mkmf.
> mkmf -t FOO
. Makefile is ready.

> cat Makefile | grep TEMPLATE
MK_TEMPLATE = FOO
include $(MK_TEMPLATE)
  1. no one to our knowledge is relying on the templates in this repo as being in a particular spot directory-structure wise.

ilaflott and others added 4 commits January 28, 2025 11:42
slightly adjust current README instructions
test-run publish_conda workflow by asking it to run on push to `conda_package` branch, see what happens!
@ilaflott ilaflott closed this May 8, 2025
@ilaflott ilaflott reopened this Jun 24, 2025
Copy link
Copy Markdown
Member

@underwoo underwoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some changes, or additional information needed.

ilaflott and others added 5 commits February 24, 2026 15:14
Removed 'conda-forge::tcsh' from host, run, and test requirements.
…list (targeting #75 review)

meta.yaml:
- Add build steps to copy templates/* to $PREFIX/share/mkmf/templates/
  so the templates are part of the conda package and discoverable by
  downstream tools (e.g. fre-cli) at a stable, predictable path:
    mkmf -t $CONDA_PREFIX/share/mkmf/templates/<name>.mk

t/t004-templates.sh:
- setup(): detect conda context via $PREFIX env var and set templateDir
  to the installed location; fall back to in-source templates/ otherwise
- Remove stale template tests that no longer exist in templates/:
    ncrc-cray.mk, ncrc-gnu.mk, ncrc-pgi.mk, ncrc-intel.mk
- Add tests for all templates that currently exist in templates/:
    hpcme-intel2025.03-oneapi.mk, hpcme-intel21/23/24.mk,
    linux-intel.mk, ncrc-nvhpc.mk, ncrc4-cce/gcc/intel.mk,
    ncrc5-cce/gcc/intel/intel-classic/intel-oneapi.mk
t000, t001, t002, t003, t004 — PATH check (underwoo line 8 / 'see above'):
- Replace fragile 'do_we_have_mkmf=$(which mkmf) || echo ...' pattern
  with 'if [ $(command -v mkmf) ]' as suggested
- Add comment explaining the dual-mode rationale: conda-installed copy is
  already on PATH and is the copy under test; local dev adds bin/ so the
  working copy is exercised instead of any system copy

t001 — symlink isolation (underwoo lines 14 and 24):
- setup(): create testDir first, copy t/src/ into it, create the
  file6.f90 symlink inside testDir/src/ instead of in the real source tree
  so teardown cleans it automatically and a killed test leaves no residue
- teardown(): remove the now-unnecessary 'rm -f .../src/file6.f90' line
- Update all test invocations from BATS_TEST_DIRNAME/src -> testDir/src

t001 — count_lines usage (underwoo line 44):
- Apply count_lines() helper to all seven 'cat file | wc -l' sites

t003 — symlink isolation (same class as t001):
- Same setup/teardown changes: copy src to testDir, symlink inside testDir
- Update all BATS_TEST_DIRNAME/src references in test bodies to testDir/src
  including path-matching regexes in 'mkmf finds sources in directory'
  and 'mkmf finds include files in -I<INCLUDE>'

t004 — fix syntax error from previous commit:
- Restore missing testDir creation, cd, and teardown() that were
  accidentally dropped; setup() was left unclosed causing bats parse error
….yaml

- Remove tcsh dependency from environment.yml per underwoo's review
  (tcsh is not used in any mkmf tools)
- Remove bats-core from host: and run: requirements in meta.yaml
  (bats-core is a test runner, not a runtime dependency; it remains
  in test.requires where it belongs)
Address underwoo's follow-up review comment: the old approach skipped
the PATH prepend when mkmf was already found on PATH, which could
silently test a stale or unrelated copy and hide real failures.

New approach: always prepend the appropriate directory to PATH.
- In conda build test environments ($PREFIX set): use $PREFIX/bin
  where the just-built package was installed.
- In local development: use the repo's own mkmf/bin/ directory.

This ensures the tests always exercise the intended copy of mkmf
regardless of what else is on the user's PATH.
Replace the if/else pattern that silently fell back to the repo's
mkmf/bin/ directory with a two-step approach:

1. In conda build/test ($PREFIX set), prepend $PREFIX/bin to PATH
2. Verify mkmf is on PATH; if not, error out with an actionable message
   telling the user to add mkmf/bin to their PATH

This addresses underwoo's review feedback: the old else branch could
resolve a path that doesn't work and mask the real failure.  Now,
missing mkmf always causes an immediate, clear failure.
Runs bats tests directly against the repo checkout using system
perl and bats from apt, exercising the local-development PATH
setup in the test harness.
On pull_request: build only (test).
On push to main: build and publish to anaconda.org using ANACONDA_TOKEN.
Removes the now-redundant publish_conda workflow.
@ilaflott
Copy link
Copy Markdown
Member Author

ilaflott commented Mar 12, 2026

I decided that those testing locally checked out code will be yelled at by the tests if they have no added mkmf's executables to PATH by hand. This case is covered by the new, non-conda oriented test workflow. conda build still covers the package use-case

edit: .github/workflow/test.yml not failing nor succeeding- stalling. why?

Replace 'tr < /dev/urandom | fold | head' pipelines with bounded
'dd bs=45 count=1 | base64' approach.  The old pipeline can hang
when SIGPIPE delivery to tr is delayed, which was observed on bare
ubuntu-latest runners (the conda container was unaffected).
@ilaflott
Copy link
Copy Markdown
Member Author

Looks like this is ready for round 2.

@ilaflott
Copy link
Copy Markdown
Member Author

NOAA-GFDL/fre-cli#774 checks the compatibility of this with fre-cli's current usage. should be usable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

a basic conda package build and environment conda package upload to noaa-gfdl for initial use and testing of aforementioned packaging scheme.

4 participants