Skip to content

Commit

Permalink
experiment II
Browse files Browse the repository at this point in the history
  • Loading branch information
cpanato committed Feb 28, 2024
1 parent c1b90d6 commit fa59cf5
Showing 1 changed file with 12 additions and 110 deletions.
122 changes: 12 additions & 110 deletions ci-build-packages/action.yaml
Expand Up @@ -10,118 +10,20 @@ inputs:
packages:
required: true
description: "packages to build."
script_to_run:
required: true
description: "packages to build."
token:
description: "GH Token"
required: false

outputs:
packages_were_built:
description: 'Built packages.'
value: ${{ steps.build.outputs.packages_were_built }}

runs:
using: "composite"

steps:
- name: "Install wolfictl onto PATH"
uses: wolfi-dev/actions/install-wolfictl@main

- name: Generate snapshot date
id: snapshot-date
run: |
echo "date=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT"
echo "epoch=$(date -u +%s)" >> "$GITHUB_OUTPUT"
shell: bash

- name: 'Build Wolfi'
shell: bash
run: |
# Setup the melange cache dir on the host so we can use that in subsequent builds
mkdir ../.melangecache
for package in ${{ inputs.packages }}; do
make MELANGE_EXTRA_OPTS="--create-build-log --cache-dir=$(pwd)/../.melangecache" REPO="$GITHUB_WORKSPACE/packages" package/$package -j1
make REPO="$GITHUB_WORKSPACE/packages" test/$package -j1
done
- name: Check for file
id: file_check
shell: bash
run: |
if test -f "packages.log"; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
touch packages.log
- name: Identify newly built packages
id: list_built_packages
shell: bash
if: ${{ steps.file_check.outputs.exists == 'true'}}
run: |
{
echo 'files_to_upload<<EOF'
awk -F'|' '{ printf "./packages/%s/%s-%s.apk\n", $1, $3, $4}' < packages.log
echo EOF
} >> "$GITHUB_OUTPUT"
- name: "Check that packages can be installed with apk add"
shell: bash
run: |
# Create a fake linux fs under /tmp/emptyroot to pass to `apk --root`.
mkdir -p /tmp/emptyroot/etc/apk
cp -r /etc/apk/* /tmp/emptyroot/etc/apk/
cat /dev/null > /tmp/emptyroot/etc/apk/world
mkdir -p /tmp/emptyroot/lib/apk/db
touch /tmp/emptyroot/lib/apk/db/{installed,lock,scripts.tar,triggers}
mkdir -p /tmp/emptyroot/var/cache/apk
apk update --root /tmp/emptyroot
# Find .apk files and add them to the string
for f in $(echo "${{ steps.list_built_packages.outputs.files_to_upload }}"); do
tar -Oxf $f .PKGINFO
apk add --root /tmp/emptyroot --repository ./packages --allow-untrusted --simulate $f
done
- name: Check diff
shell: bash
if: steps.file_check.outputs.exists == 'true'
# Let's not fail the whole job if this step fails as it is for improved UX rather than an enforced check
continue-on-error: true
run: |
wolfictl check diff
- name: Check for diff file
id: diff_file_check
shell: bash
run: |
if test -f "diff.log"; then
cat diff.log
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
# Use the x86_64 build results for the comment for now so we don't have duplicates.
- name: PR comment diff
if: steps.diff_file_check.outputs.exists == 'true' && ${{ inputs.arch }} == 'x86_64'
uses: thollander/actions-comment-pull-request@632cf9ce90574d125be56b5f3405cda41a84e2fd # v2.3.1
# We're seeing jobs using merge queues fail
continue-on-error: true
with:
filePath: diff.log
GITHUB_TOKEN: ${{ inputs.token }}

- name: 'Upload built packages to GitHub artifacts'
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
path: |
${{ steps.list_built_packages.outputs.files_to_upload }}
./packages.log
name: packages-${{ inputs.arch }}
retention-days: 1
if-no-files-found: warn
using: 'docker'
image: 'docker://ghcr.io/wolfi-dev/sdk:latest@sha256:7c1012eb43ee829351f3b33eb0f150ca2d2e176545bd58a398a7427f5645d9c9'
entrypoint: /bin/bash
args:
- -c
- ${{ inputs.script_to_run }}
env:
GITHUB_TOKEN: ${{ inputs.token }}
PACKAGES: ${{ inputs.packages }}

0 comments on commit fa59cf5

Please sign in to comment.