Skip to content

Commit a4e0560

Browse files
authored
Merge pull request #8 from RetroDECK/cooker
Cooker
2 parents 7c44c83 + 46bfd33 commit a4e0560

File tree

1,196 files changed

+49690
-991
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,196 files changed

+49690
-991
lines changed
Lines changed: 115 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Build RetroDECK Components"
1+
name: "Alchemic Circle: Build RetroDECK Components"
22

33
on:
44
push:
@@ -9,8 +9,8 @@ on:
99

1010
workflow_dispatch:
1111

12-
schedule:
13-
- cron: '00 17 * * *' # 2:00 AM JST (JST is UTC+9, so 17:00 UTC)
12+
# schedule:
13+
# - cron: '00 17 * * *' # 2:00 AM JST (JST is UTC+9, so 17:00 UTC)
1414

1515
permissions:
1616
contents: write
@@ -31,22 +31,48 @@ jobs:
3131
run: |
3232
heavy=()
3333
light=()
34-
35-
for recipe in */recipe.sh; do
36-
if grep -q "flatpak_id_CULO" "$recipe"; then #TODO: we might not need this anymore
37-
heavy+=("$recipe")
34+
35+
# define here all the "source_url" that must be built on the "heavy" runner
36+
heavy_list=()
37+
38+
for recipe in */component_recipe.json; do
39+
# Skip if the glob didn't match any real file
40+
[ -f "$recipe" ] || continue
41+
42+
# Extract the first source_url present in the recipe file (if any)
43+
source_url=$(jq -r '..|objects|.source_url? // empty' "$recipe" | head -n1 || echo "")
44+
45+
# If heavy_list is defined and we have a source_url, check if the source_url is in the heavy_list
46+
if [[ ${#heavy_list[@]} -gt 0 && -n "$source_url" ]]; then
47+
matched=0
48+
for h in "${heavy_list[@]}"; do
49+
if [[ "$source_url" == "$h" ]]; then
50+
# assign directly to heavy and stop searching
51+
heavy+=("$(jq -n --arg r "$recipe" --arg c "$(basename "$(dirname "$recipe")")" '{recipe:$r,component:$c}')")
52+
matched=1
53+
break
54+
fi
55+
done
56+
57+
# if no match found, go to light
58+
if [[ $matched -eq 0 ]]; then
59+
light+=("$(jq -n --arg r "$recipe" --arg c "$(basename "$(dirname "$recipe")")" '{recipe:$r,component:$c}')")
60+
fi
3861
else
39-
light+=("$recipe")
62+
# no heavy_list or no source_url -> default to light
63+
light+=("$(jq -n --arg r "$recipe" --arg c "$(basename "$(dirname "$recipe")")" '{recipe:$r,component:$c}')")
4064
fi
4165
done
42-
43-
heavy_json=$(printf '%s\n' "${heavy[@]}" | jq -R . | jq -s -c .)
44-
light_json=$(printf '%s\n' "${light[@]}" | jq -R . | jq -s -c .)
45-
66+
67+
# Each entry in heavy/light is a raw JSON object string; combine them into a JSON array
68+
heavy_json=$(printf '%s\n' "${heavy[@]}" | jq -s -c .)
69+
light_json=$(printf '%s\n' "${light[@]}" | jq -s -c .)
70+
4671
echo "heavy=$heavy_json" >> $GITHUB_OUTPUT
4772
echo "light=$light_json" >> $GITHUB_OUTPUT
4873
4974
build-light:
75+
name: "Build ${{ matrix.recipe.component }}"
5076
needs: setup-recipes
5177
runs-on: ubuntu-latest
5278
if: github.event_name != 'schedule' || github.ref == 'refs/heads/update/components'
@@ -96,20 +122,20 @@ jobs:
96122
git log -1 --oneline
97123
98124
# Run Build
99-
- name: Run Build Artifacts
125+
- name: 'Alchemist: Run Build Artifacts'
100126
run: |
101-
source automation-tools/utils.sh
102-
artifact_name=$(basename $(dirname "${{ matrix.recipe }}"))
103-
echo "artifact_name=$artifact_name" >> $GITHUB_ENV
104-
bash "${{ matrix.recipe }}"
127+
# Use the component name provided in the matrix entry
128+
echo "artifact_name=${{ matrix.recipe.component }}" >> $GITHUB_ENV
129+
automation-tools/alchemist/alchemist.sh -f "${{ matrix.recipe.recipe }}"
105130
106131
- name: Upload Artifacts
107132
uses: actions/upload-artifact@v4
108133
with:
109134
name: ${{ env.artifact_name }}
110135
path: ${{ env.artifact_name }}/artifacts/*
111-
136+
112137
build-heavy:
138+
name: "Build ${{ matrix.recipe.component }}"
113139
needs: setup-recipes
114140
runs-on: retrodeck
115141
if: (github.event_name != 'schedule' || github.ref == 'refs/heads/update/components') && fromJSON(needs.setup-recipes.outputs.heavy-matrix).length > 0
@@ -156,12 +182,17 @@ jobs:
156182
git log -1 --oneline
157183
158184
# Run Build
159-
- name: Run Build Artifacts
185+
- name: 'Alchemist: Run Build Artifacts'
160186
run: |
161-
source automation-tools/utils.sh
162-
artifact_name=$(basename $(dirname "${{ matrix.recipe }}"))
163-
echo "artifact_name=$artifact_name" >> $GITHUB_ENV
164-
bash "${{ matrix.recipe }}"
187+
# Use the component name provided in the matrix entry
188+
echo "artifact_name=${{ matrix.recipe.component }}" >> $GITHUB_ENV
189+
automation-tools/alchemist/alchemist.sh -f "${{ matrix.recipe.recipe }}"
190+
191+
- name: Upload Artifacts
192+
uses: actions/upload-artifact@v4
193+
with:
194+
name: ${{ env.artifact_name }}
195+
path: ${{ env.artifact_name }}/artifacts/*
165196

166197
Release_RetroDECK_Components:
167198
needs: [build-light, build-heavy]
@@ -200,13 +231,55 @@ jobs:
200231
fi
201232
done
202233
203-
- name: Generate components_version.md
234+
- name: Generate components_version_list.md
204235
run: |
205-
source automation-tools/utils.sh
236+
# Loop through each <component_name> folder
237+
for component_dir in */; do
238+
# Skip automation-tools and other non-component directories
239+
if [[ "$component_dir" == "automation-tools/" ]] || [[ "$component_dir" == "downloaded-artifacts/" ]]; then
240+
continue
241+
fi
242+
243+
# Path to artifacts directory
244+
artifacts_dir="${component_dir}artifacts"
245+
246+
# Check if artifacts directory exists
247+
if [[ -d "$artifacts_dir" ]]; then
248+
# Look for tar.gz files in artifacts
249+
for archive in "$artifacts_dir"/*.tar.gz; do
250+
if [[ -f "$archive" ]]; then
251+
echo "Checking archive: $archive"
252+
253+
# Check if archive contains component_version file
254+
fullpath=$(tar -tzf "$archive" | grep 'component_version' | head -n 1)
255+
if [[ -n "$fullpath" ]]; then
256+
echo "Extracting $fullpath from $archive"
257+
tar -xzf "$archive" -C "$component_dir" "$fullpath"
258+
259+
# Clean up the ugly path (normalize it)
260+
extracted_path=$(realpath "$component_dir/$fullpath")
261+
normalized_path=$(realpath "$component_dir/component_version")
262+
263+
# Check if $fullpath is exactly 'component_version' (no leading dirs)
264+
if [[ "$extracted_path" != "$normalized_path" ]]; then
265+
mv -f "$extracted_path" "$normalized_path"
266+
fi
267+
else
268+
echo "No component_version found in $archive"
269+
echo "DEBUG: Listing contents of $archive"
270+
tar -tzf "$archive"
271+
fi
272+
fi
273+
done
274+
fi
275+
done
276+
277+
# Source the write function and call it
278+
source automation-tools/write_components_version.sh
206279
write_components_version
207-
echo "Components version file generated."
208-
cat components_version.md
209280
281+
# Show the resulting components_version_list.md file
282+
cat components_version_list.md
210283
- name: Generate a token for Rekku
211284
id: generate-rekku-token
212285
uses: actions/create-github-app-token@v1
@@ -275,8 +348,8 @@ jobs:
275348
echo "This is a RetroDECK Components Artifacts release from [this commit](https://github.com/${{ github.repository }}/commit/${{ github.sha }}), from branch [${{ env.BRANCH_NAME }}](https://github.com/RetroDECK/RetroDECK/tree/feat/${{ env.BRANCH_NAME }})." >> "$RELEASE_BODY_FILE"
276349
echo "" >> "$RELEASE_BODY_FILE"
277350
278-
# Append the contents of components_version.md to the release body
279-
cat components_version.md >> "$RELEASE_BODY_FILE"
351+
# Append the contents of components_version_list.md to the release body
352+
cat components_version_list.md >> "$RELEASE_BODY_FILE"
280353
echo "" >> "$RELEASE_BODY_FILE"
281354
282355
# Prepare array
@@ -347,14 +420,14 @@ jobs:
347420
tag: "${{ env.TAG }}"
348421
name: "RetroDECK Components ${{ env.TAG }}"
349422
body: ${{ steps.generate-body.outputs.RELEASE_BODY }}
350-
artifacts: "*/artifacts/*,!*/artifacts/version,components_version.md"
423+
artifacts: "*/artifacts/*,!*/artifacts/component_version,components_version_list.md"
351424
allowUpdates: true
352425
omitBodyDuringUpdate: true
353426
makeLatest: ${{ env.MAKE_LATEST }}
354427
repo: ${{ env.REPO_NAME }}
355428
token: ${{ steps.generate-rekku-token.outputs.token }}
356429

357-
- name: Create diff between target branch and PR components_version.md
430+
- name: Create diff between target branch and PR components_version_list.md
358431
run: |
359432
if [[ "${GITHUB_BASE_REF}" == "cooker" ]]; then
360433
TARGET_BRANCH="main"
@@ -363,18 +436,18 @@ jobs:
363436
fi
364437
365438
git fetch origin $TARGET_BRANCH
366-
if [ -f "components_version.md" ]; then
367-
if git show origin/$TARGET_BRANCH:components_version.md > target_components_version.md 2>/dev/null; then
368-
echo "Generating diff between $TARGET_BRANCH and PR components_version.md..."
369-
diff -u target_components_version.md components_version.md > components_version_diff.txt || true
439+
if [ -f "components_version_list.md" ]; then
440+
if git show origin/$TARGET_BRANCH:components_version_list.md > target_components_version_list.md 2>/dev/null; then
441+
echo "Generating diff between $TARGET_BRANCH and PR components_version_list.md..."
442+
diff -u target_components_version_list.md components_version_list.md > components_version_diff.txt || true
370443
echo "Diff saved to components_version_diff.txt"
371444
else
372-
echo "components_version.md does not exist on $TARGET_BRANCH branch. Skipping diff."
373-
echo "No components_version.md on $TARGET_BRANCH branch." > components_version_diff.txt
445+
echo "components_version_list.md does not exist on $TARGET_BRANCH branch. Skipping diff."
446+
echo "No components_version_list.md on $TARGET_BRANCH branch." > components_version_diff.txt
374447
fi
375448
else
376-
echo "components_version.md not found in PR. Skipping diff."
377-
echo "No components_version.md in PR." > components_version_diff.txt
449+
echo "components_version_list.md not found in PR. Skipping diff."
450+
echo "No components_version_list.md in PR." > components_version_diff.txt
378451
fi
379452
380453
- name: Write PR body
@@ -387,14 +460,15 @@ jobs:
387460
echo "## Changes:" >> pr_body.md
388461
echo "$(cat commits_list.txt)" >> pr_body.md
389462
echo "" >> pr_body.md
390-
echo "## Diff between main and PR components_version.md:" >> pr_body.md
463+
echo "## Diff between main and PR components_version_list.md:" >> pr_body.md
391464
echo "```diff" >> pr_body.md
392465
echo "$(cat components_version_diff.txt)" >> pr_body.md
393466
echo "```" >> pr_body.md
394467
468+
# Skipped on cooker as you cannot open PRs against the same branch
395469
- name: Open Pull Request
396470
uses: peter-evans/create-pull-request@v7
397-
if: github.event_name != 'schedule' || github.ref == 'refs/heads/update/components' && github.head_ref != github.base_ref
471+
if: (github.event_name != 'schedule' || github.ref == 'refs/heads/update/components') && github.head_ref != github.base_ref && env.BRANCH_NAME != 'cooker'
398472
with:
399473
token: ${{ steps.generate-rekku-token.outputs.token }}
400474
commit-message: "Update RetroDECK Components Artifacts"

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
downloaded-artifacts
22
*/artifacts
33
.tmpfunc
4-
grab.log
4+
*.log
5+
_work
6+
.flatpak-builder
7+
component_version
8+
components_version_list.md
9+
squashfs-root
10+
11+
#just temporary until Alchemist is integrated here
12+
automation-tools/Alchemist-temp

0 commit comments

Comments
 (0)