Skip to content

Conversation

germa89
Copy link
Collaborator

@germa89 germa89 commented Mar 9, 2022

Using cache to avoid running all the examples every time we do push/PR

Close #951

@germa89 germa89 added Enhancement CI/CD Related with CICD, Github Actions, etc labels Mar 9, 2022
@germa89 germa89 requested a review from akaszynski March 9, 2022 17:56
@germa89 germa89 self-assigned this Mar 9, 2022
@germa89 germa89 changed the title Ci/cache building doc files Using cache when building documentation Mar 9, 2022
@germa89
Copy link
Collaborator Author

germa89 commented Mar 9, 2022

I'm not applying this to the nightly doc build (no cache there)

@codecov
Copy link

codecov bot commented Mar 9, 2022

Codecov Report

Merging #953 (e67fae0) into main (d37086d) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #953   +/-   ##
=======================================
  Coverage   73.02%   73.02%           
=======================================
  Files          39       39           
  Lines        5712     5712           
=======================================
  Hits         4171     4171           
  Misses       1541     1541           

@akaszynski
Copy link
Collaborator

Made another commit to remove project coverage requirement partially to trigger the CI again. I’ll determine example build time improvement after latest commit.

@akaszynski
Copy link
Collaborator

Docs being fully rebuilt each time:

Computation time summary:
    - ../../examples/02-geometry/03-volumes.py:                                                         157.75 sec   0.0 MB
    - ../../examples/00-mapdl-examples/2d_plate_with_a_hole.py:                                          52.75 sec   0.0 MB
    - ../../examples/02-geometry/04-primitives.py:                                                       21.24 sec   0.0 MB
    - ../../examples/00-mapdl-examples/geometry.py:                                                      18.56 sec   0.0 MB
    - ../../examples/01-apdlmath-examples/solve_dense_matrix.py:                                         15.78 sec   0.0 MB
    - ../../examples/00-mapdl-examples/pyvista_mesh.py:                                                  13.33 sec   0.0 
 

Seems that we're getting a cache hit with a bad cache key:

Cache restored from key: Examples-Linux--

Recommend not using OS, and instead using the version of the package. This way the key is cleared when a new version is a released (this way, all examples are rebuild but only on release). Do this with:

https://stackoverflow.com/a/65616499/3369879

Using the output from python -c "from ansys.mapdl.core import __version__; print(__version__)"

uses: actions/cache@v2
with:
path: doc/build
key: doc-build-${{ steps.version.outputs.PYMAPDL_VERSION }}-${{ github.sha }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Won't this mean that this will be different each time?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes... but...

since the "restore-key" is used as a glob pattern, it will match the last version of the cache. I need to "create" a different sha every time, otherwise you cannot store the cache if there is another workflow run going on.

I hope this makes sense.

@germa89 germa89 requested a review from akaszynski March 10, 2022 17:56
@germa89
Copy link
Collaborator Author

germa89 commented Mar 10, 2022

I think this is ready:

Almost 50% reduction in building time. Of course, this is a one test metric, so it is not super reliable, but overall, I will expect to a decent reduction.

Copy link
Collaborator

@akaszynski akaszynski left a comment

Choose a reason for hiding this comment

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

Nice work implementing this! 50% reduction is a big deal, and now we can keep adding examples without bloating our CI/CD.

@akaszynski akaszynski merged commit a5680ee into main Mar 11, 2022
@akaszynski akaszynski deleted the ci/cache-building-doc-files branch March 11, 2022 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI/CD Related with CICD, Github Actions, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using cache when building examples in documentation

2 participants