build: try to cache source tarballs

This commit is contained in:
Marcus Holland-Moritz 2024-08-13 13:12:18 +02:00
parent 03d6b14870
commit 1daa729d59
3 changed files with 7 additions and 29 deletions

View File

@ -44,12 +44,7 @@ cd "$HOME"
rm -rf dwarfs dwarfs-* rm -rf dwarfs dwarfs-*
if [[ "$BUILD_FROM_TARBALL" == "1" ]]; then if [[ "$BUILD_FROM_TARBALL" == "1" ]]; then
# delete all but the latest tarball tar xf "/artifacts/cache/dwarfs-source-${GITHUB_RUN_NUMBER}.tar.zst"
ls -1 -r --sort=time /workspace/dwarfs-*.tar.zst | tail -n +2 | while read -r tarball; do
echo "deleting old tarball: $tarball"
rm -f "$tarball"
done
tar xf /workspace/dwarfs-*.tar.zst
ln -s dwarfs-* dwarfs ln -s dwarfs-* dwarfs
else else
git config --global --add safe.directory /workspace git config --global --add safe.directory /workspace
@ -309,10 +304,6 @@ else
elif [[ "-$BUILD_TYPE-" == *-source-* ]]; then elif [[ "-$BUILD_TYPE-" == *-source-* ]]; then
$BUILD_TOOL package_source $BUILD_TOOL package_source
$BUILD_TOOL copy_source_artifacts $BUILD_TOOL copy_source_artifacts
rm -rf /tmp-runner/artifacts
mkdir -p /tmp-runner/artifacts
cp source-artifacts.env /tmp-runner
cp dwarfs-*.tar.zst /tmp-runner/artifacts
fi fi
if [[ "-$BUILD_TYPE-" != *-[at]san-* ]] && \ if [[ "-$BUILD_TYPE-" != *-[at]san-* ]] && \

View File

@ -136,17 +136,6 @@ jobs:
--env GITHUB_RUN_ATTEMPT \ --env GITHUB_RUN_ATTEMPT \
dwarfs-linux-build-arch dwarfs-linux-build-arch
- name: Prepare Artifact Upload
run: cat ${{ runner.temp }}/source-artifacts.env >> $GITHUB_ENV
- name: Upload Source Package
uses: actions/upload-artifact@v4
with:
name: dwarfs-source
path: ${{ runner.temp }}/artifacts/${{ env.source_tarball }}
if-no-files-found: error
compression-level: 0
linux-src: linux-src:
needs: package-source needs: package-source
@ -213,11 +202,6 @@ jobs:
fetch-depth: '0' fetch-depth: '0'
ref: ${{ github.ref }} ref: ${{ github.ref }}
- name: Download Source Tarball
uses: actions/download-artifact@v4
with:
name: dwarfs-source
- name: Build Docker Image - name: Build Docker Image
run: | run: |
docker build \ docker build \
@ -235,6 +219,7 @@ jobs:
--mount type=bind,source=${{ runner.temp }},target=/tmp-runner \ --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-ccache,target=/ccache \
--mount type=bind,source=/home/mhx/github-local,target=/local \ --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_FROM_TARBALL=1 \
--env BUILD_TYPE=${{ matrix.build_type }} \ --env BUILD_TYPE=${{ matrix.build_type }} \
--env BUILD_ARCH=${{ matrix.arch }} \ --env BUILD_ARCH=${{ matrix.arch }} \

View File

@ -855,12 +855,14 @@ if(DEFINED ENV{GITHUB_REF_TYPE})
set(PACKAGE_EXT ".tar.zst") set(PACKAGE_EXT ".tar.zst")
endif() endif()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/source-artifacts.env" set(SOURCE_TARBALL "${CMAKE_PROJECT_NAME}-${PRJ_VERSION_FULL}${PACKAGE_EXT}")
"source_tarball=${CMAKE_PROJECT_NAME}-${PRJ_VERSION_FULL}${PACKAGE_EXT}\n")
add_custom_target(copy_source_artifacts add_custom_target(copy_source_artifacts
COMMAND ${CMAKE_COMMAND} -E make_directory ${ARTIFACTS_FULL_PATH} COMMAND ${CMAKE_COMMAND} -E make_directory ${ARTIFACTS_FULL_PATH}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${PRJ_VERSION_FULL}${PACKAGE_EXT} ${ARTIFACTS_FULL_PATH} COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_TARBALL} ${ARTIFACTS_FULL_PATH}
COMMAND ${CMAKE_COMMAND} -E make_directory ${DWARFS_ARTIFACTS_DIR}/cache
COMMAND ${CMAKE_COMMAND} -E create_symlink ../${ARTIFACTS_SUBDIR}/${SOURCE_TARBALL}
${DWARFS_ARTIFACTS_DIR}/cache/dwarfs-source-$ENV{GITHUB_RUN_NUMBER}${PACKAGE_EXT}
) )
if(STATIC_BUILD_DO_NOT_USE OR WIN32) if(STATIC_BUILD_DO_NOT_USE OR WIN32)