Skip to content

Commit 4f7ee76

Browse files
committed
determine cache type from pkg_type
1 parent 825a2e3 commit 4f7ee76

5 files changed

Lines changed: 265 additions & 46 deletions

File tree

.github/workflows/build-on-change.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ jobs:
7070
# Manual trigger with specific recipe
7171
if [ -f "${{ inputs.recipe_path }}" ]; then
7272
RECIPE="${{ inputs.recipe_path }}"
73-
CHANGED_RECIPES=$(jq -n --arg path "$RECIPE" '[{"path": $path}]')
73+
pkg_type=$(grep -E "^pkg_type:" "$RECIPE" | head -1 | sed 's/pkg_type:[[:space:]]*//; s/^["'"'"']//; s/["'"'"']$//' || echo "")
74+
CHANGED_RECIPES=$(jq -n --arg path "$RECIPE" --arg pkg_type "$pkg_type" '[{"path": $path, "pkg_type": $pkg_type}]')
7475
else
7576
echo "::error::Recipe not found: ${{ inputs.recipe_path }}"
7677
exit 1
@@ -92,10 +93,11 @@ jobs:
9293
echo "Changed files:"
9394
echo "$CHANGED_FILES"
9495
95-
# Build JSON array of changed recipes
96+
# Build JSON array of changed recipes with pkg_type
9697
for file in $CHANGED_FILES; do
9798
if [ -f "$file" ]; then
98-
CHANGED_RECIPES=$(echo "$CHANGED_RECIPES" | jq --arg path "$file" '. + [{"path": $path}]')
99+
pkg_type=$(grep -E "^pkg_type:" "$file" | head -1 | sed 's/pkg_type:[[:space:]]*//; s/^["'"'"']//; s/["'"'"']$//' || echo "")
100+
CHANGED_RECIPES=$(echo "$CHANGED_RECIPES" | jq --arg path "$file" --arg pkg_type "$pkg_type" '. + [{"path": $path, "pkg_type": $pkg_type}]')
99101
fi
100102
done
101103
fi
@@ -117,6 +119,7 @@ jobs:
117119
118120
echo "$CHANGED_RECIPES" | jq -c '.[]' | while read -r recipe; do
119121
path=$(echo "$recipe" | jq -r '.path')
122+
pkg_type=$(echo "$recipe" | jq -r '.pkg_type')
120123
pkg_name=$(basename "$(dirname "$path")")
121124
122125
# Skip cache check if force rebuild
@@ -139,7 +142,7 @@ jobs:
139142
cached_status=$(echo "$cached_info" | jq -r '.last_build_status // ""' 2>/dev/null || echo "")
140143
141144
if [ "$cached_hash" == "$current_hash" ] && [ "$cached_status" == "success" ]; then
142-
echo "::notice::Skipping $pkg_name - already built with same hash"
145+
echo "::notice::Skipping $pkg_name - already built with same hash" >&2
143146
continue
144147
fi
145148
fi
@@ -172,7 +175,7 @@ jobs:
172175
uses: ./.github/workflows/matrix_builds.yaml
173176
with:
174177
sbuild-url: "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/${{ matrix.recipe.path }}"
175-
ghcr-url: ${{ contains(matrix.recipe.path, 'packages/') && format('ghcr.io/{0}/pkgcache', github.repository_owner) || format('ghcr.io/{0}/bincache', github.repository_owner) }}
178+
ghcr-url: ghcr.io/${{ github.repository_owner }}
176179
pkg-family: ${{ github.event.repository.name }}
177180
rebuild: true
178181
logs: true

.github/workflows/manual-build.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ on:
1515
- x86_64-Linux
1616
- aarch64-Linux
1717
default: 'x86_64-Linux'
18-
cache_type:
19-
description: 'Cache type (auto-detected from path if not specified)'
20-
type: choice
21-
options:
22-
- auto
23-
- bincache
24-
- pkgcache
25-
default: 'auto'
2618

2719
jobs:
2820
validate:
@@ -80,7 +72,7 @@ jobs:
8072
with:
8173
host: ${{ inputs.host }}
8274
sbuild-url: "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/${{ needs.validate.outputs.recipe }}"
83-
ghcr-url: ${{ contains(needs.validate.outputs.recipe, 'packages/') && format('ghcr.io/{0}/pkgcache', github.repository_owner) || format('ghcr.io/{0}/bincache', github.repository_owner) }}
75+
ghcr-url: ghcr.io/${{ github.repository_owner }}
8476
pkg-family: ${{ github.event.repository.name }}
8577
rebuild: true
8678
logs: true

