From d41f15a4b7623e4fc5959d556d48169d751cbf0d Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Wed, 27 Nov 2024 16:25:38 +0100 Subject: [PATCH] ci: add opam-rt branch lookup for the form of username/branchname --- .github/scripts/main/main.sh | 3 +++ .github/workflows/ci.ml | 4 +++- .github/workflows/main.yml | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/scripts/main/main.sh b/.github/scripts/main/main.sh index 6f5385670f5..9dcf821463e 100644 --- a/.github/scripts/main/main.sh +++ b/.github/scripts/main/main.sh @@ -127,6 +127,9 @@ if [ "$OPAM_TEST" = "1" ]; then fi cd $CACHE/opam-rt git fetch origin + if [ "$GITHUB_EVENT_NAME" = "pull_request" ] && git ls-remote --exit-code origin $GITHUB_PR_USER/$BRANCH ; then + BRANCH=$GITHUB_PR_USER/$BRANCH + fi if git ls-remote --exit-code origin $BRANCH ; then if git branch | grep -q $BRANCH; then git checkout $BRANCH diff --git a/.github/workflows/ci.ml b/.github/workflows/ci.ml index 9ff06d19121..1cb38d150da 100644 --- a/.github/workflows/ci.ml +++ b/.github/workflows/ci.ml @@ -378,7 +378,9 @@ let main_test_job ~analyse_job ~build_linux_job ~build_windows_job:_ ~build_macO let matrix = platform_ocaml_matrix ~fail_fast:false start_latests_ocaml in let host = host_of_platform platform in let ocamlv = "${{ matrix.ocamlv }}" in - job ~oc ~workflow ?section ~runs_on:(Runner [runner]) ~env:[("OPAM_TEST", "1")] ~matrix ~needs ("Test-" ^ name_of_platform platform) + job ~oc ~workflow ?section ~runs_on:(Runner [runner]) + ~env:[("OPAM_TEST", "1"); ("GITHUB_PR_USER", "{{ github.event.pull_request.user.login }}")] + ~matrix ~needs ("Test-" ^ name_of_platform platform) ++ only_on MacOS (install_sys_packages ["coreutils"; "gpatch"] ~descr:"Install gnu coreutils" [MacOS]) ++ checkout () ++ only_on Linux (run "Install bubblewrap" ["sudo apt install bubblewrap"]) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5ee3dc78f71..e404f3be635 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -282,6 +282,7 @@ jobs: fail-fast: false env: OPAM_TEST: 1 + GITHUB_PR_USER: {{ github.event.pull_request.user.login }} steps: - name: Checkout tree uses: actions/checkout@v4 @@ -336,6 +337,7 @@ jobs: fail-fast: false env: OPAM_TEST: 1 + GITHUB_PR_USER: {{ github.event.pull_request.user.login }} steps: - name: Install gnu coreutils run: brew install coreutils gpatch