removed fallback to main repo clone in the workflows, and redundant repo clone in the linux build script

This commit is contained in:
cheezwiz7899
2026-05-06 16:57:08 +12:00
parent 1716ff43fd
commit a28ad80f70
5 changed files with 141 additions and 51 deletions
+38 -12
View File
@@ -2,7 +2,6 @@ name: Build Citron (Android)
concurrency:
group: build-android-${{ inputs.pr_number || inputs.target_branch || github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
@@ -49,14 +48,14 @@ jobs:
REPO_URL="https://github.com/${HEAD_REPO}.git"
FULL_HASH=$(git ls-remote "$REPO_URL" "refs/heads/$TARGET_BRANCH" | cut -f1 | head -n1)
if [ -z "$FULL_HASH" ]; then
REPO_URL="https://github.com/${{ env.UPSTREAM_REPO }}.git"
TARGET_BRANCH="main"
FULL_HASH=$(git ls-remote "$REPO_URL" HEAD | cut -f1)
echo "::error::Could not resolve branch '${TARGET_BRANCH}' in '${HEAD_REPO}'. Refusing to fall back to main."
exit 1
fi
SHORT_HASH=$(echo "$FULL_HASH" | cut -c1-7)
echo "Resolved ${HEAD_REPO}@${TARGET_BRANCH} to ${FULL_HASH}"
echo "branch_name=$TARGET_BRANCH" >> $GITHUB_OUTPUT
echo "hash_short=$SHORT_HASH" >> $GITHUB_OUTPUT
echo "hash_full=$FULL_HASH" >> $GITHUB_OUTPUT
@@ -79,6 +78,7 @@ jobs:
exit 0
fi
echo "Checking for HASH_SHORT: $HASH_SHORT"
MARKER="<!-- citron-pr-builds:${PR_NUMBER} -->"
COMMENT_BODY=$(gh api "repos/${UPSTREAM}/issues/${PR_NUMBER}/comments?per_page=100" \
--jq "[.[] | select(.body | contains(\"$MARKER\") or contains(\"Build Artifacts for PR #${PR_NUMBER}\"))] | last | .body // empty" \
@@ -93,11 +93,15 @@ jobs:
PLATFORM_ROW=$(echo "$COMMENT_BODY" | grep "\*\*${PLATFORM}\*\*" || true)
echo "Platform row: $PLATFORM_ROW"
if echo "$PLATFORM_ROW" | grep -qF "$HASH_SHORT"; then
if echo "$PLATFORM_ROW" | grep -qE "(\[Standard\]|\[8 Elite\]|Failed)"; then
echo "Commit ${HASH_SHORT} already built or failed for ${PLATFORM}. Skipping."
if [ -n "$PLATFORM_ROW" ] && echo "$PLATFORM_ROW" | grep -qF "$HASH_SHORT"; then
if echo "$PLATFORM_ROW" | grep -qE "(\[Standard\]|\[8 Elite\]|Success|Failed)"; then
echo "Commit ${HASH_SHORT} already handled for ${PLATFORM}. Skipping."
echo "already_built=true" >> $GITHUB_OUTPUT
exit 0
elif echo "$PLATFORM_ROW" | grep -q "Building..."; then
echo "Commit ${HASH_SHORT} is currently building for ${PLATFORM}. Will build again to be safe."
echo "already_built=false" >> $GITHUB_OUTPUT
exit 0
fi
fi
@@ -182,8 +186,19 @@ jobs:
- name: Clone Citron Source
run: |
CLONE_REPO="${{ needs.check-version.outputs.head_repo }}"
if [[ "$CLONE_REPO" != *"/"* ]]; then CLONE_REPO="${{ env.UPSTREAM_REPO }}"; fi
git clone --recursive -b "${{ needs.check-version.outputs.branch_name }}" "https://github.com/${CLONE_REPO}.git" citron_source
BRANCH_NAME="${{ needs.check-version.outputs.branch_name }}"
EXPECTED_HASH="${{ needs.check-version.outputs.new_hash_full }}"
if [ -z "$CLONE_REPO" ] || [[ "$CLONE_REPO" != *"/"* ]]; then CLONE_REPO="${{ env.UPSTREAM_REPO }}"; fi
if [ -z "$BRANCH_NAME" ]; then BRANCH_NAME="main"; fi
echo "Cloning from $CLONE_REPO (branch: $BRANCH_NAME)..."
git clone --recursive -b "$BRANCH_NAME" "https://github.com/${CLONE_REPO}.git" citron_source
cd citron_source
ACTUAL_HASH=$(git rev-parse HEAD)
echo "Checked out ${CLONE_REPO}@${BRANCH_NAME}: ${ACTUAL_HASH}"
if [ -n "$EXPECTED_HASH" ] && [ "$ACTUAL_HASH" != "$EXPECTED_HASH" ]; then
echo "::error::Checked out ${ACTUAL_HASH}, expected ${EXPECTED_HASH}"
exit 1
fi
- name: Install Build Dependencies
run: |
@@ -252,8 +267,19 @@ jobs:
- name: Clone Citron Source
run: |
CLONE_REPO="${{ needs.check-version.outputs.head_repo }}"
if [[ "$CLONE_REPO" != *"/"* ]]; then CLONE_REPO="${{ env.UPSTREAM_REPO }}"; fi
git clone --recursive -b "${{ needs.check-version.outputs.branch_name }}" "https://github.com/${CLONE_REPO}.git" citron_source
BRANCH_NAME="${{ needs.check-version.outputs.branch_name }}"
EXPECTED_HASH="${{ needs.check-version.outputs.new_hash_full }}"
if [ -z "$CLONE_REPO" ] || [[ "$CLONE_REPO" != *"/"* ]]; then CLONE_REPO="${{ env.UPSTREAM_REPO }}"; fi
if [ -z "$BRANCH_NAME" ]; then BRANCH_NAME="main"; fi
echo "Cloning from $CLONE_REPO (branch: $BRANCH_NAME)..."
git clone --recursive -b "$BRANCH_NAME" "https://github.com/${CLONE_REPO}.git" citron_source
cd citron_source
ACTUAL_HASH=$(git rev-parse HEAD)
echo "Checked out ${CLONE_REPO}@${BRANCH_NAME}: ${ACTUAL_HASH}"
if [ -n "$EXPECTED_HASH" ] && [ "$ACTUAL_HASH" != "$EXPECTED_HASH" ]; then
echo "::error::Checked out ${ACTUAL_HASH}, expected ${EXPECTED_HASH}"
exit 1
fi
- name: Install Build Dependencies
run: |
+30 -11
View File
@@ -2,7 +2,6 @@ name: Build Citron (Linux)
concurrency:
group: build-linux-${{ inputs.pr_number || inputs.target_branch || github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
@@ -49,14 +48,14 @@ jobs:
REPO_URL="https://github.com/${HEAD_REPO}.git"
FULL_HASH=$(git ls-remote "$REPO_URL" "refs/heads/$TARGET_BRANCH" | cut -f1 | head -n1)
if [ -z "$FULL_HASH" ]; then
REPO_URL="https://github.com/${{ env.UPSTREAM_REPO }}.git"
TARGET_BRANCH="main"
FULL_HASH=$(git ls-remote "$REPO_URL" HEAD | cut -f1)
echo "::error::Could not resolve branch '${TARGET_BRANCH}' in '${HEAD_REPO}'. Refusing to fall back to main."
exit 1
fi
SHORT_HASH=$(echo "$FULL_HASH" | cut -c1-7)
echo "Resolved ${HEAD_REPO}@${TARGET_BRANCH} to ${FULL_HASH}"
echo "branch_name=$TARGET_BRANCH" >> $GITHUB_OUTPUT
echo "hash_short=$SHORT_HASH" >> $GITHUB_OUTPUT
echo "hash_full=$FULL_HASH" >> $GITHUB_OUTPUT
@@ -79,6 +78,7 @@ jobs:
exit 0
fi
echo "Checking for HASH_SHORT: $HASH_SHORT"
MARKER="<!-- citron-pr-builds:${PR_NUMBER} -->"
COMMENT_BODY=$(gh api "repos/${UPSTREAM}/issues/${PR_NUMBER}/comments?per_page=100" \
--jq "[.[] | select(.body | contains(\"$MARKER\") or contains(\"Build Artifacts for PR #${PR_NUMBER}\"))] | last | .body // empty" \
@@ -93,11 +93,15 @@ jobs:
PLATFORM_ROW=$(echo "$COMMENT_BODY" | grep "\*\*${PLATFORM}\*\*" || true)
echo "Platform row: $PLATFORM_ROW"
if echo "$PLATFORM_ROW" | grep -qF "$HASH_SHORT"; then
if echo "$PLATFORM_ROW" | grep -qE "(\[x86_64\]|\[v3\]|\[ARM\]|Failed)"; then
echo "Commit ${HASH_SHORT} already built or failed for ${PLATFORM}. Skipping."
if [ -n "$PLATFORM_ROW" ] && echo "$PLATFORM_ROW" | grep -qF "$HASH_SHORT"; then
if echo "$PLATFORM_ROW" | grep -qE "(\[x86_64\]|\[v3\]|\[ARM\]|Success|Failed)"; then
echo "Commit ${HASH_SHORT} already handled for ${PLATFORM}. Skipping."
echo "already_built=true" >> $GITHUB_OUTPUT
exit 0
elif echo "$PLATFORM_ROW" | grep -q "Building..."; then
echo "Commit ${HASH_SHORT} is currently building for ${PLATFORM}. Will build again to be safe."
echo "already_built=false" >> $GITHUB_OUTPUT
exit 0
fi
fi
@@ -172,7 +176,7 @@ jobs:
build:
name: "${{ matrix.name }}"
needs: [check-version, comment-start]
if: needs.check-version.outputs.should_build == 'true'
if: always() && needs.check-version.outputs.should_build == 'true'
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
@@ -209,11 +213,19 @@ jobs:
run: |
CLONE_REPO="${{ needs.check-version.outputs.head_repo }}"
BRANCH_NAME="${{ needs.check-version.outputs.branch_name }}"
EXPECTED_HASH="${{ needs.check-version.outputs.new_hash_full }}"
if [ -z "$CLONE_REPO" ] || [[ "$CLONE_REPO" != *"/"* ]]; then CLONE_REPO="${{ env.UPSTREAM_REPO }}"; fi
if [ -z "$BRANCH_NAME" ]; then BRANCH_NAME="main"; fi
echo "Cloning from $CLONE_REPO (branch: $BRANCH_NAME)..."
git clone --recurse-submodules --shallow-submodules --depth 1 -b "$BRANCH_NAME" "https://github.com/${CLONE_REPO}.git" emulator
cd emulator
ACTUAL_HASH=$(git rev-parse HEAD)
echo "Checked out ${CLONE_REPO}@${BRANCH_NAME}: ${ACTUAL_HASH}"
if [ -n "$EXPECTED_HASH" ] && [ "$ACTUAL_HASH" != "$EXPECTED_HASH" ]; then
echo "::error::Checked out ${ACTUAL_HASH}, expected ${EXPECTED_HASH}"
exit 1
fi
- name: Prepare Build Environment
run: |
@@ -241,7 +253,14 @@ jobs:
working-directory: ./emulator
run: |
GIT_SHA=$(git rev-parse --short HEAD)
export APP_VERSION="PR-${{ needs.check-version.outputs.pr_number }}-${GIT_SHA}"
PR_NUMBER="${{ needs.check-version.outputs.pr_number }}"
BRANCH_NAME="${{ needs.check-version.outputs.branch_name }}"
SAFE_BRANCH=$(printf '%s' "$BRANCH_NAME" | tr '/ ' '--' | tr -cd 'A-Za-z0-9._-')
if [ -n "$PR_NUMBER" ]; then
export APP_VERSION="PR-${PR_NUMBER}-${GIT_SHA}"
else
export APP_VERSION="${SAFE_BRANCH:-main}-${GIT_SHA}"
fi
export VERSION="${APP_VERSION}"
export ARCH_SUFFIX="${{ matrix.script_suffix }}"
export DEVEL="true"
+25 -10
View File
@@ -2,7 +2,6 @@ name: Build Citron (macOS)
concurrency:
group: build-macos-${{ inputs.pr_number || inputs.target_branch || github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
@@ -49,14 +48,14 @@ jobs:
REPO_URL="https://github.com/${HEAD_REPO}.git"
FULL_HASH=$(git ls-remote "$REPO_URL" "refs/heads/$TARGET_BRANCH" | cut -f1 | head -n1)
if [ -z "$FULL_HASH" ]; then
REPO_URL="https://github.com/${{ env.UPSTREAM_REPO }}.git"
TARGET_BRANCH="main"
FULL_HASH=$(git ls-remote "$REPO_URL" HEAD | cut -f1)
echo "::error::Could not resolve branch '${TARGET_BRANCH}' in '${HEAD_REPO}'. Refusing to fall back to main."
exit 1
fi
SHORT_HASH=$(echo "$FULL_HASH" | cut -c1-7)
echo "Resolved ${HEAD_REPO}@${TARGET_BRANCH} to ${FULL_HASH}"
echo "branch_name=$TARGET_BRANCH" >> $GITHUB_OUTPUT
echo "hash_short=$SHORT_HASH" >> $GITHUB_OUTPUT
echo "hash_full=$FULL_HASH" >> $GITHUB_OUTPUT
@@ -79,6 +78,7 @@ jobs:
exit 0
fi
echo "Checking for HASH_SHORT: $HASH_SHORT"
MARKER="<!-- citron-pr-builds:${PR_NUMBER} -->"
COMMENT_BODY=$(gh api "repos/${UPSTREAM}/issues/${PR_NUMBER}/comments?per_page=100" \
--jq "[.[] | select(.body | contains(\"$MARKER\") or contains(\"Build Artifacts for PR #${PR_NUMBER}\"))] | last | .body // empty" \
@@ -93,11 +93,15 @@ jobs:
PLATFORM_ROW=$(echo "$COMMENT_BODY" | grep "\*\*${PLATFORM}\*\*" || true)
echo "Platform row: $PLATFORM_ROW"
if echo "$PLATFORM_ROW" | grep -qF "$HASH_SHORT"; then
if echo "$PLATFORM_ROW" | grep -qE "(\[DMG\]|Failed)"; then
echo "Commit ${HASH_SHORT} already built or failed for ${PLATFORM}. Skipping."
if [ -n "$PLATFORM_ROW" ] && echo "$PLATFORM_ROW" | grep -qF "$HASH_SHORT"; then
if echo "$PLATFORM_ROW" | grep -qE "(\[DMG\]|Success|Failed)"; then
echo "Commit ${HASH_SHORT} already handled for ${PLATFORM}. Skipping."
echo "already_built=true" >> $GITHUB_OUTPUT
exit 0
elif echo "$PLATFORM_ROW" | grep -q "Building..."; then
echo "Commit ${HASH_SHORT} is currently building for ${PLATFORM}. Will build again to be safe."
echo "already_built=false" >> $GITHUB_OUTPUT
exit 0
fi
fi
@@ -189,8 +193,19 @@ jobs:
git config --global http.version HTTP/1.1
git config --global http.userAgent "git/2.39.3 (AppleGit-146)"
CLONE_REPO="${{ needs.check-version.outputs.head_repo }}"
if [[ "$CLONE_REPO" != *"/"* ]]; then CLONE_REPO="${{ env.UPSTREAM_REPO }}"; fi
git clone --recursive -b "${{ needs.check-version.outputs.branch_name }}" "https://github.com/${CLONE_REPO}.git" citron
BRANCH_NAME="${{ needs.check-version.outputs.branch_name }}"
EXPECTED_HASH="${{ needs.check-version.outputs.new_hash_full }}"
if [ -z "$CLONE_REPO" ] || [[ "$CLONE_REPO" != *"/"* ]]; then CLONE_REPO="${{ env.UPSTREAM_REPO }}"; fi
if [ -z "$BRANCH_NAME" ]; then BRANCH_NAME="main"; fi
echo "Cloning from $CLONE_REPO (branch: $BRANCH_NAME)..."
git clone --recursive -b "$BRANCH_NAME" "https://github.com/${CLONE_REPO}.git" citron
cd citron
ACTUAL_HASH=$(git rev-parse HEAD)
echo "Checked out ${CLONE_REPO}@${BRANCH_NAME}: ${ACTUAL_HASH}"
if [ -n "$EXPECTED_HASH" ] && [ "$ACTUAL_HASH" != "$EXPECTED_HASH" ]; then
echo "::error::Checked out ${ACTUAL_HASH}, expected ${EXPECTED_HASH}"
exit 1
fi
- name: Initialize Submodules
working-directory: ./citron
+42 -16
View File
@@ -2,7 +2,6 @@ name: Build Citron (Windows)
concurrency:
group: build-windows-${{ inputs.pr_number || inputs.target_branch || github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
@@ -49,14 +48,14 @@ jobs:
REPO_URL="https://github.com/${HEAD_REPO}.git"
FULL_HASH=$(git ls-remote "$REPO_URL" "refs/heads/$TARGET_BRANCH" | cut -f1 | head -n1)
if [ -z "$FULL_HASH" ]; then
REPO_URL="https://github.com/${{ env.UPSTREAM_REPO }}.git"
TARGET_BRANCH="main"
FULL_HASH=$(git ls-remote "$REPO_URL" HEAD | cut -f1)
echo "::error::Could not resolve branch '${TARGET_BRANCH}' in '${HEAD_REPO}'. Refusing to fall back to main."
exit 1
fi
SHORT_HASH=$(echo "$FULL_HASH" | cut -c1-7)
echo "Resolved ${HEAD_REPO}@${TARGET_BRANCH} to ${FULL_HASH}"
echo "branch_name=$TARGET_BRANCH" >> $GITHUB_OUTPUT
echo "hash_short=$SHORT_HASH" >> $GITHUB_OUTPUT
echo "hash_full=$FULL_HASH" >> $GITHUB_OUTPUT
@@ -79,6 +78,7 @@ jobs:
exit 0
fi
echo "Checking for HASH_SHORT: $HASH_SHORT"
MARKER="<!-- citron-pr-builds:${PR_NUMBER} -->"
COMMENT_BODY=$(gh api "repos/${UPSTREAM}/issues/${PR_NUMBER}/comments?per_page=100" \
--jq "[.[] | select(.body | contains(\"$MARKER\") or contains(\"Build Artifacts for PR #${PR_NUMBER}\"))] | last | .body // empty" \
@@ -93,11 +93,15 @@ jobs:
PLATFORM_ROW=$(echo "$COMMENT_BODY" | grep "\*\*${PLATFORM}\*\*" || true)
echo "Platform row: $PLATFORM_ROW"
if echo "$PLATFORM_ROW" | grep -qF "$HASH_SHORT"; then
if echo "$PLATFORM_ROW" | grep -qE "(\[MSVC\]|\[Clangtron\]|Failed)"; then
echo "Commit ${HASH_SHORT} already built or failed for ${PLATFORM}. Skipping."
if [ -n "$PLATFORM_ROW" ] && echo "$PLATFORM_ROW" | grep -qF "$HASH_SHORT"; then
if echo "$PLATFORM_ROW" | grep -qE "(\[MSVC\]|\[Clangtron\]|Success|Failed)"; then
echo "Commit ${HASH_SHORT} already handled for ${PLATFORM}. Skipping."
echo "already_built=true" >> $GITHUB_OUTPUT
exit 0
elif echo "$PLATFORM_ROW" | grep -q "Building..."; then
echo "Commit ${HASH_SHORT} is currently building for ${PLATFORM}. Will build again to be safe."
echo "already_built=false" >> $GITHUB_OUTPUT
exit 0
fi
fi
@@ -171,8 +175,8 @@ jobs:
build-msvc:
name: "Citron Build (Windows MSVC - x64)"
needs: [check-version]
if: needs.check-version.outputs.should_build == 'true'
needs: [check-version, comment-start]
if: always() && needs.check-version.outputs.should_build == 'true'
runs-on: windows-latest
timeout-minutes: 180
steps:
@@ -189,8 +193,19 @@ jobs:
shell: bash
run: |
CLONE_REPO="${{ needs.check-version.outputs.head_repo }}"
if [[ "$CLONE_REPO" != *"/"* ]]; then CLONE_REPO="${{ env.UPSTREAM_REPO }}"; fi
git clone --recursive -b "${{ needs.check-version.outputs.branch_name }}" "https://github.com/${CLONE_REPO}.git" citron
BRANCH_NAME="${{ needs.check-version.outputs.branch_name }}"
EXPECTED_HASH="${{ needs.check-version.outputs.new_hash_full }}"
if [ -z "$CLONE_REPO" ] || [[ "$CLONE_REPO" != *"/"* ]]; then CLONE_REPO="${{ env.UPSTREAM_REPO }}"; fi
if [ -z "$BRANCH_NAME" ]; then BRANCH_NAME="main"; fi
echo "Cloning from $CLONE_REPO (branch: $BRANCH_NAME)..."
git clone --recursive -b "$BRANCH_NAME" "https://github.com/${CLONE_REPO}.git" citron
cd citron
ACTUAL_HASH=$(git rev-parse HEAD)
echo "Checked out ${CLONE_REPO}@${BRANCH_NAME}: ${ACTUAL_HASH}"
if [ -n "$EXPECTED_HASH" ] && [ "$ACTUAL_HASH" != "$EXPECTED_HASH" ]; then
echo "::error::Checked out ${ACTUAL_HASH}, expected ${EXPECTED_HASH}"
exit 1
fi
- name: Cache vcpkg and Qt dependencies (MSVC)
uses: actions/cache@v4
@@ -238,8 +253,8 @@ jobs:
build-clangtron:
name: "Citron Build (Windows Clangtron - x64)"
needs: [check-version]
if: needs.check-version.outputs.should_build == 'true'
needs: [check-version, comment-start]
if: always() && needs.check-version.outputs.should_build == 'true'
runs-on: ubuntu-latest
timeout-minutes: 240
env:
@@ -249,8 +264,19 @@ jobs:
- name: Clone Citron Source
run: |
CLONE_REPO="${{ needs.check-version.outputs.head_repo }}"
if [[ "$CLONE_REPO" != *"/"* ]]; then CLONE_REPO="${{ env.UPSTREAM_REPO }}"; fi
git clone -b "${{ needs.check-version.outputs.branch_name }}" "https://github.com/${CLONE_REPO}.git" citron
BRANCH_NAME="${{ needs.check-version.outputs.branch_name }}"
EXPECTED_HASH="${{ needs.check-version.outputs.new_hash_full }}"
if [ -z "$CLONE_REPO" ] || [[ "$CLONE_REPO" != *"/"* ]]; then CLONE_REPO="${{ env.UPSTREAM_REPO }}"; fi
if [ -z "$BRANCH_NAME" ]; then BRANCH_NAME="main"; fi
echo "Cloning from $CLONE_REPO (branch: $BRANCH_NAME)..."
git clone -b "$BRANCH_NAME" "https://github.com/${CLONE_REPO}.git" citron
cd citron
ACTUAL_HASH=$(git rev-parse HEAD)
echo "Checked out ${CLONE_REPO}@${BRANCH_NAME}: ${ACTUAL_HASH}"
if [ -n "$EXPECTED_HASH" ] && [ "$ACTUAL_HASH" != "$EXPECTED_HASH" ]; then
echo "::error::Checked out ${ACTUAL_HASH}, expected ${EXPECTED_HASH}"
exit 1
fi
- name: Cache CPM and Toolchain (Clangtron)
uses: actions/cache@v4
+6 -2
View File
@@ -13,8 +13,12 @@ else
fi
# --- Source Code Checkout and Versioning ---
git clone --recurse-submodules --shallow-submodules --depth 1 "https://github.com/citron-neo/emulator.git" ./citron
cd ./citron
if [ -d ".git" ]; then
echo "Already in a git repository, using current directory."
else
git clone --recurse-submodules --shallow-submodules --depth 1 "https://github.com/citron-neo/emulator.git" ./citron
cd ./citron
fi
if [ "$DEVEL" = 'true' ]; then
CITRON_TAG="$(git rev-parse --short HEAD)"