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

Github Actions not caching _site #4

Closed
datapolitical opened this issue Jan 5, 2021 · 33 comments
Closed

Github Actions not caching _site #4

datapolitical opened this issue Jan 5, 2021 · 33 comments

Comments

@datapolitical
Copy link
Contributor

datapolitical commented Jan 5, 2021

I'm running into an odd issue where every time my site deploys it has to re-generate all of the webp image files, because it can't find them in the destination directory (despite being in the same folder with the originals). The code runs fine locally, but that's because the _site folder is still there. But with this plugin that _site data disappears after it's pushed.

Edit: I should add that I had to fork the action and edit it to run with ubuntu-latest and bash in order to get the thing to run the webp plugin. If there's a way to update it to support the plugin using the current setup. https://github.com/datapolitical/jekyll-deploy-action

So I'm just sort of trying to figure out how to make the two work together correctly, and any thoughts you might have would be very welcome.

https://github.com/sverrirs/jekyll-webp/blob/master/lib/jekyll-webp/webpGenerator.rb

@jeffreytse
Copy link
Owner

jeffreytse commented Jan 8, 2021

Hi @datapolitical

Thanks for your issue. I think you should config the workflow with the actions/cache@v2 as below for caching the _site folder:

  # Use GitHub Actions' cache to cache dependencies on servers
  - uses: actions/cache@v2
    with:
      path: vendor/bundle
      key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
      restore-keys: |
        ${{ runner.os }}-gems-

  # Use GitHub Actions' cache to cache site on servers
  - uses: actions/cache@v2
    with:
      path: _site
      key: ${{ runner.os }}-site-${{ hashFiles('**/index.html') }}
      restore-keys: |
        ${{ runner.os }}-site-

Thanks and regards

@datapolitical
Copy link
Contributor Author

Thanks!

@datapolitical datapolitical changed the title wiped gh-pages branch conflicts with WebP image generation Github Actions not caching _site Mar 21, 2021
@datapolitical datapolitical reopened this Mar 21, 2021
@datapolitical
Copy link
Contributor Author

Turns out this is not working and my site build has ballooned to over 16 minutes because of the responsive image plugin I'm using.

The action runs, the cache hit happens, but nothing is being stored in the cache.
I use this:

# Use GitHub Actions' cache to cache site on servers
  - uses: actions/cache@v2
    with:
      path: _site
      key: ${{ runner.os }}-site-${{ hashFiles('**/index.html') }}
      restore-keys: |
        ${{ runner.os }}-site-

from here: https://github.com/datapolitical/chrisfnicholson.github.io/blob/main/.github/workflows/build-jekyll.yml

But the response is:
Received 22 of 22 (100.0%), 0.0 MBs/sec
Cache Size: ~0 MB (22 B).

I assume there's something up with my path but it's exactly what was suggested above.

@jeffreytse
Copy link
Owner

Hi @datapolitical

I saw that you're not using this jekyll-deploy-action from here https://github.com/datapolitical/chrisfnicholson.github.io/blob/481414b45213dafaf635ba4b980ffa0050050966/.github/workflows/build-jekyll.yml#L54, so I think you cache a wrong site ouput folder.

Thanks and regards

@datapolitical
Copy link
Contributor Author

datapolitical commented Mar 21, 2021

It's the same action I just updated it to run in Ubuntu and added a few extra dependencies so my site would build properly. Shouldn't change the build folder.

What's the directory structure because caching vendor/bundle works but I don't have a vendor folder in my local copy of the code. So part of me thinks I've specified that wrong.

master...datapolitical:master

I really appreciate the help.

@jeffreytse
Copy link
Owner

jeffreytse commented Mar 21, 2021

Could you change your action to jeffreytse/[email protected] and try again? Maybe it settles your issue abou the _site folder has not been cached. : )

@datapolitical
Copy link
Contributor Author

Didn't build because of all the dependencies I load early in the script conflict with what your code expects, but I need them to run imagemagick image

@jeffreytse
Copy link
Owner

Hi @datapolitical , my deploy action has added imagemagick package to the system enviroment, so I don't know why it has the conflicts, could you provide me the action log to analysis?

@datapolitical
Copy link
Contributor Author

This is the issue I'm talking about. It was a lot of work to make it compatible.

sverrirs/jekyll-webp#15 (comment)

@jeffreytse
Copy link
Owner

Hi @datapolitical , don't worry, I will try to help you to settle down this issue, please be patient. : )

@jeffreytse
Copy link
Owner

jeffreytse commented Mar 21, 2021

Hi @datapolitical

