Skip to content

Commit eb8a63b

Browse files
scottshambaughmeeseeksmachine
authored andcommitted
Backport PR pandas-dev#64396: CI: CI/CD hardening
1 parent b426e6e commit eb8a63b

13 files changed

Lines changed: 103 additions & 68 deletions

.github/actions/run-tests/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ runs:
77
shell: bash -el {0}
88

99
- name: Publish test results
10-
uses: actions/upload-artifact@v4
10+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
1111
with:
1212
name: Test results
1313
path: test-data.xml
1414
if: failure()
1515

1616
- name: Upload coverage to Codecov
17-
uses: codecov/codecov-action@v5
17+
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
1818
with:
1919
flags: unittests
2020
name: codecov-pandas

.github/actions/setup-conda/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ runs:
77
using: composite
88
steps:
99
- name: Install ${{ inputs.environment-file }}
10-
uses: mamba-org/setup-micromamba@v2
10+
uses: mamba-org/setup-micromamba@add3a49764cedee8ee24e82dfde87f5bc2914462 # v2
1111
with:
1212
environment-file: ${{ inputs.environment-file }}
1313
environment-name: test

.github/workflows/cache-cleanup-daily.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
# 4:10 UTC daily
55
- cron: "10 4 * * *"
66

7+
permissions: {}
8+
79
jobs:
810
cleanup:
911
runs-on: ubuntu-24.04

.github/workflows/cache-cleanup.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ on:
44
types:
55
- closed
66

7+
permissions: {}
8+
79
jobs:
810
cleanup:
911
runs-on: ubuntu-24.04
12+
permissions:
13+
actions: write
1014
if: github.repository_owner == 'pandas-dev'
1115
steps:
1216
- name: Clean Cache

.github/workflows/code-checks.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ env:
1414
ENV_FILE: environment.yml
1515
PANDAS_CI: 1
1616

17-
permissions:
18-
contents: read
17+
permissions: {}
1918

2019
# pre-commit run by https://pre-commit.ci/
2120
jobs:
2221
docstring_typing_manual_hooks:
2322
name: Docstring validation, typing, and other manual pre-commit hooks
2423
runs-on: ubuntu-24.04
24+
permissions:
25+
contents: read
2526
defaults:
2627
run:
2728
shell: bash -el {0}
@@ -33,7 +34,7 @@ jobs:
3334

3435
steps:
3536
- name: Checkout
36-
uses: actions/checkout@v6
37+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3738
with:
3839
fetch-depth: 0
3940

@@ -91,7 +92,7 @@ jobs:
9192
if: ${{ steps.build.outcome == 'success' && always() }}
9293

9394
- name: Typing
94-
uses: pre-commit/action@v3.0.1
95+
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
9596
with:
9697
extra_args: --verbose --hook-stage manual --all-files
9798
if: ${{ steps.build.outcome == 'success' && always() }}
@@ -103,6 +104,8 @@ jobs:
103104
asv-benchmarks:
104105
name: ASV Benchmarks
105106
runs-on: ubuntu-24.04
107+
permissions:
108+
contents: read
106109
defaults:
107110
run:
108111
shell: bash -el {0}
@@ -114,7 +117,7 @@ jobs:
114117

115118
steps:
116119
- name: Checkout
117-
uses: actions/checkout@v6
120+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
118121
with:
119122
fetch-depth: 0
120123

@@ -134,6 +137,8 @@ jobs:
134137
requirements-dev-text-installable:
135138
name: Test install requirements-dev.txt
136139
runs-on: ubuntu-24.04
140+
permissions:
141+
contents: read
137142

138143
concurrency:
139144
# https://github.community/t/concurrecy-not-work-for-push/183068/7
@@ -142,13 +147,13 @@ jobs:
142147

143148
steps:
144149
- name: Checkout
145-
uses: actions/checkout@v6
150+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
146151
with:
147152
fetch-depth: 0
148153

149154
- name: Setup Python
150155
id: setup_python
151-
uses: actions/setup-python@v6
156+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
152157
with:
153158
python-version: '3.11'
154159
cache: 'pip'

