Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn committed Feb 29, 2024
1 parent dbf3c3a commit 8249339
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 12 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/image-diff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
run: |
go install github.com/google/go-containerregistry/cmd/crane@main
go install github.com/reproducible-containers/diffoci/cmd/diffoci@master
# curl -fsSL "https://github.com/project-zot/zot/releases/download/v2.0.2-rc2/zot-linux-amd64-minimal" > /usr/bin/zot
# chmod +x /usr/bin/zot
sudo apt-get install parallel -y
- name: Diff All Images
id: diff
Expand All @@ -35,14 +37,17 @@ jobs:
--head-ref ${{ github.head_ref }} \
--base-ref ${{ github.event.pull_request.base.ref }} \
--set-github-output-on-diff \
--report ./report.log \
--jobs $(nproc --all)
# --jobs $(nproc --all) \
--errors ./error.log \
--report ./report.log
- uses: actions/upload-artifact@v4
id: report
with:
name: "Report"
path: "./report.log"
path: |
./error.log
./report.log
- uses: peter-evans/find-comment@v3
id: fc
Expand Down
45 changes: 36 additions & 9 deletions private/diff.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ set -o pipefail -o errexit -o nounset

# try with ./private/diff.bash --head-ref test --base-ref test --query-bazel --registry-spawn

readonly STDERR=$(mktemp)
readonly DISK_STORAGE=/tmp/diff-storage
STDERR=$(mktemp)

# Upon exiting, stop the registry and print STDERR on non-zero exit code.
on_exit() {
Expand All @@ -21,20 +20,17 @@ on_exit() {
fi
fi
pkill -P $$
rm -f $STDERR
}
trap "on_exit" EXIT

# Redirect stderr to the $STDERR temp file for the rest of the script.
exec 2>>"${STDERR}"

PID=
HEAD_REF=
BASE_REF=
QUERY_FILE=
REPORT_FILE=
REGISTRY=
JOBS=
STDERR=
SET_GITHUB_OUTPUT="0"

while (( $# > 0 )); do
Expand Down Expand Up @@ -75,6 +71,10 @@ while (( $# > 0 )); do
JOBS="$2"
shift 2
;;
(--errors)
STDERR="$2"
shift 2;
;;
(*)
echo "unknown arg $1"
exit 1
Expand Down Expand Up @@ -104,11 +104,38 @@ if [[ -z "${QUERY_FILE}" ]]; then
fi


# Redirect stderr to the $STDERR temp file for the rest of the script.
exec 2>>"${STDERR}"

DISK_STORAGE="/tmp/diff-storage"

if [[ "${QUERY_FILE}" == "bazel" ]]; then
bazel build :sign_and_push.query
QUERY_FILE=$(bazel cquery --output=files :sign_and_push.query)
fi

# if [[ "${REGISTRY}" == "spawn" ]]; then
# # Make a self signed cert
# rm -f /tmp/localhost.pem /tmp/localhost.pem
# rm -rf $DISK_STORAGE
# mkcert -install
# (cd /tmp && mkcert localhost)
# echo '{
# "http":{
# "address":"127.0.0.1", "port":"4564",
# "tls": {
# "cert":"/tmp/localhost.pem",
# "key":"/tmp/localhost-key.pem"
# }
# },
# "log": { "level": "info" },
# "storage":{"rootDirectory":"/tmp/diff-storage"}
# }' > /tmp/cfg.json
# REGISTRY="localhost:4564"
# zot serve /tmp/cfg.json &
# sleep 2
# fi

if [[ "${REGISTRY}" == "spawn" ]]; then
rm -rf $DISK_STORAGE
mkdir $DISK_STORAGE
Expand Down Expand Up @@ -148,9 +175,8 @@ function test_image () {
ref=$(bazel run $push_label -- --repository $repo_stage --tag $tag_stamped)
echo "Pushed, diffing"

sleep 0.01

if ! diffoci diff --semantic "$repo_origin:$tag_stamped" "$repo_stage:$tag_stamped" --pull always; then
if ! diffoci diff --semantic "$repo_origin:$tag_stamped" "$repo_stage:$tag_stamped" --pull always --platform linux/amd64; then
echo ""
echo "👎 $repo_origin:$tag_stamped and $repo_stage:$tag_stamped are different."
if [[ "${SET_GITHUB_OUTPUT}" == "1" ]]; then
Expand All @@ -173,12 +199,13 @@ fi


# Parallelize using gnu parallel
if [[ -n "${JOBS}" ]]; then
if [[ "${JOBS}" -gt 0 ]]; then
export HEAD_REF BASE_REF REGISTRY REPORT_FILE SET_GITHUB_OUTPUT
export -f stamp_origin stamp_stage test_image
cat "${QUERY_FILE}" | parallel --eta --progress --jobs "${JOBS}" "set -o pipefail -o errexit -o nounset && test_image"
else
while IFS= read -r line || [ -n "$line" ]; do
test_image "${line}"
break
done < "${QUERY_FILE}"
fi

0 comments on commit 8249339

Please sign in to comment.