-
Notifications
You must be signed in to change notification settings - Fork 1
115 lines (115 loc) · 5.46 KB
/
_reusable-update-python-and-pre-commit-dependencies.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
---
name: Update python linting dependencies in-sync with pre-commit
on:
workflow_call:
inputs:
commit-user-name:
description: The name of the user to use when committing changes to the repository.
required: true
type: string
commit-user-email:
description: The email of the user to use when committing changes to the repository.
required: true
type: string
dependency-dict:
description: 'Specify a valid JSON dictionary of dependency groups to update,
where each key is a dependency group name, and each value is a list of dependencies
to update within that group, e.g. {"dev": ["pylint", "ruff"], "tests": ["ruff"]}.
Use an empty string, e.g. "", for dependencies located in the default group'
required: false
type: string
default: '{}'
update-pre-commit:
description: A boolean indicating if the pre-commit hooks should be updated.
required: false
type: boolean
default: false
run-pre-commit:
description: A boolean indicating to run the pre-commit hooks to perform auto-fixing
after updating the dependencies. Setting this input to `true` will also
set the update-pre-commit input to `true`.
required: false
type: boolean
default: false
pre-commit-repo-update-skip-list:
description: A comma-separated list of pre-commit repo urls to skip updates
for (only applicable when `update-pre-commit=true`).
required: false
type: string
default: ''
pre-commit-hook-skip-list:
description: A comma-separated list of pre-commit hooks to skip (only applicable
when `run-pre-commit=true`).
required: false
type: string
default: ''
export-dependency-groups:
description: A comma-separated list of dependency groups that should have
their requirements exported. An output folder can be specified by appending
a ":" followed by the custom output folder path to the provided group name,
e.g. "tests:custom/folder/path". The created file will always be named "requirements.txt",
and the folder will default to matching the group name if no custom folder
path is given.
required: false
type: string
default: ''
secrets:
checkout-token:
description: The token to use for checking out the repository, must have permissions
to write back to the repository.
required: true
gpg-signing-key-private:
description: The private GPG key to use for signing the commit.
required: true
gpg-signing-key-passphrase:
description: The passphrase for the private GPG key.
required: true
jobs:
update-python-and-pre-commit-deps:
name: Update python linters and pre-commit dependencies
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
token: ${{ secrets.checkout-token }}
- uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0
with:
gpg_private_key: ${{ secrets.gpg-signing-key-private }}
passphrase: ${{ secrets.gpg-signing-key-passphrase }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Set up pre-commit cache
if: ${{ inputs.update-pre-commit || inputs.run-pre-commit }}
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml')
}}
- if: ${{ endsWith(github.repository, '/python-package-ci-cd') }} # Run the local action when this is run in the python-package-ci-cd repository
uses: ./actions/update_development_dependencies
with:
dependency-dict: ${{ inputs.dependency-dict }}
update-pre-commit: ${{ inputs.update-pre-commit }}
run-pre-commit: ${{ inputs.run-pre-commit }}
pre-commit-repo-update-skip-list: ${{ inputs.pre-commit-repo-update-skip-list }}
pre-commit-hook-skip-list: ${{ inputs.pre-commit-hook-skip-list }}
export-dependency-groups: ${{ inputs.export-dependency-groups }}
- if: ${{ !endsWith(github.repository, '/python-package-ci-cd') }} # Run the public action when this is run outside the python-package-ci-cd repository
uses: tektronix/python-package-ci-cd/actions/[email protected]
with:
dependency-dict: ${{ inputs.dependency-dict }}
update-pre-commit: ${{ inputs.update-pre-commit }}
run-pre-commit: ${{ inputs.run-pre-commit }}
pre-commit-repo-update-skip-list: ${{ inputs.pre-commit-repo-update-skip-list }}
pre-commit-hook-skip-list: ${{ inputs.pre-commit-hook-skip-list }}
export-dependency-groups: ${{ inputs.export-dependency-groups }}
- uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842 # v5.0.1
with:
commit_message: 'chore: Update dependencies.'
commit_user_name: ${{ inputs.commit-user-name }}
commit_user_email: ${{ inputs.commit-user-email }}
commit_author: ${{ inputs.commit-user-name }} <${{ inputs.commit-user-email }}>