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

improvement: support ccache-action #93

Open
kinkie opened this issue Nov 20, 2024 · 1 comment
Open

improvement: support ccache-action #93

kinkie opened this issue Nov 20, 2024 · 1 comment

Comments

@kinkie
Copy link

kinkie commented Nov 20, 2024

It would be great to be able to use https://github.com/hendrikmuhs/ccache-action together with vmaction. What would be needed is to copy the .ccache dir into the VM as part of bringup, and then copy it out together with tested files and artifacts

@ojwb
Copy link

ojwb commented Dec 17, 2024

It's already possible to do this - here's what I've been doing:

Set up ccache-action on the host side

    - name: Install CCache                                                                                                                                                   
      uses: hendrikmuhs/ccache-action@v1                                                                                                                                     
      with:                                                                                                                                                                  
        key: ${{ github.job }}                                                                                                                                               

Install ccache in the VM and configure it suitably in the prepare step

The package to install seems to be ccache for all the OSes with vmactions I've set up so far, but the command to install a package varies - e.g. for freebsd it's pkg install -y so:

        usesh: true
        prepare: |
          set -e
          pkg install -y ccache
          ccache --set-config=cache_dir="$GITHUB_WORKSPACE/.ccache"
          ccache --set-config=max_size='500M'
          ccache --set-config=compression=true

(These config settings match the current defaults in ccache-action.)

Set up the compiler(s) to use ccache in the run step

E.g. for autotools:

        run: |
          set -e
          export CC='ccache cc'
          export CXX='ccache c++'    

Make sure the .ccache directory is copied back to the host

Use rsync with copyback (which is the default):

      with:
        sync: rsync
        copyback: true

or this apparently ought to work (but I get file permission errors during the build when I tried using sshfs):

      with:
        sync: sshfs

(Since I didn't get sshfs to work I can't definitively say how it compares for speed, but I'd guess the overhead of every file access turning into an ssh exchange is going to be slower if your build is large enough that ccache is worth the effort.)


I think it would be helpful to add some notes to the documentation covering the above as it took me a bit of experimentation to get it to work.

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