-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check env vars for non-Travis CI platforms #1067
Conversation
Special cases are now Travis, Gitlab, Drone, Cirrus and Appveyor. Not all of these CI services provide the same information as Travis does, or in the same way, so some massaging of variable contents is required. Appveyor is arguably one of the worse ones here. This is untested on most of these CI systems at the time this was committed; hence, any feedback is appreciated.
We will need some way to check which CI service is the "preferred uploader of documentation". Perhaps we could introduce a keyword argument to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! Can be merged as is as far as I can tell. Would you mind adding an entry to the CHANGELOG?
Goes a long way towards fixing #988. We're only missing BitBucket now I think. Regarding GitLab -- the assumption is that you'll still be pushing the pages to GitHub though, since GitLab pages uses a different system? |
Co-Authored-By: Morten Piibeleht <morten.piibeleht@gmail.com>
Yes, for now - I'll add a statement in the docs about that. It seems that with Gitlab CI you only need to push to a different folder, though, so that may not be too hard. They claim you can use any static site generator to create the website. |
Thanks for the review, @mortenpi and @fredrikekre! |
src/Writers/LaTeXWriter.jl
Outdated
@info "No tag detected..." | ||
else | ||
"" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation is a bit broken here.
But in any case -- this actually duplicates the code above. Could we refactor the if
into a function that we can re-use here and above?
I am also wondering if it might be better to make the @info
s @debug
s. Although, there might be value in being verbose about this automagic behavior here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can make it a function, will take a while though - dont have too much free time today, so maybe in the evening.
Was there are a reason, by the way, why you wanted to mark this "experimental"? |
Just because I haven't tested on all of these systems. |
Co-Authored-By: Morten Piibeleht <morten.piibeleht@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having the ability to easily deploy from manually is also a great thing to have. It might be worth iterating on it a bit though. One option is to do that in a separate PR, as not to hold up the CI service support stuff.
The documentation CI builds complains about missing docstrings in the manual. Could we put:
CI_SYSTEM
inlib/public.md
read_ci_env
inlib/internals/documenter.md
Co-Authored-By: Morten Piibeleht <morten.piibeleht@gmail.com>
Thanks @mortenpi for the extensive review! I've added comments in the reviews. I can separate the local dev changes into another PR (if this one is OK with tests and all), but it will take me some time - I'm sending my laptop out for repairs, and would need to set up the loaner... |
@mortenpi , sorry for the delay on this. I've removed the manual deployment stuff (I think) and this should be final if tests work. |
Hi, I see you are doing a lot of mingling of the environment variables - is that really necessary? Wouldn't a better solution be to leave it to the CI config, which already does a lot of that (although I am not sure it does everything) For example, instead of checking jobs:
include:
- stage: "Documentation"
if: type != pull_request
julia: 1.0
os: linux
script:
- julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd()));
Pkg.instantiate()'
- julia --project=docs/ docs/make.jl
after_success: skip https://docs.travis-ci.com/user/conditional-builds-stages-jobs/ That way, the core of Documenter can be (maybe entirely) CI-independent. Of course, supplying example configurations for some of the more common CIs would be great for the users. |
Follow up on my previous comment - a list of conditions on Travis, corresponding to the current checks:
What probably cannot be very easily replaced is the check for the existence of I haven't used Travis in several years, so maybe I got something wrong - in such a case I would be glad to be corrected. |
I think the logic here is that you want to be able to build documentation on every CI run, possibly inspect it, but not actually deploy it. |
Hmm, I see what you mean... On CircleCI I would then separate into 2 jobs the building of the docs from their deployment.... However, it seems to me now that I'm looking into the docs that in Travis, there is no easy way to share data between jobs :( So you'd need to have 2 jobs and build the docs in both and that is just bad design. I still think the deployment should be independent from the CI you are using, but as far as I can tell Travis offers no easy way to solve the problem you're taking about. |
By the way, regarding #1067 (comment) - yes, on GitLab, you don't push anything, you just tell the CI "this folder has the content of the pages". So you don't even need the |
@@ -13,7 +13,7 @@ navigation menu. It goes into the `\\title` LaTeX command. | |||
|
|||
""" | |||
module LaTeXWriter | |||
import ...Documenter: Documenter | |||
import ...Documenter: Documenter, read_ci_env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WARNING: could not import Documenter.read_ci_env into LaTeXWriter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you resolve this? I didn't see this locally myself. But is/was this due to read_ci_env
living in a submodule now?
Sorry for the delay with reviewing this, will take another look at the code tonight. @asinghvi17 is right in that the So I am not sure we want to decouple the deploy checks from That is not to say that there aren't refactorings that couldn't be done, but I think these things go beyond this PR. Feel free to open up a separate issue though to discuss this further.
That feature is only for private repositories, no?
I'd say that you'd still want one, ideally. The idea of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still a few things to work out here.
let tag = get(ENV, "TRAVIS_TAG", "") | ||
if occursin(Base.VERSION_REGEX, tag) | ||
let tag = read_ci_env()[:tag] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the empty line:
@@ -667,100 +695,106 @@ function git_push( | |||
end | |||
chmod(keyfile, 0o600) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we undo the changes below this line? They are pretty extensive, touching fragile code and not really relevant to the CI changes.
Please set the appropriate environment variables before you try to deploy. | ||
These environment variables can be seen in the documentation for `deploydocs`, | ||
which can be accessed by `?deploydocs` in the REPL. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. This will now print this error every time you build locally, which is a bit misleading. Could we just @info
here with a one-line comment about the CI
variable not being defined?
end | ||
|
||
# Get authentication key. | ||
documenter_key = get(ENV, "DOCUMENTER_KEY", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
documenter_key = get(ENV, "DOCUMENTER_KEY", "") | |
documenter_key = get(ENV, "DOCUMENTER_KEY", "") |
## The deploydocs' repo should match TRAVIS_REPO_SLUG | ||
repo_ok = occursin(travis_repo_slug, repo) | ||
## The deploydocs' repo should match the repo slug provided by CI | ||
repo_ok = occursin(repo_slug, repo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting a ERROR: LoadError: UndefVarError: repo_slug not defined
here.
@@ -13,7 +13,7 @@ navigation menu. It goes into the `\\title` LaTeX command. | |||
|
|||
""" | |||
module LaTeXWriter | |||
import ...Documenter: Documenter | |||
import ...Documenter: Documenter, read_ci_env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you resolve this? I didn't see this locally myself. But is/was this due to read_ci_env
living in a submodule now?
returnfinaldeploy && begin ret = (ret..., uploader = uploader == nothing) end | ||
|
||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not actually returning anything?
""" | ||
function read_ci_env(returnfinaldeploy=false; uploader::CI_SYSTEM = TRAVIS) | ||
|
||
arraylength = returnfinaldeploy ? 6 : 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused
Furthermore, if `returnfinaldeploy` is true, the function will check whether the | ||
current CI provider matches `uploader` (set by default to Travis). | ||
|
||
Returns a NamedTuple. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, for a more cleaner API here, it would be better if read_ci_env
would just return nothing
if the CI env can not be detected? That way the call sites do not have to do the haskey(ENV, "CI")
check, which may actually be different on different CI systems (in general). So instead, they would check if this returned nothing
or not, and decide whether we're in CI based on that.
@@ -188,6 +189,8 @@ end | |||
function writeheader(io::IO, doc::Documents.Document) | |||
custom = joinpath(doc.user.root, doc.user.source, "assets", "custom.sty") | |||
isfile(custom) ? cp(custom, "custom.sty"; force = true) : touch("custom.sty") | |||
|
|||
tag = haskey(ENV, "CI") ? read_ci_env(false)[:tag] : "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You pass false
here, but not above?
Not sure if the finaldeploy
check should really be in the read_ci_env
function like this in the first place.
Hi, However, it is probably too late to change that now and force users to have two files. I still stand behind the idea that CI logic should be left to the CI system and not to the deploy function. However, I am now not so sure how to do that properly. Regarding the GitLab pages issue, I agree, having the deploydocs function there and doing most of the work makes sense to me there. |
You are not wrong in the sense that we are currently missing a way to just easily deploy to We definitely want some API to just do deployment (which |
Any movement on this? I would love to add support for Azure Pipelines as well. |
I'll create a more minimized PR in a couple of days, hopefully that simplifies matters - I seem to have touched too much code here. |
This is very stale, so I'll go ahead an close this. Also, I think |
Special cases are now Travis, Gitlab, Drone, Cirrus and Appveyor.
Not all of these CI services provide the same information as Travis
does, or in the same way, so some massaging of variable contents is
required. Appveyor is arguably one of the worse ones here.
This is untested on most of these CI systems at the time this was
committed; hence, any feedback is appreciated.