Skip to content

Commit a5a9afa

Browse files
authored
Enable code generation in repo (#788)
1 parent 5f10c4d commit a5a9afa

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed

.github/workflows/test.yml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,23 @@ concurrency:
1212
jobs:
1313
pre-commit:
1414
runs-on: ubuntu-latest
15-
if: false == startsWith(github.event.pull_request.head.ref, 'datadog-api-spec/generated/') && !contains(github.event.pull_request.labels.*.name, 'ci/skip/pre-commit')
15+
if: >
16+
github.event.pull_request.draft == false &&
17+
!contains(github.event.pull_request.labels.*.name, 'ci/skip') &&
18+
!contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/') &&
19+
!contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')
1620
steps:
17-
- uses: actions/checkout@v1
18-
- uses: actions/setup-python@v1
21+
- name: Get GitHub App token
22+
id: get_token
23+
uses: tibdex/[email protected]
24+
with:
25+
app_id: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
26+
private_key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
27+
- uses: actions/checkout@v2
28+
with:
29+
fetch-depth: 0
30+
ref: ${{ github.event.pull_request.head.sha }}
31+
token: ${{ steps.get_token.outputs.token }}
1932
- name: Install pre-commit
2033
run: python -m pip install pre-commit
2134
- name: set PY
@@ -24,8 +37,20 @@ jobs:
2437
with:
2538
path: ~/.cache/pre-commit
2639
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
27-
- name: Run pre-commit
28-
run: pre-commit run --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }} --show-diff-on-failure --color=always
40+
- id: pre_commit
41+
name: Run pre-commit
42+
if: github.event.action != 'closed' && github.event.pull_request.merged != true
43+
run: |
44+
pre-commit run --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }} --show-diff-on-failure --color=always
45+
- name: Commit changes
46+
if: ${{ failure() }}
47+
run: |-
48+
git add -A
49+
git config user.name "${GIT_AUTHOR_NAME}"
50+
git config user.email "${GIT_AUTHOR_EMAIL}"
51+
git commit -m "pre-commit fixes"
52+
git push origin HEAD:${{ github.event.pull_request.head.ref }}
53+
exit 1
2954
3055
test:
3156
strategy:

.pre-commit-config.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
repos:
22
- repo: local
33
hooks:
4-
- id: generated
5-
name: Do not commit generated files
6-
language: fail
7-
entry: Unstage generated files with 'git reset --' command
8-
files: '^datadog_api_client/v.*'
9-
verbose: true
104
- id: generate
115
name: Generate
126
language: node
137
entry: make
14-
files: "^.generator/.*"
8+
files: '^(\.generator/.*|\.pre-commit-config\.yaml|setup\.cfg|Makefile)'
159
pass_filenames: false
1610
- id: docs
1711
name: Format documentation

0 commit comments

Comments
 (0)