.github/workflows/codeql.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ concurrency:
88
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
99
cancel-in-progress: true
1010

11-
permissions:
12-
contents: read
11+
permissions: {}
1312

1413
jobs:
1514
analyze:
@@ -27,9 +26,9 @@ jobs:
2726
- python
2827

2928
steps:
30-
- uses: actions/checkout@v6
31-
- uses: github/codeql-action/init@v4
29+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
30+
- uses: github/codeql-action/init@c793b717bc78562f491db7b0e93a3a178b099162 # v4
3231
with:
3332
languages: ${{ matrix.language }}
34-
- uses: github/codeql-action/autobuild@v4
35-
- uses: github/codeql-action/analyze@v4
33+
- uses: github/codeql-action/autobuild@c793b717bc78562f491db7b0e93a3a178b099162 # v4
34+
- uses: github/codeql-action/analyze@c793b717bc78562f491db7b0e93a3a178b099162 # v4

.github/workflows/comment-commands.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@ on:
33
issue_comment:
44
types: created
55

6-
permissions:
7-
contents: read
8-
issues: write
9-
pull-requests: write
6+
permissions: {}
107

118
jobs:
129
preview_docs:
1310
runs-on: ubuntu-24.04
11+
permissions:
12+
contents: read
13+
issues: write
14+
pull-requests: write
1415
if: github.event.issue.pull_request && github.event.comment.body == '/preview'
1516
concurrency:
1617
group: ${{ github.actor }}-preview-docs
1718
steps:
18-
- uses: pandas-dev/github-doc-previewer@v0.3.2
19+
- uses: pandas-dev/github-doc-previewer@7a1ea7e96d1a24578ec35eedd4256a7d80c3fef8 # v0.3.2
1920
with:
2021
previewer-server: "https://pandas.pydata.org/preview"
2122
artifact-job: "Doc Build and Upload"

.github/workflows/deprecation-tracking-bot.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ on:
1010
- main
1111

1212

13-
permissions:
14-
contents: read
13+
permissions: {}
1514

1615
jobs:
1716
deprecation_update:
1817
permissions:
18+
contents: read
1919
issues: write
2020
runs-on: ubuntu-24.04
2121
env:
2222
DEPRECATION_TRACKER_ISSUE: 56596
2323
steps:
24-
- uses: actions/github-script@v8
24+
- uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
2525
id: update-deprecation-issue
2626
with:
2727
script: |

.github/workflows/docbuild-and-upload.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ on:
2525
env:
2626
ENV_FILE: environment.yml
2727
PANDAS_CI: 1
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2928

30-
permissions:
31-
contents: read
29+
permissions: {}
3230

3331
jobs:
3432
web_and_docs:
3533
name: Doc Build and Upload
3634
runs-on: ubuntu-24.04
35+
permissions:
36+
contents: read
3737

3838
concurrency:
3939
# https://github.community/t/concurrecy-not-work-for-push/183068/7
@@ -46,23 +46,27 @@ jobs:
4646

