Skip to content

Commit d56f848

Browse files
cdce8pPierre-Sassoulas
authored andcommitted
Improve Github action workflows (#7651)
* Remove restore keys * Log pylint + astroid versions * Reset cache versions * Add check-latest to setup-python * Use pyproject.toml for hash * Update comment-hider version comment * Pin additional actions
1 parent 8b0bb16 commit d56f848

10 files changed

+153
-129
lines changed

.github/workflows/changelog.yml

+13-11
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ on:
55
types: [opened, synchronize, labeled, unlabeled, reopened]
66

77
env:
8-
# Also change CACHE_VERSION in the other workflows
9-
CACHE_VERSION: 31
10-
DEFAULT_PYTHON: "3.10"
8+
CACHE_VERSION: 1
9+
KEY_PREFIX: base-venv
10+
DEFAULT_PYTHON: "3.11"
11+
12+
permissions:
13+
contents: read
1114

1215
jobs:
1316
check-changelog:
@@ -17,32 +20,31 @@ jobs:
1720
timeout-minutes: 10
1821
steps:
1922
- name: Check out code from GitHub
20-
uses: actions/checkout@v3.0.2
23+
uses: actions/checkout@v3.1.0
2124
with:
2225
# `towncrier check` runs `git diff --name-only origin/main...`, which
2326
# needs a non-shallow clone.
2427
fetch-depth: 0
2528
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
2629
id: python
27-
uses: actions/setup-python@v4.2.0
30+
uses: actions/setup-python@v4.3.0
2831
with:
2932
python-version: ${{ env.DEFAULT_PYTHON }}
33+
check-latest: true
3034
- name: Generate partial Python venv restore key
3135
id: generate-python-key
3236
run: >-
33-
echo "::set-output name=key::base-venv-${{ env.CACHE_VERSION }}-${{
34-
hashFiles('setup.cfg', 'requirements_test.txt', 'requirements_test_min.txt')
35-
}}"
37+
echo "key=${{ env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{
38+
hashFiles('pyproject.toml', 'requirements_test.txt',
39+
'requirements_test_min.txt') }}" >> $GITHUB_OUTPUT
3640
- name: Restore Python virtual environment
3741
id: cache-venv
38-
uses: actions/[email protected].8
42+
uses: actions/[email protected].11
3943
with:
4044
path: venv
4145
key: >-
4246
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
4347
steps.generate-python-key.outputs.key }}
44-
restore-keys: |
45-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-base-venv-${{ env.CACHE_VERSION }}-
4648
- name: Create Python virtual environment
4749
if: steps.cache-venv.outputs.cache-hit != 'true'
4850
run: |

.github/workflows/checks.yaml

+30-25
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ on:
88
pull_request: ~
99

1010
env:
11-
CACHE_VERSION: 31
12-
DEFAULT_PYTHON: "3.10"
11+
CACHE_VERSION: 1
12+
KEY_PREFIX: base-venv
13+
DEFAULT_PYTHON: "3.11"
1314
PRE_COMMIT_CACHE: ~/.cache/pre-commit
1415

1516
concurrency:
1617
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1718
cancel-in-progress: true
1819

