actions / actions/toolkit

Cache saving failed with zstd installed when tar is older than 1.27

Open
#1,099 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
Cache saving (Post step) will fail when

  • the environment have zstd command
  • the envrionment donot have a gnu tar version 1.27+

reason:

tar's --use-compress-program PROG argument supports space in PROG was introduced in (gnu tar commit, included in ver 1.27) 7b5e803963822e69a73d00ba62ac01b1c23f112c and have had a bug fixed in (gnu tar commit, included in ver 1.29) 61cd3fd26855d40ee3a6491b2aa3611cd2aae46c

but here:

https://github.com/actions/toolkit/blob/f8a69bc473af4a204d0c03de61d5c9d1300dfb17/packages/cache/src/internal/tar.ts#L106-L115

tar.ts donot check tar version and used zstd xxxx args

maybe we should use tar -cf - somefile... | zstd -thingsand zstd -d some.tar.zst | tar -xv?

To Reproduce

on:
  workflow_dispatch:

jobs:
  libs:
    name: ceshi
    runs-on: ubuntu-latest
    container: centos:7
    steps:
      - name: install zstd
        run: |
          # fastmirror is to slow
          CENTOS_MIRROR='mirror.facebook.net/centos/'
          sed -i 's/^metalink=/#metalink=/g' /etc/yum.repos.d/*.repo
          sed -i 's/^mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/*.repo
          sed -i 's|^#baseurl=http://mirror\.centos\.org/centos/|baseurl=https://'$CENTOS_MIRROR'|g' /etc/yum.repos.d/*.repo
          yum install -yy epel-release
          EPEL_MIRROR='mirror.facebook.net/fedora/epel/'
          sed -i 's/^metalink=/#metalink=/g' /etc/yum.repos.d/*.repo
          sed -i 's/^mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/*.repo
          sed -i 's|^#baseurl=http://download.fedoraproject.org/pub/epel/|baseurl=https://'$EPEL_MIRROR'|g' /etc/yum.repos.d/*.repo
          yum install -yy zstd
      - name: cache
        uses: actions/cache@v3
        with:
          path: |
            /etc
          key: ceshiceshi1

see https://github.com/dixyes/ghactionsplay/runs/6569965704?check_suite_focus=true

Expected behavior
cache being successful saved.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/cache/src/internal/tar.ts at lines 106-115 and reproduce the cache post-step failure with zstd installed and an older tar, using the linked CentOS 7 workflow as a reference. Trace how tar and zstd are invoked, then verify that cache saving succeeds in the described environment without regressing supported compression behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.