Skip to content

Commit 380427f

Browse files
authored
fix the reusable precommit so it runs on the correct commit sha (#936)
1 parent 8f4d080 commit 380427f

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
@@ -75,6 +75,7 @@ jobs:
7575
uses: ./.github/workflows/reusable-integration-test.yml
7676
with:
7777
target-branch: ${{ inputs.target-branch }}
78+
has-integration-label: ${{ contains(github.event.pull_request.labels.*.name, 'ci/integrations') }}
7879
secrets:
7980
PIPELINE_GITHUB_APP_ID: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
8081
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
@@ -38,6 +38,11 @@ on:
3838
required: false
3939
type: string
4040
default: 'datadog-api-spec'
41+
has-integration-label:
42+
description: 'Whether the calling PR has ci/integrations label'
43+
required: false
44+
type: boolean
45+
default: false
4146
secrets:
4247
PIPELINE_GITHUB_APP_ID:
4348
required: false
@@ -63,7 +68,8 @@ jobs:
6368
!contains(github.event.pull_request.labels.*.name, 'ci/skip') &&
6469
!contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/') &&
6570
contains(github.event.pull_request.labels.*.name, 'ci/integrations')) ||
66-
github.event_name == 'schedule'
71+
github.event_name == 'schedule' ||
72+
(github.event_name == 'workflow_call' && inputs.has-integration-label)
6773
services:
6874
datadog-agent:
6975
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
@@ -55,14 +55,21 @@ jobs:
5555
with:
5656
path: ~/.cache/pre-commit
5757
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
58+
- name: Determine pre-commit range
59+
id: commit_range
60+
run: |
61+
FROM_REF=$(git merge-base HEAD origin/master)
62+
echo "from_ref=$FROM_REF" >> $GITHUB_OUTPUT
63+
echo "to_ref=HEAD" >> $GITHUB_OUTPUT
64+
echo "Pre-commit will check from $FROM_REF to HEAD"
5865
- id: pre_commit
5966
name: Run pre-commit
6067
if: github.event.action != 'closed' && github.event.pull_request.merged != true
6168
run: |
6269
pre-commit run --from-ref "${FROM_REF}" --to-ref "${TO_REF}" --show-diff-on-failure --color=always
6370
env:
64-
FROM_REF: ${{ github.event.pull_request.base.sha }}
65-
TO_REF: ${{ github.event.pull_request.head.sha }}
71+
FROM_REF: ${{ steps.commit_range.outputs.from_ref }}
72+
TO_REF: ${{ steps.commit_range.outputs.to_ref }}
6673
- name: Commit changes
6774
if: failure() && inputs.enable-commit-changes && github.event.pull_request.head.repo.full_name == github.repository
6875
run: |-

0 commit comments

Comments
 (0)