Skip to content

Commit

Permalink
ensure branch is set to the PR branch
Browse files Browse the repository at this point in the history
  • Loading branch information
AbeCoull committed Nov 16, 2023
1 parent 15e42b2 commit 4aa606c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .github/scripts/update_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# language governing permissions and limitations under the License.

import fileinput
import argparse
from pathlib import Path

# Here we replace the `amazon-braket-sdk` dependency to point to the file system; otherwise
Expand All @@ -22,6 +23,11 @@
# dependency, we can do this for the ones we own to make sure that when the sdk updates
# its dependencies, these upstream github repos will not be impacted.

parser = argparse.ArgumentParser()

# --branch={branch_name}
parser.add_argument("-b", "--branch", help="PR branch name")

package = "amazon-braket-sdk"
path = Path.cwd().parent.resolve()

Expand All @@ -32,3 +38,10 @@
line if package not in line else f'"{package} @ file://{path}/{package}-python",\n'
)
print(replaced_line, end="")

for line in fileinput.input("tox.ini", inplace=True):
# Ensure that tox uses the working branch for the SDK PR.
replaced_line = (
line if package not in line else f' git+https://github.com/amazon-braket/{package}-python.git@{args.branch}\n'
)
print(replaced_line, end="")
6 changes: 5 additions & 1 deletion .github/workflows/dependent-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ jobs:
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
with:
python-version: ${{ matrix.python-version }}
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Install dependencies
run: |
pip install --upgrade pip
cd ..
git clone https://github.com/aws/${{ matrix.dependent }}.git
cd ${{ matrix.dependent }}
# Update the amazon-braket-sdk dependency to reference the current commit
python ${GITHUB_WORKSPACE}/.github/scripts/update_dependency.py
python ${GITHUB_WORKSPACE}/.github/scripts/update_dependency.py --branch ${{ steps.extract_branch.outputs.branch }}
pip install tox
- name: Run unit tests
run: |
Expand Down

0 comments on commit 4aa606c

Please sign in to comment.