Skip to content

Commit 2991193

Browse files
authored
fix the reusable precommit (#3374)
so it runs on the correct commit sha
1 parent 83925bd commit 2991193

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
@@ -48,6 +48,7 @@ jobs:
4848
uses: ./.github/workflows/reusable-integration-test.yml
4949
with:
5050
target-branch: ${{ inputs.target-branch }}
51+
has-integration-label: ${{ contains(github.event.pull_request.labels.*.name, 'ci/integrations') }}
5152
secrets:
5253
PIPELINE_GITHUB_APP_ID: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
5354
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
@@ -65,7 +70,8 @@ jobs:
6570
!contains(github.event.pull_request.labels.*.name, 'ci/skip') &&
6671
!contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/') &&
6772
contains(github.event.pull_request.labels.*.name, 'ci/integrations')) ||
68-
github.event_name == 'schedule'
73+
github.event_name == 'schedule' ||
74+
(github.event_name == 'workflow_call' && inputs.has-integration-label)
6975
services:
7076
datadog-agent:
7177
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
@@ -60,14 +60,21 @@ jobs:
6060
uses: actions/setup-go@v4
6161
with:
6262
go-version: 1.22.x
63+
- name: Determine pre-commit range
64+
id: commit_range
65+
run: |
66+
FROM_REF=$(git merge-base HEAD origin/master)
67+
echo "from_ref=$FROM_REF" >> $GITHUB_OUTPUT
68+
echo "to_ref=HEAD" >> $GITHUB_OUTPUT
69+
echo "Pre-commit will check from $FROM_REF to HEAD"
6370
- id: pre_commit
6471
name: Run pre-commit
6572
if: github.event.action != 'closed' && github.event.pull_request.merged != true
6673
run: |
6774
pre-commit run --from-ref "${FROM_REF}" --to-ref "${TO_REF}" --show-diff-on-failure --color=always
6875
env:
69-
FROM_REF: ${{ github.event.pull_request.base.sha }}
70-
TO_REF: ${{ github.event.pull_request.head.sha }}
76+
FROM_REF: ${{ steps.commit_range.outputs.from_ref }}
77+
TO_REF: ${{ steps.commit_range.outputs.to_ref }}
7178
- name: Commit changes
7279
if: ${{ failure() && inputs.enable-commit-changes }}
7380
run: |-

0 commit comments

Comments
 (0)