diff --git a/.github/scripts/update_dependency.py b/.github/scripts/update_dependency.py index ec1be302a..460496234 100644 --- a/.github/scripts/update_dependency.py +++ b/.github/scripts/update_dependency.py @@ -11,6 +11,7 @@ # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. +import argparse import fileinput from pathlib import Path @@ -22,6 +23,13 @@ # 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") + +args = parser.parse_args() + package = "amazon-braket-sdk" path = Path.cwd().parent.resolve() @@ -32,3 +40,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'"{package} @ file://{path}/{package}-python",\n' + ) + print(replaced_line, end="") diff --git a/.github/workflows/dependent-tests.yml b/.github/workflows/dependent-tests.yml index aca79d599..8b2c34b17 100644 --- a/.github/workflows/dependent-tests.yml +++ b/.github/workflows/dependent-tests.yml @@ -26,19 +26,20 @@ jobs: uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 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 - pip install --upgrade git+https://github.com/aws/amazon-braket-schemas-python.git@main - pip install --upgrade git+https://github.com/aws/amazon-braket-default-simulator-python.git@main - pip install -e . 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 - pip install -e .[test] + python ${GITHUB_WORKSPACE}/.github/scripts/update_dependency.py --branch ${{ steps.extract_branch.outputs.branch }} + pip install tox - name: Run unit tests run: | cd ../${{ matrix.dependent }} - pytest + tox -e unit-tests