awalsh128 / cache-apt-pkgs-action

Cache APT packages in GitHub Actions
Other
205 stars 35 forks source link

Cache symlinks for pkgs #25

Closed pablgonz closed 2 years ago

pablgonz commented 2 years ago

Hi, I am trying to capture ghostscript and almost everything is going perfect, with the only detail of a symbolic link that is not restored from the cache.

I run the solution manually (no problem), but it would be great if this didn't happen. As an example I have this test repo cache-apt-gs.

With the following configuration file:

name: Test cache-ghostscript

on:
  push:
    branches:
      - "*"
  pull_request:

jobs:
  using-apt-fast:
    runs-on: ubuntu-latest
    env:
      DEBIAN_FRONTEND: noninteractive
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
        with:
          fetch-depth: 1
      - name: Update sources and install ghostscript
        run: >
         sudo apt-fast -y update < /dev/null > /dev/null && sudo apt-fast -y install --no-install-recommends ghostscript < /dev/null > /dev/null

         gsicclink=/usr/share/ghostscript/$(gs --version)/iccprofiles

         if readlink -e "$gsicclink"; then
            echo $gsicclink is a symlink
         else
            echo $gsicclink is not a symlink
         fi

  cache-apt-pkgs:
    runs-on: ubuntu-latest
    env:
      DEBIAN_FRONTEND: noninteractive
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
        with:
          fetch-depth: 1
      - name: Update sources and install ghostscript
        uses: awalsh128/cache-apt-pkgs-action@v1.0.2
        with:
          packages: fonts-urw-base35 libgs9-common libijs-0.35 libjbig2dec0 libopenjp2-7 libgs9 ghostscript
          version: 1.0
          refresh: true
      # libgs9-common creates a symlink from /usr/share/ghostscript, but silently fails to create
      - run: >
         gsicclink=/usr/share/ghostscript/$(gs --version)/iccprofiles

         if readlink -e "$gsicclink"; then
            echo $gsicclink is a symlink
         else
            echo $gsicclink is not a symlink
         fi

get for using-apt-fast:

/usr/share/ghostscript/9.50/iccprofiles is a symlink

get for cache-apt-pkgs:

/usr/share/ghostscript/9.50/iccprofiles is not a symlink

Thanks for the great work Regards

awalsh128 commented 2 years ago

Hey @pablgonz, it looks like this is from libgs9-common and the problem is that I only pipe regular files to the tar.

dpkg -L "libgs9-common" |
while IFS= read -r f; do     
  if test -f $f; then echo "${f:1}"; fi;
done | 
xargs tar -czf "/tmp/test.tar" -C /

Updating the conditional to consider symlinks with if test -f $f || test -L $f; then echo "${f:1}"; fi; fixes it though. Going to do an update and pull into master. Then going to have you try the action @master to make sure it resolves your issue (staging is currently broken).

awalsh128 commented 2 years ago

All set @pablgonz. Update the action to use master instead of the version and let me know if it works. I'll add a regression test for this later and do a patch rev 1.0.3.

pablgonz commented 2 years ago

@awalsh128 Hello, thanks for the prompt response, now it has worked, of course I had to modify:

      - name: Update sources and install ghostscript
        uses: awalsh128/cache-apt-pkgs-action@master
        with:
          packages: fonts-urw-base35 libgs9-common libijs-0.35 libjbig2dec0 libopenjp2-7 libgs9 ghostscript
          version: 3.0
          refresh: true

That is, I had to change version, even with the key refresh: true it did not take the change.

awalsh128 commented 2 years ago

Thanks for confirming. The refresh flag is a no-op and a bug because it doesn't do what it says it is going to do. I am going to do a rev minor and get rid of the flag. Refreshes should be versioned since the cache is immutable.

pablgonz commented 2 years ago

@awalsh128 For reference (https://github.com/actions/cache/issues/2), perhaps not eliminate it, but rather "de-document" it and leave it doing nothing.

pablgonz commented 2 years ago

@awalsh128 I've been thinking about refresh: true, maybe (https://docs.github.com/en/rest/actions/cache#delete-a-github-actions-cache-for-a-repository-using-a-cache-id)

Can be implemented (I have used the curl trick described there so that I can revert to using version = 1.0)

awalsh128 commented 2 years ago

We could do this but it requires the user to toggle the value. Seems like a version value would be better suited. WDYT?

pablgonz commented 2 years ago

I don't have an opinion about this, I only see it from the user side and I don't know how hard it is to implement...by the way, any specific reason to only use numbers in version and not allowing some semantics version: 1.0-beta?