Skip to content

Commit c3c5bdf

Browse files
authored
fix the reusable precommit (#2687)
so it runs on the correct commit sha
1 parent aa275e4 commit c3c5bdf

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

.github/workflows/reusable-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs:
6060
with:
6161
target-branch: ${{ inputs.target-branch }}
6262
cache-version: ${{ inputs.cache-version }}
63+
has-integration-label: ${{ contains(github.event.pull_request.labels.*.name, 'ci/integrations') }}
6364
secrets:
6465
PIPELINE_GITHUB_APP_ID: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
6566
PIPELINE_GITHUB_APP_PRIVATE_KEY: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}

.github/workflows/reusable-integration-test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ on:
4343
required: false
4444
type: string
4545
default: ''
46+
has-integration-label:
47+
description: 'Whether the calling PR has ci/integrations label'
48+
required: false
49+
type: boolean
50+
default: false
4651
secrets:
4752
PIPELINE_GITHUB_APP_ID:
4853
required: false
@@ -70,7 +75,8 @@ jobs:
7075
!contains(github.event.pull_request.labels.*.name, 'ci/skip') &&
7176
!contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/') &&
7277
contains(github.event.pull_request.labels.*.name, 'ci/integrations')) ||
73-
github.event_name == 'schedule'
78+
github.event_name == 'schedule' ||
79+
(github.event_name == 'workflow_call' && inputs.has-integration-label)
7480
services:
7581
datadog-agent:
7682
image: gcr.io/datadoghq/agent:latest

.github/workflows/reusable-pre-commit.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,21 @@ jobs:
5656
with:
5757
path: ~/.cache/pre-commit
5858
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
59+
- name: Determine pre-commit range
60+
id: commit_range
61+
run: |
62+
FROM_REF=$(git merge-base HEAD origin/master)
63+
echo "from_ref=$FROM_REF" >> $GITHUB_OUTPUT
64+
echo "to_ref=HEAD" >> $GITHUB_OUTPUT
65+
echo "Pre-commit will check from $FROM_REF to HEAD"
5966
- id: pre_commit
6067
name: Run pre-commit
6168
if: github.event.action != 'closed' && github.event.pull_request.merged != true
6269
run: |
6370
pre-commit run --from-ref "${FROM_REF}" --to-ref "${TO_REF}" --show-diff-on-failure --color=always
6471
env:
65-
FROM_REF: ${{ github.event.pull_request.base.sha }}
66-
TO_REF: ${{ github.event.pull_request.head.sha }}
72+
FROM_REF: ${{ steps.commit_range.outputs.from_ref }}
73+
TO_REF: ${{ steps.commit_range.outputs.to_ref }}
6774
- name: Commit changes
6875
if: ${{ failure() && inputs.enable-commit-changes }}
6976
run: |-

0 commit comments

Comments
 (0)