Skip to content

Commit d1e8f0b

Browse files
committedMar 4, 2025·
Adjust coq-timing-diff action
1 parent d3c2af5 commit d1e8f0b

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed
 

‎.github/workflows/coq-timing-diff.yml

+15-10
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ on:
1515
type: string
1616
target_branch:
1717
description: 'Target branch to checkout'
18-
required: false
19-
default: ''
18+
required: true
2019
type: string
2120

2221
jobs:
@@ -44,8 +43,6 @@ jobs:
4443
- uses: actions/checkout@v4
4544
with:
4645
submodules: recursive
47-
repository: ${{ github.event.inputs.target_repository || github.repository }}
48-
ref: ${{ github.event.inputs.target_branch || github.ref }}
4946
- name: echo host build params
5047
run: etc/ci/describe-system-config.sh
5148
- name: echo container build params
@@ -63,25 +60,33 @@ jobs:
6360
GH_TOKEN: ${{ github.token }}
6461
run: |
6562
# Get the current branch name
66-
CURRENT_BRANCH=${{ github.event.inputs.target_branch || github.ref }}
63+
CURRENT_BRANCH=${{ github.event.inputs.target_branch }}
6764
echo "Current branch: $CURRENT_BRANCH"
6865
6966
# Check if this is a PR
7067
# Check if this branch has an associated PR
7168
PR_NUMBER=$(gh pr list --repo mit-plv/fiat-crypto --head $CURRENT_BRANCH --json number --jq '.[0].number')
72-
git remote add upstream https://github.com/mit-plv/fiat-crypto.git
69+
# Add remote for target repository if specified
70+
if [[ -n "${{ github.event.inputs.target_repository }}" && "${{ github.event.inputs.target_repository }}" != "${{ github.repository }}" ]]; then
71+
echo "Adding remote for target repository: ${{ github.event.inputs.target_repository }}"
72+
git remote add target_repo "https://github.com/${{ github.event.inputs.target_repository }}.git"
73+
git checkout -b $CURRENT_BRANCH target_repo/$CURRENT_BRANCH
74+
else
75+
git checkout -b $CURRENT_BRANCH origin/$CURRENT_BRANCH
76+
fi
7377
if [[ -n "$PR_NUMBER" ]]; then
7478
# Get the base branch from the PR
7579
BASE_BRANCH=$(gh pr view $PR_NUMBER --json baseRefName --jq '.baseRefName')
7680
echo "This branch has PR #$PR_NUMBER from $CURRENT_BRANCH to $BASE_BRANCH"
7781
# Get the merge-base of the base branch and current commit
78-
git fetch upstream $BASE_BRANCH
79-
BASE_SHA=$(git merge-base upstream/$BASE_BRANCH $GITHUB_SHA)
82+
git fetch origin $BASE_BRANCH
83+
BASE_SHA=$(git merge-base target_repo/$BASE_BRANCH $CURRENT_BRANCH)
84+
8085
else
8186
# For non-PRs, use merge-base of current branch and master as base_sha
8287
echo "This is not a PR, using merge-base with master"
83-
git fetch upstream master
84-
BASE_SHA=$(git merge-base upstream/master $GITHUB_SHA)
88+
git fetch origin master
89+
BASE_SHA=$(git merge-base master $CURRENT_BRANCH)
8590
fi
8691
8792
echo "Using base SHA: $BASE_SHA"

0 commit comments

Comments
 (0)
Please sign in to comment.