diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81e6c491..2d6f22c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,14 +21,75 @@ jobs: - uses: actions/checkout@v6 with: path: cle + - name: Resolve the angr/binaries ref + id: binaries-ref + shell: bash + env: + GH_TOKEN: ${{ github.token }} + PR_BODY: ${{ github.event.pull_request.body }} + run: | + ref=master + number=$(printf '%s' "$PR_BODY" | + grep -Eo '(angr/binaries#|github\.com/angr/binaries/pull/)[0-9]+' | + head -n 1 | + grep -Eo '[0-9]+$') || true + if [ -n "$number" ]; then + state=$(gh api "repos/angr/binaries/pulls/$number" --jq .state) || state=unavailable + if [ "$state" = open ]; then + ref="refs/pull/$number/head" + else + echo "angr/binaries#$number is $state, so it is not used" + fi + fi + echo "Checking out angr/binaries at $ref" + echo "ref=$ref" >>"$GITHUB_OUTPUT" - uses: actions/checkout@v6 with: repository: angr/binaries path: binaries + ref: ${{ steps.binaries-ref.outputs.ref }} - name: Install the latest version of uv uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1 if: runner.os == 'Windows' + - name: Resolve referenced sibling pull requests + working-directory: cle + shell: bash + env: + GH_TOKEN: ${{ github.token }} + PR_BODY: ${{ github.event.pull_request.body }} + run: | + config=$RUNNER_TEMP/uv-sources.toml + packages= + requirements= + seen= + references=$(printf '%s' "$PR_BODY" | + grep -Eo '[A-Za-z0-9._-]+/[A-Za-z0-9._-]+#[0-9]+|github\.com/[A-Za-z0-9._-]+/[A-Za-z0-9._-]+/pull/[0-9]+' | + sed -E -e 's|^github\.com/||' -e 's|/pull/|#|' -e 's|[/#]| |g') || true + while read -r owner repo number; do + [ -n "$number" ] || continue + case " $seen " in *" $owner/$repo "*) continue ;; esac + seen="$seen $owner/$repo" + package=$(sed -n '/^\[tool\.uv\.sources\]/,/^\[/p' pyproject.toml | + grep -F -e "\"https://github.com/$owner/$repo\"" -e "\"https://github.com/$owner/$repo.git\"" | + sed -E 's/^ *([^ =]+).*/\1/' | + head -n 1) || true + [ -n "$package" ] || continue + state=$(gh api "repos/$owner/$repo/pulls/$number" --jq .state) || state=unavailable + if [ "$state" != open ]; then + echo "$owner/$repo#$number is $state, so it is not used" + continue + fi + echo "Installing $package from $owner/$repo#$number" + packages="$packages\"$package\"," + requirements="$requirements\"$package @ git+https://github.com/$owner/$repo@refs/pull/$number/head\"," + done <<<"$references" + if [ -z "$packages" ]; then + echo "No sibling pull request is referenced, so every sibling stays on master" + exit 0 + fi + printf 'no-sources-package = [%s]\nupgrade-package = [%s]\n' "$packages" "$requirements" | tee "$config" + echo "UV_CONFIG_FILE=$config" >>"$GITHUB_ENV" - name: Sync dependencies with uv run: uv sync --directory cle --python python3.12 --group testing - name: Run tests