Bogdanp / setup-racket

A GH action for installing Racket.
MIT License
49 stars 9 forks source link

[Request] Make setup-rakcet compatible with caching #38

Closed ctittel closed 2 years ago

ctittel commented 3 years ago

My github action yml file includes the following two steps (purpose being that downloading and setting up the dependencies takes ~2 Minutes and I want to speed it up):

    - name: Cache Racket dependencies
      uses: actions/cache@v2
      with:
        path: /opt/racket
        key: ${{ runner.os }}-racket
    - name: Install Racket & dependencies 
      uses: Bogdanp/setup-racket@v1.5
      with:
        architecture: 'x64'
        distribution: 'full'
        variant: 'CS'
        version: '8.1'
        packages: 'pollen, gregor, sugar, txexpr' # must be a comma-separated string!
        dest: '/opt/racket'

The caching part seems to work - after the first run of the action I was informed that 200MB were cached.

On the second run the step Cache Racket dependencies reported that 200MB were successfully restored. However, the action got stuck for > 3 Minutes in the step Install Racket & dependencies. I aborted the action and the log of Install Racket & dependencies contains the following:

  installerURL = https://download.racket-lang.org/installers/8.1/racket-8.1-x86_64-linux-cs.sh
  sh /tmp/install-racket.sh
  /usr/bin/sudo
  This program will extract and install Racket v8.1.

  Note: the required diskspace for this installation is 658M.

  Checking the integrity of the binary archive... ok.
  "/opt/racket" exists, delete? 
  Error: The operation was canceled.

It seems the prompt "/opt/racket" exists, delete? appeared and it didn't continue on its own.

Bogdanp commented 3 years ago

Hi @ctittel. I've set up an example workflow that shows how you can use actions/cache with setup-racket. Installing Racket itself is generally very fast so there's usually no need to cache the Racket installation and caching the packages is pretty straightforward, but it means you can't use the packages: syntax in setup racket (because it doesn't pass --skip-installed to raco pkg) so you have to "manually" install the pacakges.

Hope that helps!

ctittel commented 2 years ago

Thanks, it works perfectly! In my case this speeds up the action from ~2m30 in the first run to ~45s in following runs.

Does raco pkg install --auto --skip-installed pollen gregor sugar txexpr also update packages if there are newer versions available?

Bogdanp commented 2 years ago

No, I don't think it will. I personally like to use racksnaps in my production apps and generate the caching key based on the current catalog I'm using. You could run raco pkg update after install, but that will end up making requests to the catalog so it may slow things down a bit, but probably not by much.

Bogdanp commented 2 years ago

I've updated the docs to link to the example so I'm going to close this.

ctittel commented 2 years ago

Thanks! I added raco pkg update --all to the action and it works as intended. The checking for updates adds only about 2 seconds time