Skip to content

Commit

Permalink
feat: re-use packages in builds
Browse files Browse the repository at this point in the history
update FreeBSD VM image to 1.0.1
  • Loading branch information
trombik committed Oct 14, 2024
1 parent 02deed0 commit 34104a4
Showing 1 changed file with 65 additions and 1 deletion.
66 changes: 65 additions & 1 deletion .github/workflows/poudriere.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,36 @@ jobs:
remove-large-packages: 'true'
remove-cached-tools: 'true'


- name: Checkout
uses: actions/checkout@v4

- name: Download packages
id: download-packages
uses: dawidd6/action-download-artifact@v6
with:

# download packages cache from previous workflow run
workflow: poudriere.yml
workflow_conclusion: completed
name: packages-cache
path: packages
if_no_artifact_found: warn

- name: poudriere bulk
id: make
uses: cross-platform-actions/action@v0.25.0
with:
operating_system: freebsd
version: '14.1'
image_url: https://github.com/trombik/freebsd-builder-poudriere/releases/download/v1.0.0/freebsd-14.1-x86-64.qcow2
image_url: https://github.com/trombik/freebsd-builder-poudriere/releases/download/v1.0.1/freebsd-14.1-x86-64.qcow2
sync_files: true
run: |
set -x
set -e
df -h -tufs
tree .
poudriere ports -l
poudriere jail -l
Expand All @@ -80,6 +95,9 @@ jobs:
OVERLAY_DIR=`realpath .`
PORT_TO_BUILD=${{ matrix.PORT }}
# disable tmpfs to save memory
echo USE_TMPFS=no | sudo tee -a /usr/local/etc/poudriere.conf
# avoid crushing guest OS due to running out of disk space
MAX_JOBS=1
Expand All @@ -90,6 +108,19 @@ jobs:
sudo poudriere ports -c -p overlay -B "${{ env.BRANCH_NAME }}" -m git+file -U "${OVERLAY_DIR}"
poudriere ports -l
# build pkg, which creates data/packages/${JAIL_NAME}-${PORTS_NAME}/All
# so that packages cache can be extracted under the directory.
# the `All` directory is a symlink and computed by poudriere.
sudo poudriere bulk -j "${JAIL_NAME}" -b latest -J "${MAX_JOBS}" ports-mgmt/pkg
tree "/usr/local/poudriere/data/packages/${JAIL_NAME}-${PORTS_NAME}/All"
# pre-fill packages cache
if [ -d packages ]; then
ls -al packages
cp -R packages/* "/usr/local/poudriere/data/packages/${JAIL_NAME}-${PORTS_NAME}/All/"
rm -rf packages
fi
# build the ports with the overlay (-o) and binary packages from
# PACKAGE_FETCH_URL (-b). Test the port with Q/A checks (-Ct). use
# `true` to prevent failure on build failures. the job will fail
Expand All @@ -100,6 +131,9 @@ jobs:
tree "/usr/local/poudriere/data/logs/bulk/${JAIL_NAME}-${PORTS_NAME}/latest/logs"
sudo cp -R "/usr/local/poudriere/data/logs/bulk/${JAIL_NAME}-${PORTS_NAME}/latest/logs" ${OVERLAY_DIR}/logs
# collect the built packages
sudo cp -RL "/usr/local/poudriere/data/packages/${JAIL_NAME}-${PORTS_NAME}/All" "${OVERLAY_DIR}/packages"
df -h -tufs
- name: Create a safe port name from matrix.PORT
Expand All @@ -115,6 +149,13 @@ jobs:
name: logs-${{ env.SAFE_PORT_NAME }}
path: logs/

- name: upload packages
id: packages-upload-step
uses: actions/upload-artifact@v4
with:
name: packages-${{ env.SAFE_PORT_NAME }}
path: packages/

- name: Fail if any build failed
shell: sh
run: |
Expand All @@ -132,9 +173,32 @@ jobs:
cat failed_packages.txt
echo "Logs are available in an artifact. ID: ${{ steps.logs-upload-step.outputs.artifact-id }}"
echo "Packages are available in an artifact. ID: ${{ steps.packages-upload-step.outputs.artifact-id }}"
EXIT_STATUS=0
if [ ! -z "${FAILED_PACKAGES}" ]; then
EXIT_STATUS=1
fi
exit "${EXIT_STATUS}"
store-packages:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download built packages
uses: actions/download-artifact@v4
with:
pattern: packages-*
merge-multiple: true

- name: List package cache
shell: sh
run: |
tree packages
- name: Upload packages cache for future builds
uses: actions/upload-artifact@v4
with:
name: packages-cache
path: packages

0 comments on commit 34104a4

Please sign in to comment.