From 017eea7b5ac6813ba713a379e5a54fb7c58764d3 Mon Sep 17 00:00:00 2001 From: Billy Moses Date: Mon, 16 Mar 2026 10:59:55 -0500 Subject: [PATCH] Fix out of date version --- builder/check-upstream.sh | 54 ++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/builder/check-upstream.sh b/builder/check-upstream.sh index 1368a95..7964240 100755 --- a/builder/check-upstream.sh +++ b/builder/check-upstream.sh @@ -1,8 +1,14 @@ #!/bin/bash -git -C /app/Enzyme fetch -git -C /app/Enzyme-JaX fetch -git -C /app/Reactant fetch + git -C /app/Enzyme fetch origin "+refs/heads/*:refs/remotes/origin/*" + git -C /app/Enzyme-JaX fetch origin "+refs/heads/*:refs/remotes/origin/*" + git -C /app/Reactant fetch origin "+refs/heads/*:refs/remotes/origin/*" + + get_upstream_hash() { + project=$1 + workflow=$2 + python3 -c "import sys, json, urllib.request; req = urllib.request.Request('https://api.github.com/repos/EnzymeAD/'+sys.argv[1]+'/actions/workflows/'+sys.argv[2]+'/runs?status=success&branch=main&per_page=1', headers={'User-Agent': 'Mozilla/5.0'}); res = urllib.request.urlopen(req); data = json.loads(res.read()); print(data['workflow_runs'][0]['head_sha']) if data.get('workflow_runs') else print('')" "$project" "$workflow" + } declare -a branches=("main") @@ -12,45 +18,45 @@ for branch in ${branches[@]}; do ejaxcommit="None" reactantcommit="None" - HEADHASH=$(git -C /app/Enzyme rev-parse $branch) - UPSTREAMHASH=$(git -C /app/Enzyme rev-parse $branch@{upstream}) - commit=$(git -C /app/Enzyme rev-parse --short=7 HEAD) - if [ "$HEADHASH" != "$UPSTREAMHASH" ] + HEADHASH=$(git -C /app/Enzyme rev-parse HEAD) + UPSTREAMHASH=$(get_upstream_hash Enzyme enzyme-ci.yml) + if [ "$HEADHASH" != "$UPSTREAMHASH" ] && [ ! -z "$UPSTREAMHASH" ] then echo -e ${FINISHED}Updating Enzyme, old was $HEADHASH new was $UPSTREAMHASH ${NOCOLOR} git -C /app/Enzyme checkout $branch - git -C /app/Enzyme fetch - git -C /app/Enzyme reset --hard origin/$branch + git -C /app/Enzyme reset --hard $UPSTREAMHASH + commit=$(git -C /app/Enzyme rev-parse --short=7 HEAD) else - echo -e ${FINISHED}Current branch is up to date with origin/$branch.${NOCOLOR} + commit=$(git -C /app/Enzyme rev-parse --short=7 HEAD) + echo -e ${FINISHED}Current branch is up to date with origin/nightly.${NOCOLOR} fi - JHEADHASH=$(git -C /app/Enzyme-JaX rev-parse $branch) - JUPSTREAMHASH=$(git -C /app/Enzyme-JaX rev-parse $branch@{upstream}) - ejaxcommit=$(git -C /app/Enzyme-JaX rev-parse --short=7 HEAD) + JHEADHASH=$(git -C /app/Enzyme-JaX rev-parse HEAD) + JUPSTREAMHASH=$(get_upstream_hash Enzyme-JaX build.yml) - if [ "$JHEADHASH" != "$JUPSTREAMHASH" ] + if [ "$JHEADHASH" != "$JUPSTREAMHASH" ] && [ ! -z "$JUPSTREAMHASH" ] then echo -e ${FINISHED}Updating Enzyme-JaX, old was $JHEADHASH new was $JUPSTREAMHASH ${NOCOLOR} git -C /app/Enzyme-JaX checkout $branch - git -C /app/Enzyme-JaX fetch - git -C /app/Enzyme-JaX reset --hard origin/$branch + git -C /app/Enzyme-JaX reset --hard $JUPSTREAMHASH + ejaxcommit=$(git -C /app/Enzyme-JaX rev-parse --short=7 HEAD) else - echo -e ${FINISHED}Current branch is up to date with origin/$branch.${NOCOLOR} + ejaxcommit=$(git -C /app/Enzyme-JaX rev-parse --short=7 HEAD) + echo -e ${FINISHED}Current branch is up to date with origin/nightly.${NOCOLOR} fi - RHEADHASH=$(git -C /app/Reactant rev-parse $branch) - RUPSTREAMHASH=$(git -C /app/Reactant rev-parse $branch@{upstream}) - reactantcommit=$(git -C /app/Reactant rev-parse --short=7 HEAD) + RHEADHASH=$(git -C /app/Reactant rev-parse HEAD) + RUPSTREAMHASH=$(get_upstream_hash Reactant reactant-bazel-custom.yml) - if [ "$RHEADHASH" != "$RUPSTREAMHASH" ] + if [ "$RHEADHASH" != "$RUPSTREAMHASH" ] && [ ! -z "$RUPSTREAMHASH" ] then echo -e ${FINISHED}Updating Reactant, old was $RHEADHASH new was $RUPSTREAMHASH ${NOCOLOR} git -C /app/Reactant checkout $branch - git -C /app/Reactant fetch - git -C /app/Reactant reset --hard origin/$branch + git -C /app/Reactant reset --hard $RUPSTREAMHASH + reactantcommit=$(git -C /app/Reactant rev-parse --short=7 HEAD) else - echo -e ${FINISHED}Current branch is up to date with origin/$branch.${NOCOLOR} + reactantcommit=$(git -C /app/Reactant rev-parse --short=7 HEAD) + echo -e ${FINISHED}Current branch is up to date with origin/nightly.${NOCOLOR} fi if [ "$JHEADHASH" != "$JUPSTREAMHASH" ] || [ "$RHEADHASH" != "$RUPSTREAMHASH" ] || [ "$HEADHASH" != "$UPSTREAMHASH" ]