Dovyski / setup-opencv-action

Github Action to download and setup OpenCV

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Guidence on caching

olirice opened this issue · comments

The actions takes 35-40 mins to run

Is there any support for caching so it can be skipped so long as none of the settings have changed?

This project was a huge help getting our CI working, thanks for putting it together

I am really glad you like (and are using) it! I face the very same problems with my own CI tests, but I don't think you can persist data from one action run to another.

Consulting the Github Actions docs now, I've found this:

If you need to access artifacts from a previous workflow run, you'll need to store the artifacts somewhere. For example, you could run a script at the end of your workflow to store build artifacts on Amazon S3 or Artifactory, and then use the storage service's API to retrieve those artifacts in a future workflow.

Maybe the setup-opencv-action could have some sort of config params to upload the compiled files to a place, then download them in the future if all params are the same.

My fear is that it is too specific to be integrated into the action itself.

I've just got to know GitHub cache action: https://github.com/actions/cache

I think this is exactly what you are looking for!

thank you! i was able to get that working

Awesome! If you have a .yml snippet you would like to share, I can add it to the docs so other users can use this. Just a suggestion, please don't feel required to 😉

Ok, I fibbed a little

I was able to get the cache working via:

name: Tests

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Cache OpenCV
      id: cache-opencv
      uses: actions/cache@v2
      with:
          path: /usr/local
          key: fixed-opencv-cache
    
    - name: Install OpenCV
      if: steps.cache-opencv.output.cache-hit != 'true'
      uses: Dovyski/setup-opencv-action@v1
      with:
        opencv-version: '4.3.0'

Which admittedly caches far more than is actually necessary (note the 5GB size below) but I was just trying to get POC.

The issue crops up on subsequent runs when it tries to restore the cache it errors out because that's a protected part of the file system

 Cache OpenCV
3m 48s
/bin/tar: ../../../../../usr/local/src: Cannot utime: Operation not permitted
Run actions/cache@v2
Cache Size: ~5009 MB (5251874814 B)
/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/f844c62f-0070-413f-93e1-48b7bd195f64/cache.tzst -P -C /home/runner/work/ClosedCV/ClosedCV
/bin/tar: ../../../../../usr/local/man/man7/cmake-generator-expressions.7: Cannot open: File exists
/bin/tar: ../../../../../usr/local/man/man7/cmake-packages.7: Cannot open: File exists
/bin/tar: ../../../../../usr/local/man/man7/cmake-variables.7: Cannot open: File exists

I'm sure it would be possible to install in a different location and restore the cache but the project this was intended to support got dropped before I invested the time to solve that issue.

Maybe this will help as a starting point for others, but its not an out-of-the-box solution

Thank you very much for this starting point. I'll use it to iterate on for sure.

If anybody has a better solution by now, I'd love to know!

I stumbled upon porg package which can track installed files.
The list of installed files can be extracted and fed into actions/cache@v2