upload-artifact icon indicating copy to clipboard operation
upload-artifact copied to clipboard

[bug] Zip is being converted to directory after downloading the artifact

Open ltroya-as opened this issue 2 years ago • 1 comments

What happened?

I am working on a Nuxt 3 project. I am building the application once, then I am running playwright on several shards at the same time.

I am creating an archive file for the .output and .nuxt so it's faster to upload and download the artifacts. (From ~3min down to 4sec).

Before uploading the artifact, I am checking the file using the file command and this is the output: compiled.zip: Zip archive data, at least v1.0 to extract, compression method=store. Everything as expected.

Once I download the artifact, the unzip command fails. I found the reason for that failure after running the file command again: compiled.zip: directory

It's really weird

What did you expect to happen?

I expected the file result on the compiled.zip file to be compiled.zip: Zip archive data, at least v1.0 to extract, compression method=store

How can we reproduce it?

I have tried to reproduce this behavior in several small projects but I have been able to reproduce it.

However, here is my action to see if I am doing something wrong:

name: Continuous Integration

on:
  pull_request:
    branches:
      - master
      - production

# Abort current jobs after pushing new changes
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

env:
  RETENTION_DAYS: 2
  PR_NUMBER: ${{ github.event.pull_request.number }}

jobs:
  configure-application:
    name: Install dependencies and configure the application
    runs-on: ${{matrix.os}}
    strategy:
      matrix:
        os: [ubuntu-latest]
        node-version: [16.x]
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Setup NodeJS ${{matrix.node-version}}
        uses: actions/setup-node@v3
        with:
          node-version: ${{matrix.node-version}}

      - name: Cache config
        uses: actions/cache@v3
        with:
          path: |
            node_modules
          key: branch-${{ github.ref_name }}-modules-${{ hashFiles('**/yarn.lock') }}

      - name: Install dependencies
        run: yarn --frozen-lockfile

      - name: Compile application
        run: |
          yarn build
          mkdir production
          mv .output production/output
          mv .nuxt production/nuxt
          zip -qq -r compiled.zip production
          file compiled.zip

      - name: Uploading output as an artifact
        uses: actions/upload-artifact@v3
        with:
          name: output-${{ github.sha }}
          path: compiled.zip
          retention-days: ${{ env.RETENTION_DAYS }}

  ci:
    needs: [configure-application]
    name: Running Playwright tests
    runs-on: ubuntu-20.04

    strategy:
      fail-fast: true
      matrix:
        shard: [1]

    steps:
      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: 16

      - name: Checkout
        uses: actions/checkout@v3

      - name: Cache config
        uses: actions/cache/restore@v3
        with:
          path: |
            node_modules
          key: branch-${{ github.ref_name }}-modules-${{ hashFiles('**/yarn.lock') }}

      - name: Download output artifact
        uses: actions/download-artifact@v3
        with:
          name: output-${{ github.sha }}
          path: compiled.zip

      - name: Checking compiled.zip and extracting it
        run: |
          pwd
          ls -la
          file compiled.zip
          unzip compiled.zip

Anything else we need to know?

Even though file command told me that it is a directory, after running ls compiled.zip it doesn't show me its content.

Also, I have downloaded the artifact several times, and I have been able to extract its content.

What version of the action are you using?

v3

What are your runner environments?

linux

Are you on GitHub Enterprise Server? If so, what version?

No response

ltroya-as avatar May 27 '23 02:05 ltroya-as

I also met this problem and I found I could get around it by something like:

 - name: "Download artifact"
      uses: actions/download-artifact@v4
      with:
        name: ARTIFACT_NAME
        path: artifact
    - name: Unzip 
      run:  tar -xvf artifact/my_zip_name

the real zip file is under the path you specified for actions/download-artifact@v4

Earsuit avatar Aug 06 '24 14:08 Earsuit