Skip to content

Commit 7d2b257

Browse files
ci(backport): Update CI permissions changes (#2505)
* Backport: - PR #2363 - PR #2479 - PR #2481 - PR #2483 - PR #2489
1 parent 16840f6 commit 7d2b257

14 files changed

+107
-3
lines changed

.github/workflows/bump-version.yml

+5
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@ on:
3333
description: 'Perform a dry run to check'
3434
default: true
3535

36+
permissions:
37+
contents: read
38+
3639
jobs:
3740
bump-version:
41+
permissions:
42+
contents: write # for Git to git push
3843
runs-on: ubuntu-latest
3944
if: github.repository == 'scikit-hep/pyhf'
4045

.github/workflows/ci-windows.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: CI on Windows
2+
3+
on:
4+
# Run daily at 1:23 UTC
5+
schedule:
6+
- cron: '23 1 * * *'
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
test:
18+
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
matrix:
22+
os: [windows-latest]
23+
python-version: ['3.9', '3.10', '3.11', '3.12']
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Set up Python ${{ matrix.python-version }}
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install uv
36+
uv pip install --system --upgrade pip setuptools wheel
37+
uv pip install --system --upgrade '.[all,test]'
38+
39+
- name: List installed Python packages
40+
run: python -m pip list
41+
42+
- name: Test with pytest and coverage
43+
# FIXME: ignore tests/test_scripts.py as runner breaks on Windows currently
44+
run: |
45+
coverage run --module pytest --ignore tests/test_scripts.py --ignore tests/contrib --ignore tests/benchmarks --ignore tests/test_notebooks.py
46+
47+
- name: Coverage report for core project
48+
run: |
49+
coverage report
50+
coverage xml

.github/workflows/ci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ concurrency:
1515
group: ${{ github.workflow }}-${{ github.ref }}
1616
cancel-in-progress: true
1717

18+
permissions:
19+
contents: read
20+
1821
jobs:
1922
test:
2023

.github/workflows/codeql-analysis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ concurrency:
1515
group: ${{ github.workflow }}-${{ github.ref }}
1616
cancel-in-progress: true
1717

18+
permissions:
19+
contents: read
20+
1821
jobs:
1922
analyze:
23+
permissions:
24+
actions: read # for github/codeql-action/init to get workflow details
25+
contents: read # for actions/checkout to fetch code
26+
security-events: write # for github/codeql-action/analyze to upload SARIF results
2027
name: Analyze
2128
runs-on: ubuntu-latest
2229

.github/workflows/dependencies-head.yml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}
1111
cancel-in-progress: true
1212

13+
permissions:
14+
contents: read
15+
1316
jobs:
1417
release-candidates:
1518

.github/workflows/docker.yml

+6
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ concurrency:
2020
group: ${{ github.workflow }}-${{ github.ref }}
2121
cancel-in-progress: true
2222

23+
permissions:
24+
contents: read
25+
2326
jobs:
2427
docker:
2528
name: Build, test, and publish Docker images to Docker Hub
29+
permissions:
30+
contents: read
31+
packages: write # for docker to push to registry
2632
runs-on: ubuntu-latest
2733

2834
steps:

.github/workflows/docs.yml

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ concurrency:
1414
group: ${{ github.workflow }}-${{ github.ref }}
1515
cancel-in-progress: true
1616

17+
permissions:
18+
contents: read
19+
1720
jobs:
1821
build:
1922
name: Build docs

.github/workflows/lint.yml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ concurrency:
88
group: ${{ github.workflow }}-${{ github.ref }}
99
cancel-in-progress: true
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
lint:
1316

.github/workflows/lower-bound-requirements.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
- cron: '1 0 * * *'
77
workflow_dispatch:
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
test:
1114

@@ -26,7 +29,7 @@ jobs:
2629

2730
- name: Install dependencies and force lowest bound
2831
run: |
29-
python -m pip install --upgrade pip setuptools wheel
32+
python -m pip install --upgrade pip 'setuptools<70.0.0' wheel
3033
python -m pip --no-cache-dir install --constraint tests/constraints.txt .[test]
3134
3235
- name: List installed Python packages

.github/workflows/merged.yml

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
types: [closed]
66
workflow_dispatch:
77

8+
permissions:
9+
contents: read
10+
811
jobs:
912
binder:
1013
name: Trigger Binder build

.github/workflows/notebooks.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}
1111
cancel-in-progress: true
1212

13+
permissions:
14+
contents: read
15+
1316
jobs:
1417
test:
1518

@@ -41,4 +44,4 @@ jobs:
4144
# Override the ini option for filterwarnings with an empty list to disable error
4245
# on filterwarnings as testing for notebooks to run with the latest API, not if
4346
# Jupyter infrastructure is warning free.
44-
pytest --override-ini filterwarnings= tests/test_notebooks.py
47+
pytest --verbose --override-ini filterwarnings= tests/test_notebooks.py

.github/workflows/publish-package.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@ concurrency:
2525
group: ${{ github.workflow }}-${{ github.ref }}
2626
cancel-in-progress: true
2727

28+
permissions:
29+
contents: read
30+
2831
jobs:
2932
build:
3033
name: Build Python distribution
3134
runs-on: ubuntu-latest
3235
permissions:
3336
id-token: write
3437
attestations: write
35-
contents: read
3638

3739
steps:
3840
- uses: actions/checkout@v4

.github/workflows/release_tests.yml

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}
1111
cancel-in-progress: true
1212

13+
permissions:
14+
contents: read
15+
1316
jobs:
1417

1518
pypi_release:
@@ -45,6 +48,10 @@ jobs:
4548
4649
- name: Canary test public API
4750
run: |
51+
# Override the ini option for filterwarnings with an empty list to disable error on filterwarnings
52+
# as testing the latest release API still works, not the release is warning free.
53+
# Though still show warnings by setting warning control to 'default'.
54+
export PYTHONWARNINGS='default'
4855
pytest tests/test_public_api.py
4956
5057
# FIXME: c.f. https://github.com/proycon/codemetapy/issues/24

.github/workflows/semantic-pr-check.yml

+6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ concurrency:
1111
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.number }}
1212
cancel-in-progress: true
1313

14+
permissions:
15+
contents: read
16+
1417
jobs:
1518
main:
1619

20+
permissions:
21+
pull-requests: read # for amannn/action-semantic-pull-request to analyze PRs
22+
statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR
1723
name: Validate PR title
1824
runs-on: ubuntu-latest
1925

0 commit comments

Comments
 (0)