Exclude parsing of `public` statements in Julia v1.10 CI

Hi!

I am in the latest steps of setting up my repo for publishing and I am now setting up CI. My repo has some symbols declared as public for v1.11+ releases, but I want to keep compatibility in LTS (since there is no a priori incompatibility).

I have all my public declarations in a single file (public.jl), and I protect inclusion with what is recommended somewhere in Discourse:

VERSION >= v"1.11" && include("public.jl")

However, in CI, when no coverage is produced for the file, it tries to parse it with JuliaParse, which fails for Julia v1.10.

Is there a way to exclude this file for v1.10, or to avoid the errors in parsing?

1 Like

There are the possible solutions of either using the Compat.jl package or using

public_declarations = "public x,y,z"
VERSION >= v"1.11" && eval(meta.parse(public_declarations))

I cannot test it myself, but maybe it would work if you moved your public.jl file to a directory that is not a subdirectory of src, e.g. include("../publicdeclarations/public.jl").

1 Like

A multiline string holding all the public statements can be iterated over with eachsplit(..., "\n"), allowing eval(Meta.parse(...)) in a loop. Still, the proper thing to do would be not to parse conditionally include-d files when they’re not include-d, but I don’t know the inner workings to know how feasible that is to do.

What does this mean? What’s “it”?

See also

The codecov action (or whatever generates codecov files in Julia), detects that the file was not included when running Julia v1.10 and thus no codecov file was generated, and attempts to run the Julia parser directly on it to generate it. This is the step that fails.

I am away from my PC, but I’ll post screenshot as soon as I get back.

Yeah, I knew about this solution but I prefer to leave it as the last resort, because it is not very aesthetic :frowning:

Oh what am I thinking, we wouldn’t need to iterate a multi-line string and eval(Meta.parse(...)) each line ourselves, include’s underlying include_string(@__MODULE__, ...) is also API. I would still prefer that non-include-d files aren’t parsed by codecov, but the upside of this is you don’t need to move public statements to a separate file to dodge the v1.10- parsers in precompilation either.

1 Like

This is the report from the GitHub Action