Skip to content

Commit

Permalink
simplify caching logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mhx committed Aug 13, 2024
1 parent 2eeed47 commit cb089b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 60 deletions.
17 changes: 3 additions & 14 deletions .docker/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,7 @@ cd "$HOME"
rm -rf dwarfs dwarfs-*

if [[ "$BUILD_FROM_TARBALL" == "1" ]]; then
TARBALL="dwarfs-source-${GITHUB_RUN_NUMBER}.tar.zst"
TARBALL_PATH=""
if [ -f "/tmp-runner/artifacts/$TARBALL" ]; then
TARBALL_PATH="/tmp-runner/artifacts"
elif [ -f "/workspace/$TARBALL" ]; then
TARBALL_PATH="/workspace"
else
echo "source tarball not found: $TARBALL"
exit 1
fi
tar xf "$TARBALL_PATH/$TARBALL"
tar xf "/artifacts/cache/dwarfs-source-${GITHUB_RUN_NUMBER}.tar.zst"
ln -s dwarfs-* dwarfs
else
git config --global --add safe.directory /workspace
Expand Down Expand Up @@ -314,9 +304,8 @@ else
elif [[ "-$BUILD_TYPE-" == *-source-* ]]; then
$BUILD_TOOL package_source
$BUILD_TOOL copy_source_artifacts
rm -rf /tmp-runner/artifacts
mkdir -p /tmp-runner/artifacts
cp dwarfs-*.tar.zst /tmp-runner/artifacts/dwarfs-source-${GITHUB_RUN_NUMBER}.tar.zst
mkdir -p /artifacts/cache
cp dwarfs-*.tar.zst /artifacts/cache/dwarfs-source-${GITHUB_RUN_NUMBER}.tar.zst
fi

if [[ "-$BUILD_TYPE-" != *-[at]san-* ]] && \
Expand Down
47 changes: 1 addition & 46 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,27 +137,6 @@ jobs:
--env GITHUB_RUN_ATTEMPT \
dwarfs-linux-build-arch
- name: Upload Source Package
uses: actions/upload-artifact@v4
with:
name: dwarfs-source
path: ${{ runner.temp }}/artifacts/dwarfs-source-${{ github.run_number }}.tar.zst
if-no-files-found: error
compression-level: 0

- name: Move Source Tarball For Caching
run: |
mv ${{ runner.temp }}/artifacts/dwarfs-source-${{ github.run_number }}.tar.zst ${GITHUB_WORKSPACE}/
- name: Cache Source Tarball
uses: actions/cache/save@v4
with:
path: dwarfs-source-${{ github.run_number }}.tar.zst
key: dwarfs-source-run-${{ github.run_number }}

- name: Remove Source Tarball
run: rm -v dwarfs-source-${{ github.run_number }}.tar.zst

linux-src:
needs: package-source

Expand Down Expand Up @@ -224,31 +203,6 @@ jobs:
fetch-depth: '0'
ref: ${{ github.ref }}

- name: Fetch Source Tarball From Cache
id: source-tarball
uses: actions/cache/restore@v4
with:
path: dwarfs-source-${{ github.run_number }}.tar.zst
key: dwarfs-source-run-${{ github.run_number }}

- name: Download Source Tarball Artifact
if: steps.source-tarball.outputs.cache-hit != 'true'
uses: actions/download-artifact@v4
with:
name: dwarfs-source

- name: Re-cache Source Tarball
if: steps.source-tarball.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: dwarfs-source-${{ github.run_number }}.tar.zst
key: dwarfs-source-run-${{ github.run_number }}

- name: Move Tarball To Artifacts Location
run: |
mkdir -p ${{ runner.temp }}/artifacts
mv ${GITHUB_WORKSPACE}/dwarfs-source-${{ github.run_number }}.tar.zst ${{ runner.temp }}/artifacts/
- name: Build Docker Image
run: |
docker build \
Expand All @@ -266,6 +220,7 @@ jobs:
--mount type=bind,source=${{ runner.temp }},target=/tmp-runner \
--mount type=bind,source=/home/mhx/github-ccache,target=/ccache \
--mount type=bind,source=/home/mhx/github-local,target=/local \
--mount type=bind,source=/mnt/opensource/artifacts/dwarfs,target=/artifacts \
--env BUILD_FROM_TARBALL=1 \
--env BUILD_TYPE=${{ matrix.build_type }} \
--env BUILD_ARCH=${{ matrix.arch }} \
Expand Down

0 comments on commit cb089b1

Please sign in to comment.