Thanks for the patience and currently this issue has been addressed and fixed.

  • You don't need to use a fork's action and I have test with the action jeffreytse/jekyll-deploy-action@master and it has no any dependencies issue. (See here and the website)
  • The default output folder is not the _site, so you should cache build folder as follow code snippet.
      # Use GitHub Actions' cache to cache site on servers
      - uses: actions/cache@v2
        with:
          path: build
          key: ${{ runner.os }}-build-${{ hashFiles('**/index.html') }}
          restore-keys: |
            ${{ runner.os }}-build-

And welcome to star this project for further updates in the future. : )

Thanks and regards

@datapolitical
Copy link
Contributor Author

When I use your action I get " /usr/bin/env: ‘ruby2.7’: No such file or directory" on line 89 https://github.com/datapolitical/chrisfnicholson.github.io/runs/2161384500?check_suite_focus=true

@datapolitical
Copy link
Contributor Author

I switched it back to my fork and now caching works great! Thanks so much for your help. Happy to debug the issue if you want but very glad this works, it took nearly 10 minutes off my build time.

@jeffreytse
Copy link
Owner

jeffreytse commented Mar 22, 2021

Hi @datapolitical,

Currently I'm researching the issue "/usr/bin/env: ‘ruby2.7’: No such file or directory", could you test with the action jeffreytse/jekyll-deploy-action@master again and tell me the result?

Thanks and regards

@jeffreytse
Copy link
Owner

jeffreytse commented Mar 22, 2021

Hi @datapolitical, could you invite me to be a collaborator as follow instructive, so that I can re-run the action by myself conveniently, it will be fast to settle this issue for me.

image

@datapolitical
Copy link
Contributor Author

Didn't work. Here's the error:

image

@jeffreytse
Copy link
Owner

jeffreytse commented Mar 22, 2021

@datapolitical According to the latest result, it seems to a issue that used a wrong bundle cache built for Ubuntu but my action's Dockerfile is using Alpine Linux (super lightweight).

@datapolitical
Copy link
Contributor Author

If you want to keep debugging, I updated the development version of the action so that the the action will run any time there's an issue added to the repository.

And yes, your action's Dockerfile uses Alpine Linux. If you wan't I'll try editing mine to remove the ubuntu stuff to see if yours can build the site properly, but at least when I tried a couple months ago, a couple of the plugins needed ubuntu.

@jeffreytse
Copy link
Owner

Hi @datapolitical, thanks for your help to dig this issue, a couple of the plugins's dependencies such as libmagick has been added, and your whole site has been built without any problems in my action currently, it's another issue, so it's better to settle this cache issue and improve the compatibility.

@jeffreytse
Copy link
Owner

jeffreytse commented Mar 22, 2021

Hi @datapolitical I just commented the issue in your repository but never triggered the action

@datapolitical
Copy link
Contributor Author

Try opening a new issue, that worked for me.

@jeffreytse
Copy link
Owner

I think the comment_created event should be better, I am afraid of too many issues 😢
image

@datapolitical
Copy link
Contributor Author

OK now it runs if you make a comment.

@datapolitical
Copy link
Contributor Author

datapolitical commented Mar 22, 2021

I edited the action to remove the dependencies and to create a new cache and it looks like it works! Still waiting for it to finish generating all the files but figured I'd give you a heads up.

https://github.com/datapolitical/chrisfnicholson.github.io/blob/dev/.github/workflows/test-jekyll.yml

@datapolitical
Copy link
Contributor Author

Actually it looks like you fixed it because the old workflow you just ran also worked.

@jeffreytse
Copy link
Owner

Hi @datapolitical

Many thanks for your help and the cache compatibility issue has been addressed and fixed (#12), now you can just use the jeffreytse/jekyll-deploy-action@master without any other issues.

Thanks and regards

@jeffreytse
Copy link
Owner

@datapolitical Could you change back to the previous cache key? So that I can check if it does work.

@datapolitical
Copy link
Contributor Author

Trying it now live

@jeffreytse
Copy link
Owner

jeffreytse commented Mar 22, 2021

Hi @datapolitical, I have seen the action cleaned up the incompatible gem cache, so this issue should be settled down perfectly.
image

@datapolitical
Copy link
Contributor Author

Also, If you wouldn't mind creating a release, I prefer not to target my code at master because things can change.

@jeffreytse
Copy link
Owner

jeffreytse commented Mar 22, 2021

@datapolitical, I will publish a release in this weekend, any other new bugs I would also fix in this week.

@datapolitical
Copy link
Contributor Author

It's broken again

@datapolitical
Copy link
Contributor Author

Nevermind, I know what happened. it was a different plugin

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

No branches or pull requests

2 participants