20+
permissions:
21+
contents: read
22+
1923
jobs:
2024
prepare-base:
2125
name: Prepare base dependencies
@@ -26,28 +30,27 @@ jobs:
2630
pre-commit-key: ${{ steps.generate-pre-commit-key.outputs.key }}
2731
steps:
2832
- name: Check out code from GitHub
29-
uses: actions/checkout@v3.0.2
33+
uses: actions/checkout@v3.1.0
3034
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
3135
id: python
32-
uses: actions/setup-python@v4.2.0
36+
uses: actions/setup-python@v4.3.0
3337
with:
3438
python-version: ${{ env.DEFAULT_PYTHON }}
39+
check-latest: true
3540
- name: Generate partial Python venv restore key
3641
id: generate-python-key
3742
run: >-
38-
echo "::set-output name=key::base-venv-${{ env.CACHE_VERSION }}-${{
39-
hashFiles('setup.cfg', 'requirements_test.txt', 'requirements_test_min.txt')
40-
}}"
43+
echo "key=${{ env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{
44+
hashFiles('pyproject.toml', 'requirements_test.txt',
45+
'requirements_test_min.txt') }}" >> $GITHUB_OUTPUT
4146
- name: Restore Python virtual environment
4247
id: cache-venv
43-
uses: actions/[email protected].8
48+
uses: actions/[email protected].11
4449
with:
4550
path: venv
4651
key: >-
4752
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
4853
steps.generate-python-key.outputs.key }}
49-
restore-keys: |
50-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-base-venv-${{ env.CACHE_VERSION }}-
5154
- name: Create Python virtual environment
5255
if: steps.cache-venv.outputs.cache-hit != 'true'
5356
run: |
@@ -59,17 +62,15 @@ jobs:
5962
- name: Generate pre-commit restore key
6063
id: generate-pre-commit-key
6164
run: >-
62-
echo "::set-output name=key::pre-commit-${{ env.CACHE_VERSION }}-${{
63-
hashFiles('.pre-commit-config.yaml') }}"
65+
echo "key=pre-commit-${{ env.CACHE_VERSION }}-${{
66+
hashFiles('.pre-commit-config.yaml') }}" >> $GITHUB_OUTPUT
6467
- name: Restore pre-commit environment
6568
id: cache-precommit
66-
uses: actions/[email protected].8
69+
uses: actions/[email protected].11
6770
with:
6871
path: ${{ env.PRE_COMMIT_CACHE }}
6972
key: >-
7073
${{ runner.os }}-${{ steps.generate-pre-commit-key.outputs.key }}
71-
restore-keys: |
72-
${{ runner.os }}-pre-commit-${{ env.CACHE_VERSION }}-
7374
- name: Install pre-commit dependencies
7475
if: steps.cache-precommit.outputs.cache-hit != 'true'
7576
run: |
@@ -83,15 +84,16 @@ jobs:
8384
needs: prepare-base
8485
steps:
8586
- name: Check out code from GitHub
86-
uses: actions/checkout@v3.0.2
87+
uses: actions/checkout@v3.1.0
8788
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
8889
id: python
89-
uses: actions/setup-python@v4.2.0
90+
uses: actions/setup-python@v4.3.0
9091
with:
9192
python-version: ${{ env.DEFAULT_PYTHON }}
93+
check-latest: true
9294
- name: Restore Python virtual environment
9395
id: cache-venv
94-
uses: actions/[email protected].8
96+
uses: actions/[email protected].11
9597
with:
9698
path: venv
9799
key:
@@ -104,7 +106,7 @@ jobs:
104106
exit 1
105107
- name: Restore pre-commit environment
106108
id: cache-precommit
107-
uses: actions/[email protected].8
109+
uses: actions/[email protected].11
108110
with:
109111
path: ${{ env.PRE_COMMIT_CACHE }}
110112
key: ${{ runner.os }}-${{ needs.prepare-base.outputs.pre-commit-key }}
@@ -121,6 +123,7 @@ jobs:
121123
run: |
122124
. venv/bin/activate
123125
pip install -e .
126+
pip list | grep 'astroid\|pylint'
124127
pre-commit run --hook-stage manual pylint-with-spelling --all-files
125128
126129
spelling:
@@ -130,15 +133,16 @@ jobs:
130133
needs: prepare-base
131134
steps:
132135
- name: Check out code from GitHub
133-
uses: actions/checkout@v3.0.2
136+
uses: actions/checkout@v3.1.0
134137
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
135138
id: python
136-
uses: actions/setup-python@v4.2.0
139+
uses: actions/setup-python@v4.3.0
137140
with:
138141
python-version: ${{ env.DEFAULT_PYTHON }}
142+
check-latest: true
139143
- name: Restore Python virtual environment
140144
id: cache-venv
141-
uses: actions/[email protected].8
145+
uses: actions/[email protected].11
142146
with:
143147
path: venv
144148
key:
@@ -161,15 +165,16 @@ jobs:
161165
needs: prepare-base
162166
steps:
163167
- name: Check out code from GitHub
164-
uses: actions/checkout@v3.0.2
168+
uses: actions/checkout@v3.1.0
165169
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
166170
id: python
167-
uses: actions/setup-python@v4.2.0
171+
uses: actions/setup-python@v4.3.0
168172
with:
169173
python-version: ${{ env.DEFAULT_PYTHON }}
174+
check-latest: true
170175
- name: Restore Python virtual environment
171176
id: cache-venv
172-
uses: actions/[email protected].8
177+
uses: actions/[email protected].11
173178
with:
174179
path: venv
175180
key:

.github/workflows/primer-test.yaml

+23-18
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,49 @@ on:
1313
- ".github/workflows/primer-test.yaml"
1414

1515
env:
16-
CACHE_VERSION: 31
16+
CACHE_VERSION: 1
17+
KEY_PREFIX: venv
1718

1819
concurrency:
1920
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
2021
cancel-in-progress: true
2122

23+
permissions:
24+
contents: read
25+
2226
jobs:
2327
prepare-tests-linux:
2428
name: prepare / ${{ matrix.python-version }} / Linux
2529
runs-on: ubuntu-latest
2630
timeout-minutes: 5
2731
strategy:
2832
matrix:
29-
python-version: [3.8, 3.9, "3.10"]
33+
python-version: [3.8, 3.9, "3.10", "3.11"]
3034
outputs:
3135
python-key: ${{ steps.generate-python-key.outputs.key }}
3236
steps:
3337
- name: Check out code from GitHub
34-
uses: actions/checkout@v3.0.2
38+
uses: actions/checkout@v3.1.0
3539
- name: Set up Python ${{ matrix.python-version }}
3640
id: python
37-
uses: actions/setup-python@v4.2.0
41+
uses: actions/setup-python@v4.3.0
3842
with:
3943
python-version: ${{ matrix.python-version }}
44+
check-latest: true
4045
- name: Generate partial Python venv restore key
4146
id: generate-python-key
4247
run: >-
43-
echo "::set-output name=key::venv-${{ env.CACHE_VERSION }}-${{
44-
hashFiles('setup.cfg', 'requirements_test.txt', 'requirements_test_min.txt')
45-
}}"
48+
echo "key=${{ env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{
49+
hashFiles('pyproject.toml', 'requirements_test.txt',
50+
'requirements_test_min.txt') }}" >> $GITHUB_OUTPUT
4651
- name: Restore Python virtual environment
4752
id: cache-venv
48-
uses: actions/[email protected].8
53+
uses: actions/[email protected].11
4954
with:
5055
path: venv
5156
key: >-
5257
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
5358
steps.generate-python-key.outputs.key }}
54-
restore-keys: |
55-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-${{ env.CACHE_VERSION }}-
5659
- name: Create Python virtual environment
5760
if: steps.cache-venv.outputs.cache-hit != 'true'
5861
run: |
@@ -68,18 +71,19 @@ jobs:
6871
needs: prepare-tests-linux
6972
strategy:
7073
matrix:
71-
python-version: [3.8, 3.9, "3.10"]
74+
python-version: [3.8, 3.9, "3.10", "3.11"]
7275
steps:
7376
- name: Check out code from GitHub
74-
uses: actions/checkout@v3.0.2
77+
uses: actions/checkout@v3.1.0
7578
- name: Set up Python ${{ matrix.python-version }}
7679
id: python
77-
uses: actions/setup-python@v4.2.0
80+
uses: actions/setup-python@v4.3.0
7881
with:
7982
python-version: ${{ matrix.python-version }}
83+
check-latest: true
8084
- name: Restore Python virtual environment
8185
id: cache-venv
82-
uses: actions/[email protected].8
86+
uses: actions/[email protected].11
8387
with:
8488
path: venv
8589
key:
@@ -103,18 +107,19 @@ jobs:
103107
needs: prepare-tests-linux
104108
strategy:
105109
matrix:
106-
python-version: [3.8, 3.9, "3.10"]
110+
python-version: [3.8, 3.9, "3.10", "3.11"]
107111
steps:
108112
- name: Check out code from GitHub
109-
uses: actions/checkout@v3.0.2
113+
uses: actions/checkout@v3.1.0
110114
- name: Set up Python ${{ matrix.python-version }}
111115
id: python
112-
uses: actions/setup-python@v4.2.0
116+
uses: actions/setup-python@v4.3.0
113117
with:
114118
python-version: ${{ matrix.python-version }}
119+
check-latest: true
115120
- name: Restore Python virtual environment
116121
id: cache-venv
117-
uses: actions/[email protected].8
122+
uses: actions/[email protected].11
118123
with:
119124
path: venv
120125
key:

.github/workflows/primer_comment.yaml

+15-14
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ on:
1414

1515
env:
1616
# This needs to be the SAME as in the Main and PR job
17-
CACHE_VERSION: 31
17+
CACHE_VERSION: 1
18+
KEY_PREFIX: venv-primer
19+
DEFAULT_PYTHON: "3.10"
1820

1921
permissions:
2022
contents: read
@@ -27,35 +29,36 @@ jobs:
2729
name: Run
2830
runs-on: ubuntu-latest
2931
steps:
30-
- uses: actions/setup-node@v3
32+
- uses: actions/setup-node@v3.5.1
3133
with:
3234
node-version: 16
3335
- run: npm install @octokit/rest
3436
- name: Check out code from GitHub
35-
uses: actions/checkout@v3.0.2
36-
- name: Set up Python 3.10
37+
uses: actions/checkout@v3.1.0
38+
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
3739
id: python
38-
uses: actions/setup-python@v4.2.0
40+
uses: actions/setup-python@v4.3.0
3941
with:
40-
python-version: "3.10"
42+
python-version: ${{ env.DEFAULT_PYTHON }}
43+
check-latest: true
4144

4245
# Restore cached Python environment
4346
- name: Restore Python virtual environment
4447
id: cache-venv
45-
uses: actions/[email protected].8
48+
uses: actions/[email protected].11
4649
with:
4750
path: venv
4851
key:
49-
${{ runner.os }}-${{ steps.python.outputs.python-version }}-venv-primer-${{
50-
env.CACHE_VERSION }}
52+
${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{
53+
env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}
5154
- name: Fail job if Python cache restore failed
5255
if: steps.cache-venv.outputs.cache-hit != 'true'
5356
run: |
5457
echo "Failed to restore Python venv from cache"
5558
exit 1
5659
5760
- name: Download outputs
58-
uses: actions/github-script@v6
61+
uses: actions/github-script@v6.3.3
5962
with:
6063
script: |
6164
// Download workflow pylint output
@@ -110,9 +113,8 @@ jobs:
110113
--new-file=output_${{ steps.python.outputs.python-version }}_pr.txt
111114
- name: Post comment
112115
id: post-comment
113-
uses: actions/github-script@v6
116+
uses: actions/github-script@v6.3.3
114117
with:
115-
github-token: ${{ secrets.GITHUB_TOKEN }}
116118
script: |
117119
const fs = require('fs')
118120
const comment = fs.readFileSync('tests/.pylint_primer_tests/comment.txt', { encoding: 'utf8' })
@@ -128,8 +130,7 @@ jobs:
128130
return prNumber
129131
- name: Hide old comments
130132
# Taken from mypy primer
131-
# v0.3.0
132-
uses: kanga333/comment-hider@bbdf5b562fbec24e6f60572d8f712017428b92e0
133+
uses: kanga333/comment-hider@c12bb20b48aeb8fc098e35967de8d4f8018fffdf # v0.4.0
133134
with:
134135
github_token: ${{ secrets.GITHUB_TOKEN }}
135136
leave_visible: 1

0 commit comments

Comments
 (0)