.github/workflows/pr-build-test.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ jobs:
7373
7474
for file in $CHANGED_FILES; do
7575
if [ -f "$file" ]; then
76-
CHANGED_RECIPES=$(echo "$CHANGED_RECIPES" | jq --arg path "$file" '. + [{"path": $path}]')
76+
pkg_type=$(grep -E "^pkg_type:" "$file" | head -1 | sed 's/pkg_type:[[:space:]]*//; s/^["'"'"']//; s/["'"'"']$//' || echo "")
77+
CHANGED_RECIPES=$(echo "$CHANGED_RECIPES" | jq --arg path "$file" --arg pkg_type "$pkg_type" '. + [{"path": $path, "pkg_type": $pkg_type}]')
7778
fi
7879
done
7980
@@ -100,7 +101,7 @@ jobs:
100101
with:
101102
host: ${{ inputs.host }}
102103
sbuild-url: "https://raw.githubusercontent.com/${{ github.repository }}/${{ needs.detect-changes.outputs.pr_head_sha }}/${{ matrix.recipe.path }}"
103-
ghcr-url: ${{ contains(matrix.recipe.path, 'packages/') && format('ghcr.io/{0}/pkgcache', github.repository_owner) || format('ghcr.io/{0}/bincache', github.repository_owner) }}
104+
ghcr-url: ghcr.io/${{ github.repository_owner }}
104105
pkg-family: ${{ github.event.repository.name }}
105106
rebuild: true
106107
logs: true
@@ -242,12 +243,6 @@ jobs:
242243
pkg_family=$(echo "$recipe_path" | cut -d'/' -f2)
243244
recipe_name=$(basename "$recipe_path" .yaml 2>/dev/null || echo "unknown")
244245
245-
# Determine cache type from path
246-
if echo "$recipe_path" | grep -q "^packages/"; then
247-
CACHE_TYPE="pkgcache"
248-
else
249-
CACHE_TYPE="bincache"
250-
fi
251246
252247
case "$status" in
253248
success)

.github/workflows/release-metadata.yaml

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,48 @@ jobs:
5353
}
5454
chmod +x /usr/local/bin/soarql
5555
56+
- name: Filter recipes by pkg_type
57+
run: |
58+
mkdir -p /tmp/bincache-recipes /tmp/pkgcache-recipes /tmp/output
59+
60+
# Find all recipes and filter by pkg_type
61+
for recipe in $(find binaries packages -name "*.yaml" -type f 2>/dev/null); do
62+
pkg_type=$(grep -E "^pkg_type:" "$recipe" | head -1 | sed 's/pkg_type:[[:space:]]*//; s/^["'"'"']//; s/["'"'"']$//' || echo "")
63+
64+
# Create directory structure and copy recipe
65+
rel_path=$(dirname "$recipe")
66+
if [ "$pkg_type" = "static" ] || [ "$pkg_type" = "dynamic" ]; then
67+
mkdir -p "/tmp/bincache-recipes/$rel_path"
68+
cp "$recipe" "/tmp/bincache-recipes/$recipe"
69+
else
70+
mkdir -p "/tmp/pkgcache-recipes/$rel_path"
71+
cp "$recipe" "/tmp/pkgcache-recipes/$recipe"
72+
fi
73+
done
74+
75+
echo "=== Bincache recipes (static/dynamic) ==="
76+
find /tmp/bincache-recipes -name "*.yaml" 2>/dev/null | wc -l
77+
78+
echo "=== Pkgcache recipes (other pkg_types) ==="
79+
find /tmp/pkgcache-recipes -name "*.yaml" 2>/dev/null | wc -l
80+
5681
- name: Generate bincache metadata
5782
env:
5883
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5984
run: |
60-
mkdir -p /tmp/output
61-
62-
# Note: For test repo, the packages are pushed to bincache-test
63-
# sbuild-meta will look for ghcr.io/pkgforge/bincache-test/<pkg>
64-
sbuild-meta generate \
65-
--arch "${{ matrix.arch }}" \
66-
--recipes ./binaries \
67-
--output /tmp/output \
68-
--cache-type bincache \
69-
--parallel 4 \
70-
--ghcr-owner pkgforge-dev \
71-
--github-token "$GITHUB_TOKEN" || {
72-
echo "::warning::bincache metadata generation failed or no packages found"
73-
}
85+
# Generate metadata for static/dynamic packages (bincache)
86+
if [ -n "$(find /tmp/bincache-recipes -name '*.yaml' 2>/dev/null)" ]; then
87+
sbuild-meta generate \
88+
--arch "${{ matrix.arch }}" \
89+
--recipes /tmp/bincache-recipes \
90+
--output /tmp/output \
91+
--cache-type bincache \
92+
--parallel 4 \
93+
--ghcr-owner pkgforge-dev \
94+
--github-token "$GITHUB_TOKEN" || {
95+
echo "::warning::bincache metadata generation failed or no packages found"
96+
}
97+
fi
7498
7599
# Rename to include cache type
76100
if [ -f "/tmp/output/bincache/${{ matrix.arch }}.json" ]; then
@@ -85,16 +109,19 @@ jobs:
85109
env:
86110
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87111
run: |
88-
sbuild-meta generate \
89-
--arch "${{ matrix.arch }}" \
90-
--recipes ./packages \
91-
--output /tmp/output \
92-
--cache-type pkgcache \
93-
--parallel 4 \
94-
--ghcr-owner pkgforge-dev \
95-
--github-token "$GITHUB_TOKEN" || {
96-
echo "::warning::pkgcache metadata generation failed or no packages found"
97-
}
112+
# Generate metadata for non-static/dynamic packages (pkgcache)
113+
if [ -n "$(find /tmp/pkgcache-recipes -name '*.yaml' 2>/dev/null)" ]; then
114+
sbuild-meta generate \
115+
--arch "${{ matrix.arch }}" \
116+
--recipes /tmp/pkgcache-recipes \
117+
--output /tmp/output \
118+
--cache-type pkgcache \
119+
--parallel 4 \
120+
--ghcr-owner pkgforge-dev \
121+
--github-token "$GITHUB_TOKEN" || {
122+
echo "::warning::pkgcache metadata generation failed or no packages found"
123+
}
124+
fi
98125
99126
# Rename to include cache type
100127
if [ -f "/tmp/output/pkgcache/${{ matrix.arch }}.json" ]; then

0 commit comments

Comments
 (0)