Skip to content

Commit

Permalink
refactor(IDX): handle case when no target branch is present (#1698)
Browse files Browse the repository at this point in the history
This updates the logic in `diff.sh` to use `HEAD` when no target branch
is present. It also removes the `CI_PULL_REQUEST_TARGET_BRANCH_NAME` env
var from the workflows as it is not needed anymore.

---------

Co-authored-by: IDX GitHub Automation <IDX GitHub Automation>
  • Loading branch information
cgundy authored Sep 26, 2024
1 parent 91d8f93 commit a95f743
Show file tree
Hide file tree
Showing 13 changed files with 5 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/actions/bazel-test-all/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,7 @@ runs:
BAZEL_CI_CONFIG: ${{ inputs.BAZEL_CI_CONFIG }}
BAZEL_EXTRA_ARGS: "${{ inputs.BAZEL_EXTRA_ARGS }} ${{ inputs.BAZEL_EXTRA_ARGS_RULES }}"
BAZEL_STARTUP_ARGS: ${{ inputs.BAZEL_STARTUP_ARGS }}
CI_PULL_REQUEST_TARGET_BRANCH_NAME: ${{ github.event.pull_request.base.ref }}
MERGE_BASE_SHA: ${{ github.event.pull_request.base.sha }}
HONEYCOMB_API_TOKEN: ${{ inputs.HONEYCOMB_API_TOKEN }}
SSH_PRIVATE_KEY: ${{ inputs.SSH_PRIVATE_KEY }}
2 changes: 1 addition & 1 deletion .github/workflows-source/ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ env:
CI_JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
CI_PIPELINE_SOURCE: ${{ github.event_name }}
CI_PROJECT_DIR: ${{ github.workspace }}
CI_PULL_REQUEST_TARGET_BRANCH_NAME: ${{ github.event.pull_request.base.ref }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
ROOT_PIPELINE_ID: ${{ github.run_id }}
RUSTFLAGS: "--remap-path-prefix=${CI_PROJECT_DIR}=/ic"
Expand Down Expand Up @@ -260,6 +259,7 @@ jobs:
env:
BAZEL_COMMAND: "build"
RUN_ON_DIFF_ONLY: ${{ !contains(github.event.pull_request.labels.*.name, 'CI_ALL_BAZEL_TARGETS') }}
MERGE_BASE_SHA: ${{ github.event.pull_request.base.sha }}
- name: Upload build-ic.tar
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows-source/ci-pr-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ concurrency:
env:
CI_PIPELINE_SOURCE: ${{ github.event_name }}
CI_PROJECT_DIR: ${{ github.workspace }}
CI_PULL_REQUEST_TARGET_BRANCH_NAME: ${{ github.event.pull_request.base.ref }}
MERGE_BRANCH: ${{ github.event.pull_request.base.ref }}
ORG: ${{ github.repository_owner }}

Expand Down
1 change: 0 additions & 1 deletion .github/workflows-source/release-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ env:
CI_JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
CI_PIPELINE_SOURCE: ${{ github.event_name }}
CI_PROJECT_DIR: ${{ github.workspace }}
CI_PULL_REQUEST_TARGET_BRANCH_NAME: ${{ github.event.pull_request.base.ref }}
BRANCH_NAME: ${{ github.event.workflow_run.head_branch || github.ref_name }}
ROOT_PIPELINE_ID: ${{ github.run_id }}
RUSTFLAGS: "--remap-path-prefix=${CI_PROJECT_DIR}=/ic"
Expand Down
1 change: 0 additions & 1 deletion .github/workflows-source/schedule-daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ env:
CI_JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
CI_PIPELINE_SOURCE: ${{ github.event_name }}
CI_PROJECT_DIR: ${{ github.workspace }}
CI_PULL_REQUEST_TARGET_BRANCH_NAME: ${{ github.ref_name }} # this workflow will always run on the default branch
ROOT_PIPELINE_ID: ${{ github.run_id }}
BUILDEVENT_DATASET: "github-ci-dfinity"

Expand Down
1 change: 0 additions & 1 deletion .github/workflows-source/schedule-hourly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ env:
CI_JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
CI_PIPELINE_SOURCE: ${{ github.event_name }}
CI_PROJECT_DIR: ${{ github.workspace }}
CI_PULL_REQUEST_TARGET_BRANCH_NAME: ${{ github.event.pull_request.base.ref }}
ROOT_PIPELINE_ID: ${{ github.run_id }}
RUSTFLAGS: "--remap-path-prefix=${CI_PROJECT_DIR}=/ic"
BUILDEVENT_DATASET: "github-ci-dfinity"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ env:
CI_JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
CI_PIPELINE_SOURCE: ${{ github.event_name }}
CI_PROJECT_DIR: ${{ github.workspace }}
CI_PULL_REQUEST_TARGET_BRANCH_NAME: ${{ github.event.pull_request.base.ref }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
ROOT_PIPELINE_ID: ${{ github.run_id }}
RUSTFLAGS: "--remap-path-prefix=${CI_PROJECT_DIR}=/ic"
Expand Down Expand Up @@ -346,6 +345,7 @@ jobs:
env:
BAZEL_COMMAND: "build"
RUN_ON_DIFF_ONLY: ${{ !contains(github.event.pull_request.labels.*.name, 'CI_ALL_BAZEL_TARGETS') }}
MERGE_BASE_SHA: ${{ github.event.pull_request.base.sha }}
- name: Upload build-ic.tar
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-pr-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ concurrency:
env:
CI_PIPELINE_SOURCE: ${{ github.event_name }}
CI_PROJECT_DIR: ${{ github.workspace }}
CI_PULL_REQUEST_TARGET_BRANCH_NAME: ${{ github.event.pull_request.base.ref }}
MERGE_BRANCH: ${{ github.event.pull_request.base.ref }}
ORG: ${{ github.repository_owner }}
jobs:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ env:
CI_JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
CI_PIPELINE_SOURCE: ${{ github.event_name }}
CI_PROJECT_DIR: ${{ github.workspace }}
CI_PULL_REQUEST_TARGET_BRANCH_NAME: ${{ github.event.pull_request.base.ref }}
BRANCH_NAME: ${{ github.event.workflow_run.head_branch || github.ref_name }}
ROOT_PIPELINE_ID: ${{ github.run_id }}
RUSTFLAGS: "--remap-path-prefix=${CI_PROJECT_DIR}=/ic"
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/schedule-daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ env:
CI_JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
CI_PIPELINE_SOURCE: ${{ github.event_name }}
CI_PROJECT_DIR: ${{ github.workspace }}
CI_PULL_REQUEST_TARGET_BRANCH_NAME: ${{ github.ref_name }} # this workflow will always run on the default branch
ROOT_PIPELINE_ID: ${{ github.run_id }}
BUILDEVENT_DATASET: "github-ci-dfinity"
jobs:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/schedule-hourly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ env:
CI_JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
CI_PIPELINE_SOURCE: ${{ github.event_name }}
CI_PROJECT_DIR: ${{ github.workspace }}
CI_PULL_REQUEST_TARGET_BRANCH_NAME: ${{ github.event.pull_request.base.ref }}
ROOT_PIPELINE_ID: ${{ github.run_id }}
RUSTFLAGS: "--remap-path-prefix=${CI_PROJECT_DIR}=/ic"
BUILDEVENT_DATASET: "github-ci-dfinity"
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/schedule-rust-bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ env:
CI_JOB_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
CI_PIPELINE_SOURCE: ${{ github.event_name }}
CI_PROJECT_DIR: ${{ github.workspace }}
CI_PULL_REQUEST_TARGET_BRANCH_NAME: ${{ github.ref_name }} # this workflow will always run on the default branch
ROOT_PIPELINE_ID: ${{ github.run_id }}
BUILDEVENT_DATASET: "github-ci-dfinity"

Expand Down
3 changes: 1 addition & 2 deletions ci/bazel-scripts/diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ set -euo pipefail
set -x
cd "$(git rev-parse --show-toplevel)"

git fetch origin "$CI_PULL_REQUEST_TARGET_BRANCH_NAME" --quiet
MERGE_BASE="$(git merge-base HEAD origin/$CI_PULL_REQUEST_TARGET_BRANCH_NAME)"
MERGE_BASE="${MERGE_BASE_SHA:-HEAD}"
COMMIT_RANGE=${COMMIT_RANGE:-$MERGE_BASE".."}
DIFF_FILES=$(git diff --name-only "${COMMIT_RANGE}")

Expand Down

0 comments on commit a95f743

Please sign in to comment.