uraimo / run-on-arch-action

A Github Action that executes jobs/commands on non-x86 cpu architectures (ARMv6, ARMv7, aarch64, s390x, ppc64le, riscv64) via QEMU
BSD 3-Clause "New" or "Revised" License
665 stars 146 forks source link

Mounted Volume only gets updated after the `run` step completed #138

Closed TGP17 closed 9 months ago

TGP17 commented 9 months ago

I'm cross compiling an app for aarch64 in one job, zip it, cache it, restore it in the next job, where I use the run on arch action. I run ls, see that the zip is transfered. I start the run on arch action, and mount the folder with the zip, but anything that runs inside the run on arch action doesn't see the zip. I can move things into that directory from the run on arch action and that will show up in the host, but not the other way around. Here is the workflow job:

linux-arm64-appimage:
    # The host should always be linux
    runs-on: ubuntu-20.04
    name: Build on ${{ matrix.distro }} ${{ matrix.arch }}

    strategy:
      matrix:
        include:
          - arch: aarch64
            distro: ubuntu20.04
            githubToken: ${{ github.token }}          
    needs: linux-arm64
    env: 
      OS: linux
    steps:
      - name: Prepare Artifact directory
        run: mkdir ./Citra-AppImage-arm64
      - name: Download ARM64 build from cache
        uses: actions/cache/restore@v3
        with:
          path: ${{ env.OS }}-appimage-arm64
          key: ${{ runner.os }}-appimage-arm64-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
          fail-on-cache-miss: true
      - name: Show current directory
        run: ls
      - name: Show Citra-AppImage-arm64 folder
        run: ls ./Citra-AppImage-arm64
      - name: Show linux-appimage-arm64 folder
        run: ls ./linux-appimage-arm64
      - uses: actions/checkout@v3
      - uses: uraimo/run-on-arch-action@v2
        name: Build artifact
        id: build
        with:
          arch: ${{ matrix.arch }}
          distro: ${{ matrix.distro }}

          # Not required, but speeds up builds
          githubToken: ${{ github.token }}

          # Mount the artifacts directory as /artifacts in the container
          dockerRunArgs: |
            --volume "./linux-appimage-arm64:/artifacts"
          # Pass some environment variables to the container
          env: | # YAML, but pipe character is necessary
            artifact_name: git-${{ matrix.distro }}_${{ matrix.arch }}

          # The shell to run commands with in the container
          shell: /bin/sh

          # Install some dependencies in the container. This speeds up builds if
          # you are also using githubToken. Any dependencies installed here will
          # be part of the container image that gets cached, so subsequent
          # builds don't have to re-install them. The image layer is cached
          # publicly in your project's package repository, so it is vital that
          # no secrets are present in the container state or logs.
          install: |
            apt update
            apt-get install -y software-properties-common lsb-release curl
            apt-get update
            add-apt-repository -y ppa:ubuntu-toolchain-r/test
            add-apt-repository -y ppa:okirby/qt6-backports
            add-apt-repository -y ppa:okirby/qt6-testing
            add-apt-repository -y ppa:theofficialgman/gpu-tools
            curl -s https://apt.kitware.com/keys/kitware-archive-latest.asc | gpg --dearmor | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
            apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 42D5A192B819C5DA
            add-apt-repository -y 'deb https://apt.kitware.com/ubuntu/ focal main'
            apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y
            apt-get install -y \
            build-essential \
            libsdl2-dev \
            libssl-dev \
            qt6-base-dev \
            qt6-base-private-dev \
            qt6-multimedia-dev \
            qt6-l10n-tools \
            qt6-tools-dev \
            qt6-tools-dev-tools \
            qt6-documentation-tools \
            ffmpeg \
            libavcodec-dev \
            libavdevice-dev \
            libavfilter-dev \
            libavformat-dev \
            libswresample-dev \
            libswscale-dev \
            p7zip-full \
            wget \
            unzip \
            git \
            ccache \
            glslang-dev \
            glslang-tools \
            patchelf \
            desktop-file-utils \
            file

        # Produce a binary artifact and place it in the mounted volume
          run: chmod a+x ./.ci/linux-arm64-appimage.sh && ./.ci/linux-arm64-appimage.sh

      - name: Show the artifact
        run: |
          ls -al "./linux-appimage-arm64"
      - name: Publish Artifact
        uses: actions/upload-artifact@v2
        with:
          name: Citra-aarch64.AppImage
          path: "./linux-appimage-arm64/Citra-aarch64.AppImage"

Did I configure something wrong? I would appreciate any help. Or does Docker in general not show the original files in the mounted Volume?

TGP17 commented 9 months ago

I figured it out, I completely missed that I run actions checkout after I restored the cache from the previous job, which deleted the current directory.