Skip to content
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

Fix deployment of docs to netlify #34984

Merged
merged 14 commits into from
Feb 13, 2023
Merged

Conversation

tobiasdiez
Copy link
Contributor

@tobiasdiez tobiasdiez commented Feb 6, 2023

Normally, on github, netlify takes care of the build + deploy fully automatically. However, our build takes to long so that we would hit the free build mins relatively quickly. So we continue deploying the docs via github actions. But PR workflows don't have access to secrets, so we need to split the upload of the docs in a new workflow, see https://securitylab.github.com/research/github-actions-preventing-pwn-requests/.

Moreover, the netlify deploy cli doesn't take care of adding a PR comment and status check linking to the deployed website (netlify does this automatically if it would build + deploy the page). So we add this functionality manually.

@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2023

Codecov Report

Base: 88.60% // Head: 88.58% // Decreases project coverage by -0.02% ⚠️

Coverage data is based on head (0a676e1) compared to base (c000c95).
Patch has no changes to coverable lines.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #34984      +/-   ##
===========================================
- Coverage    88.60%   88.58%   -0.02%     
===========================================
  Files         2136     2136              
  Lines       396142   396142              
===========================================
- Hits        350990   350923      -67     
- Misses       45152    45219      +67     
Impacted Files Coverage Δ
src/sage/categories/super_modules_with_basis.py 96.29% <0.00%> (-3.71%) ⬇️
src/sage/homology/matrix_utils.py 84.40% <0.00%> (-3.67%) ⬇️
...e/combinat/cluster_algebra_quiver/mutation_type.py 50.11% <0.00%> (-2.62%) ⬇️
src/sage/interfaces/qsieve.py 71.30% <0.00%> (-2.61%) ⬇️
src/sage/modular/local_comp/liftings.py 98.33% <0.00%> (-1.67%) ⬇️
...rc/sage/categories/super_lie_conformal_algebras.py 95.00% <0.00%> (-1.67%) ⬇️
...onformal_algebras/lie_conformal_algebra_element.py 95.52% <0.00%> (-1.50%) ⬇️
src/sage/schemes/elliptic_curves/hom_velusqrt.py 94.48% <0.00%> (-1.19%) ⬇️
src/sage/coding/channel.py 97.10% <0.00%> (-0.73%) ⬇️
src/sage/groups/generic.py 88.34% <0.00%> (-0.68%) ⬇️
... and 20 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@kwankyu
Copy link
Collaborator

kwankyu commented Feb 6, 2023

Did you do something to automatically add the "Codecov Report" for every PR?

I hate it. It looks like a spam. It is distracting than helpful. I looked at it for some time, but I still don't know what it's doing.

Please turn it off. Or make it one of the checks.

@tobiasdiez tobiasdiez marked this pull request as ready for review February 7, 2023 08:03
@tobiasdiez
Copy link
Contributor Author

tobiasdiez commented Feb 7, 2023

This should do it. However, the "publish docs" workflow need to be included in the default branch to run, so I'm not sure how to test it (maybe in my fork once #34983 is reviewed).

Did you do something to automatically add the "Codecov Report" for every PR?

Yes, this is part of #33355. I agree that the comments are not very helpful and reliable at the moment. But this is due to the rename of the sage repo, which confused codecov. Should be fixed with the next beta release. If you then still have issues, please open a new issue.

Copy link
Member

@mkoeppe mkoeppe left a comment

Choose a reason for hiding this comment

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

LGTM, nice solution to split it up.
I am assuming that you have tested the deployment workflow.

@tobiasdiez
Copy link
Contributor Author

Sorry, I was a bit too quick with adding the "needs review" label. But now everything should work. A preview can be found at tobiasdiez#2 (with the added comment + status check).

@@ -15,14 +15,13 @@ jobs:
build-docs:
runs-on: ubuntu-latest
container: ghcr.io/sagemath/sage/sage-docker-ubuntu-focal-standard-with-targets:dev
env:
CAN_DEPLOY: ${{ secrets.NETLIFY_AUTH_TOKEN != '' }}
Copy link
Member

Choose a reason for hiding this comment

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

I think this conditionalization should not be dropped but moved into the new doc-publish workflow.
We don't want the doc-publish workflow to fail on users' repos that have GH Actions enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't want the doc-publish workflow to fail on users' repos that have GH Actions enabled.

Why not? It's not doing its intended job and a red workflow doesn't hurt anyone. Don't you think its better to be notified by the failing workflow in case the auth token is not config correctly in the main repo?

Copy link
Member

@mkoeppe mkoeppe Feb 10, 2023

Choose a reason for hiding this comment

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

If you want to have this kind of monitoring in our main repo, restrict the error to that repo only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your suggestion, but I don't plan to invest more time into what feels like an edge case. If you (or someone else) gets annoyed by the red workflow and you don't want to setup your own netlify deploy, you can simply disable this workflow in the github ui (or change the config in your default branch).

Copy link
Member

Choose a reason for hiding this comment

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

It was already implemented.
Just don't cut it out.

@mkoeppe
Copy link
Member

mkoeppe commented Feb 11, 2023

Reviewer's patch:

