From 621668a957d2a234d9115af300fb58595f7bd1e9 Mon Sep 17 00:00:00 2001 From: Yashodhan <54112038+YJDoc2@users.noreply.github.com> Date: Wed, 20 Mar 2024 20:23:31 +0530 Subject: [PATCH] Update CI to run on fork-based PRs and use proper repo when checking out (#1978) * Update CI to run on PR and use proper ref Signed-off-by: Yashodhan Joshi * Fetch GITHUB_REF and then checkout GITHUB_SHA Signed-off-by: Yashodhan Joshi --------- Signed-off-by: Yashodhan Joshi --- .github/workflows/docs.yml | 2 +- .github/workflows/format.yml | 9 ++++++--- .github/workflows/fud2.yml | 1 - .github/workflows/rust.yml | 16 +++++++++++----- .github/workflows/verification.yml | 2 +- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 0eaac9b68a..1fcd4e4769 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,7 +13,7 @@ jobs: name: Docs website runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup mdBook uses: peaceiris/actions-mdbook@v1 with: diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 033082d630..03fcc666fb 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -1,6 +1,9 @@ name: Format -on: [push] +on: + push: # allow for all branches, so forks can also validate on their own + pull_request: + branches: [main] jobs: format: @@ -8,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install stable uses: actions-rs/toolchain@v1 with: @@ -37,7 +40,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Fud Formatting check uses: psf/black@stable with: diff --git a/.github/workflows/fud2.yml b/.github/workflows/fud2.yml index 8101c772ec..d5319d8ba0 100644 --- a/.github/workflows/fud2.yml +++ b/.github/workflows/fud2.yml @@ -2,7 +2,6 @@ name: fud2 tests on: push: - branches: [main] pull_request: branches: [main] diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 5eac5bb9dc..862ebd3f3c 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,6 +1,9 @@ name: Test -on: [push] +on: + push: + pull_request: + branches: [main] # Ensures that only the latest commit of a PR can execute the actions. # Useful for cancelling job when a sequence of commits are quickly added. @@ -18,7 +21,7 @@ jobs: exists: ${{ steps.exists.outputs.exists }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: calyxir/calyx ref: ${{ github.sha }} @@ -83,8 +86,9 @@ jobs: working-directory: /home/calyx run: | git init - git remote add origin https://github.com/calyxir/calyx.git + git remote add origin https://github.com/${{ github.repository }}.git git fetch --all + git fetch origin $GITHUB_REF git checkout -f $GITHUB_SHA git clean -fd @@ -134,8 +138,9 @@ jobs: working-directory: /home/calyx run: | git init - git remote add origin https://github.com/calyxir/calyx.git + git remote add origin https://github.com/${{ github.repository }}.git git fetch --all + git fetch origin $GITHUB_REF git checkout -f $GITHUB_SHA git clean -fd @@ -193,8 +198,9 @@ jobs: working-directory: /home/calyx run: | git init - git remote add origin https://github.com/calyxir/calyx.git + git remote add origin https://github.com/${{ github.repository }}.git git fetch --all + git fetch origin $GITHUB_REF git checkout -f $GITHUB_SHA git clean -fd diff --git a/.github/workflows/verification.yml b/.github/workflows/verification.yml index afecb1a422..e38723c1d3 100644 --- a/.github/workflows/verification.yml +++ b/.github/workflows/verification.yml @@ -19,7 +19,7 @@ jobs: container: ghcr.io/cucapra/calyx:latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Get bwrap for opam run: | apt-get update -y