4747
steps:
4848
- name: Set pandas version
49+
env:
50+
INPUT_VERSION: ${{ github.event.inputs.version }}
51+
EVENT_NAME: ${{ github.event_name }}
52+
INPUT_PUBLISH_PROD: ${{ github.event.inputs.publish_prod }}
4953
run: |
5054
# tags include a `v` prefix.
5155
tag_version_pat="^v[0-9]+\.[0-9]+\.[0-9]+(rc[0-9]+)?$"
5256
version_pat="^[0-9]+\.[0-9]+\.[0-9]+(rc[0-9]+)?$"
5357
54-
if [[ -n "${{ github.event.inputs.version }}" ]]; then
55-
PANDAS_VERSION="${{ github.event.inputs.version }}"
56-
elif [[ "${{ github.event_name }}" == "push" && "$GITHUB_REF_NAME" =~ $tag_version_pat ]]; then
58+
if [[ -n "$INPUT_VERSION" ]]; then
59+
PANDAS_VERSION="$INPUT_VERSION"
60+
elif [[ "$EVENT_NAME" == "push" && "$GITHUB_REF_NAME" =~ $tag_version_pat ]]; then
5761
PANDAS_VERSION="${GITHUB_REF_NAME:1}"
5862
else
5963
PANDAS_VERSION=""
6064
fi
6165
echo "PANDAS_VERSION=$PANDAS_VERSION" >> "$GITHUB_ENV"
6266
63-
if [[ "${{ github.event_name }}" == "push" && -n "$PANDAS_VERSION" ]]; then
67+
if [[ "$EVENT_NAME" == "push" && -n "$PANDAS_VERSION" ]]; then
6468
PUBLISH_PROD="true"
65-
elif [[ "${{ github.event.inputs.publish_prod }}" == "true" ]]; then
69+
elif [[ "$INPUT_PUBLISH_PROD" == "true" ]]; then
6670
PUBLISH_PROD="true"
6771
else
6872
PUBLISH_PROD="false"
@@ -77,7 +81,7 @@ jobs:
7781
fi
7882
7983
- name: Checkout
80-
uses: actions/checkout@v6
84+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
8185
with:
8286
fetch-depth: 0
8387

@@ -96,6 +100,8 @@ jobs:
96100

97101
- name: Build website
98102
run: python web/pandas_web.py web/pandas --target-path=web/build
103+
env:
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99105

100106
- name: Build documentation
101107
run: doc/make.py --warnings-are-errors
@@ -134,7 +140,7 @@ jobs:
134140
run: mv doc/build/html web/build/docs
135141

136142
- name: Save website as an artifact
137-
uses: actions/upload-artifact@v7
143+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
138144
with:
139145
name: website
140146
path: web/build

.github/workflows/package-checks.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ on:
1111
- 3.0.x
1212
types: [ labeled, opened, synchronize, reopened ]
1313

14-
permissions:
15-
contents: read
14+
permissions: {}
1615

1716
defaults:
1817
run:
@@ -22,6 +21,8 @@ jobs:
2221
pip:
2322
if: ${{ github.event.label.name == 'Build' || contains(github.event.pull_request.labels.*.name, 'Build') || github.event_name == 'push'}}
2423
runs-on: ubuntu-24.04
24+
permissions:
25+
contents: read
2526
strategy:
2627
matrix:
2728
extra: ["test", "pyarrow", "performance", "computation", "fss", "aws", "gcp", "excel", "parquet", "feather", "hdf5", "spss", "postgresql", "mysql", "sql-other", "html", "xml", "plot", "output-formatting", "clipboard", "compression", "all"]
@@ -34,13 +35,13 @@ jobs:
3435

3536
steps:
3637
- name: Checkout
37-
uses: actions/checkout@v6
38+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3839
with:
3940
fetch-depth: 0
4041

4142
- name: Setup Python
4243
id: setup_python
43-
uses: actions/setup-python@v6
44+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
4445
with:
4546
python-version: '3.11'
4647

@@ -51,19 +52,21 @@ jobs:
5152
conda_forge_recipe:
5253
if: ${{ github.event.label.name == 'Build' || contains(github.event.pull_request.labels.*.name, 'Build') || github.event_name == 'push'}}
5354
runs-on: ubuntu-24.04
55+
permissions:
56+
contents: read
5457
name: Test Conda Forge Recipe
5558
concurrency:
5659
# https://github.community/t/concurrecy-not-work-for-push/183068/7
5760
group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-conda-forge-recipe
5861
cancel-in-progress: true
5962
steps:
6063
- name: Checkout
61-
uses: actions/checkout@v6
64+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
6265
with:
6366
fetch-depth: 0
6467

6568
- name: Set up Python
66-
uses: mamba-org/setup-micromamba@v2
69+
uses: mamba-org/setup-micromamba@add3a49764cedee8ee24e82dfde87f5bc2914462 # v2
6770
with:
6871
environment-name: recipe-test
6972
create-args: >-

0 commit comments

Comments
 (0)