commit 2a17508774e83fd273bc5b76338f4003894f3061 (HEAD -> fix-netlify)
Author: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
Date:   Fri Feb 10 23:08:59 2023 -0800

    .github/workflows/doc-publish.yml: Restore CAN_DEPLOY

diff --git a/.github/workflows/doc-publish.yml b/.github/workflows/doc-publish.yml
index c7be4a46d3..b743ea722e 100644
--- a/.github/workflows/doc-publish.yml
+++ b/.github/workflows/doc-publish.yml
@@ -13,10 +13,13 @@ permissions:
   checks: write
   pull-requests: write
 
+env:
+  CAN_DEPLOY: ${{ secrets.NETLIFY_AUTH_TOKEN != '' }}
+
 jobs:
   upload-docs:
     runs-on: ubuntu-latest
-    if: github.event.workflow_run.conclusion == 'success'
+    if: github.event.workflow_run.conclusion == 'success' && (env.CAN_DEPLOY == 'true' || github.repository == 'sagemath/sage')
     steps:
       - name: Get information about workflow origin
         uses: potiuk/get-workflow-origin@v1_5

@tobiasdiez
Copy link
Contributor Author

Did you tried that? I had something similar: 1c8c63f and ad38d45

Also, this disables the check in other repos that want to enable netlify deploy and be notified about errors...

@mkoeppe
Copy link
Member

mkoeppe commented Feb 11, 2023

I had something similar: 1c8c63f and ad38d45

Yes, these two cannot work.

@mkoeppe
Copy link
Member

mkoeppe commented Feb 11, 2023

enable netlify deploy and be notified about errors...

Protecting against the failure mode "someone removed the secret from the repository" is not believable.

@tobiasdiez
Copy link
Contributor Author

enable netlify deploy and be notified about errors...

Protecting against the failure mode "someone removed the secret from the repository" is not believable.

Yes its not very likely. But if the cost is "click two buttons if you are annoyed by the red workflow in a personal fork that you choose to enable the actions in and which has absolutely no negative consequences", then I strongly prefer that. I would appreciate if you could accept this wish to easily test the netlify deployment from the main repo and my fork, or alternatively take over the hosting on netlify yourself.

@dimpase
Copy link
Member

dimpase commented Feb 11, 2023

where are we here now? I'd like build-doc runs like https://github.com/sagemath/sage/actions/runs/4151818607/jobs/7182360271
to really deploy built docs somewhere...

@mkoeppe
Copy link
Member

mkoeppe commented Feb 11, 2023

I would appreciate if you could accept this wish to easily test the netlify deployment from the main repo and my fork, or alternatively take over the hosting on netlify yourself.

That's a rather inappropriate negotiating tactic.

@mkoeppe
Copy link
Member

mkoeppe commented Feb 11, 2023

In any case, we need to merge this ASAP.

@tobiasdiez
Copy link
Contributor Author

tobiasdiez commented Feb 12, 2023

In any case, we need to merge this ASAP.

Thanks for the review!

Did Checks for this PR uploaded docs somewhere ready for inspection? It's not clear to me. I see from the build-docs log that it did create a docker container with them, but then?

The build-docs uploads the docs as a github artifact (a simple zip file, not a docker container) and then the new publish-docs workflow is trigger. This one then publishes everything to netlify and creates a comment in the PR pointing to the published docs. This can be seen at tobiasdiez#2 with docs at https://deploy-preview-2--sagemath-tobias.netlify.app/ (the url scheme will be the same, with 2 replaced by the PR number).


Please squash this PR instead of merging it, since there are quite a few intermediate testing commits that don't need to be preserved.

@dimpase
Copy link
Member

dimpase commented Feb 12, 2023

Have we converged here? There is still "Changes requested" open.

@dimpase
Copy link
Member

dimpase commented Feb 12, 2023

let's put it in develop, once we agree on what's to be done, still.

@mkoeppe mkoeppe self-requested a review February 12, 2023 14:38
@mkoeppe
Copy link
Member

mkoeppe commented Feb 12, 2023

Have we converged here? There is still "Changes requested" open.

I had already set it to positive review. I've removed the "changes requested" to remove any ambiguity.

@tobiasdiez
Copy link
Contributor Author

let's put it in develop, once we agree on what's to be done, still.

I've merged this now, as this is a purely ci-related PR and we got the thumbs up from @vbraun to merge such PRs.

@mkoeppe mkoeppe added this to the sage-10.0 milestone Feb 13, 2023
@kwankyu
Copy link
Collaborator

kwankyu commented Feb 15, 2023

In my fork of sagemath/sage, for a PR in the repo, I received this comment

Screenshot 2023-02-15 at 11 58 00 AM

the link in which doesn't work, of course.

In my opinion, this comment should not be sent in the first place.

@tobiasdiez
Copy link
Contributor Author

Seems to be a bug in the netlify action: netlify/actions#67. For now you can disable the workflow in your fork (https://github.com/kwankyu/sage/actions/workflows/doc-publish.yml in the dropdown menu of "..." in the right upper corner)

@kwankyu
Copy link
Collaborator

kwankyu commented Feb 15, 2023

Thanks for filing the bug.

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

Successfully merging this pull request may close these issues.

5 participants