Closed xnox closed 1 week ago
Here is an example yaml that works exits success on melange at 0.8.6 but fails on master.
package:
name: test-me
version: 1.0
epoch: 0
environment:
contents:
packages:
- busybox
- git
pipeline:
- runs: |
set -x
mkdir d1
cd d1
echo "hello" > f1.dist
echo "goodbye" > f1
git diff --no-index f1.dist f1 > ../changes.diff || :
cp f1.dist f1
cp f1.dist ../f1
- working-directory: /home/build/d1
pipeline:
# the working directory above does not get applied to the patch pipeline
# below, but does get applied to the 'runs' pipelin.
- uses: patch
with:
patches: /home/build/changes.diff
- name: "Test working-directory inherited by patch pipeline"
runs: |
d1f1=$(cat /home/build/d1/f1)
f1=$(cat /home/build/f1)
echo "d1/f1 expected 'goodbye' found '$d1f1'"
echo "f1 expected 'hello' found '$f1'"
[ "$d1f1" = "goodbye" ] || fail="d1f1"
[ "$f1" = "hello" ] || fail="$fail f1"
if [ -n "$fail" ]; then
echo "FAIL: ${fail# }"
exit 1
fi
echo "PASS"
- name: "Test working directory of runs"
runs: |
exp=/home/build/d1
d=$(pwd)
echo "pwd expected '$exp' found '$d'"
if [ "$d" != "$exp" ]; then
echo "FAIL: expected pwd of $exp found $d"
fi
echo PASS
This is fixed with https://github.com/chainguard-dev/melange/pull/1312.
$ melange version
__ __ _____ _ _ _ _ ____ _____
| \/ | | ____| | | / \ | \ | | / ___| | ____|
| |\/| | | _| | | / _ \ | \| | | | _ | _|
| | | | | |___ | |___ / ___ \ | |\ | | |_| | | |___
|_| |_| |_____| |_____| /_/ \_\ |_| \_| \____| |_____|
melange
GitVersion: devel
GitCommit: 3cf5782215a0e9c4073c9dd6dfd69e4e410be438
GitTreeState: dirty
BuildDate: 2024-06-19T21:14:46
GoVersion: go1.22.3
Compiler: gc
Platform: linux/amd64
$ melange build ./test-me.yaml \
--repository-append ./packages \
--keyring-append local-melange.rsa.pub \
--signing-key local-melange.rsa \
--arch x86_64 --env-file build-x86_64.env \
--namespace wolfi \
--generate-index false \
--pipeline-dir ./pipelines/ \
-k https://packages.wolfi.dev/os/wolfi-signing.rsa.pub \
-r https://packages.wolfi.dev/os \
--source-dir ./test-me
...
2024/06/20 12:32:04 INFO ImgRef = /tmp/melange-guest-1896644730
2024/06/20 12:32:04 WARN + mkdir d1
2024/06/20 12:32:04 WARN + cd d1
2024/06/20 12:32:04 WARN + echo hello
2024/06/20 12:32:04 WARN + echo goodbye
2024/06/20 12:32:04 WARN + git diff --no-index f1.dist f1
2024/06/20 12:32:04 WARN + :
2024/06/20 12:32:04 WARN + cp f1.dist f1
2024/06/20 12:32:04 WARN + cp f1.dist ../f1
2024/06/20 12:32:04 WARN + exit 0
2024/06/20 12:32:04 INFO running step "Apply patches"
2024/06/20 12:32:04 INFO patching file f1
2024/06/20 12:32:04 INFO running step "Test working-directory inherited by patch pipeline"
2024/06/20 12:32:04 INFO d1/f1 expected 'goodbye' found 'goodbye'
2024/06/20 12:32:04 INFO f1 expected 'hello' found 'hello'
2024/06/20 12:32:04 INFO PASS
2024/06/20 12:32:04 INFO running step "Test working directory of runs"
2024/06/20 12:32:04 INFO pwd expected '/home/build/d1' found '/home/build/d1'
2024/06/20 12:32:04 INFO PASS
2024/06/20 12:32:04 INFO retrieving workspace from builder:
2024/06/20 12:32:04 INFO retrieved and wrote post-build workspace to: /tmp/melange-workspace-726653337
2024/06/20 12:32:04 INFO running package linters for test-me
2024/06/20 12:32:04 WARN WARNING: package is empty but no-provides is not set
2024/06/20 12:32:04 INFO generating SBOM for test-me
2024/06/20 12:32:04 WARN no license specified, defaulting to NOASSERTION
...
Full details in:
https://github.com/wolfi-dev/os/pull/22249/files#r1646501845
In essence: