Skip to content

Commit 141734d

Browse files
authored
Bring .github settings up-to-date (#336)
* Update pins and permissions for CI * Add dependabot schedule to keep pins up-to-date * Add codeql to do regular scans * Make test workflow cross-platform compatible * Fix file encoding for Windows
2 parents 07e30cf + cdb9327 commit 141734d

File tree

6 files changed

+68
-19
lines changed

6 files changed

+68
-19
lines changed

.github/codeql.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
paths:
2+
- "jmespath/"

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
ignore:
8+
- dependency-name: "*"
9+
update-types: ["version-update:semver-patch"]

.github/workflows/codeql.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: ["develop"]
6+
pull_request:
7+
branches: ["develop"]
8+
schedule:
9+
- cron: "0 0 * * 5"
10+
11+
permissions: "read"
12+
13+
jobs:
14+
analyze:
15+
name: "Analyze"
16+
runs-on: "ubuntu-latest"
17+
permissions:
18+
actions: read
19+
contents: read
20+
security-events: write
21+
steps:
22+
- name: "Checkout repository"
23+
uses: "actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3"
24+
25+
- name: "Run CodeQL init"
26+
uses: "github/codeql-action/init@4e94bd11f71e507f7f87df81788dff88d1dacbfb"
27+
with:
28+
config-file: "./.github/codeql.yml"
29+
languages: "python"
30+
31+
- name: "Run CodeQL autobuild"
32+
uses: "github/codeql-action/autobuild@4e94bd11f71e507f7f87df81788dff88d1dacbfb"
33+
34+
- name: "Run CodeQL analyze"
35+
uses: "github/codeql-action/analyze@4e94bd11f71e507f7f87df81788dff88d1dacbfb"

.github/workflows/run-tests.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,31 @@ name: Run Tests
22

33
on: [push, pull_request]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69
build:
710

811
runs-on: ${{ matrix.os }}
912
strategy:
1013
fail-fast: false
1114
matrix:
12-
os: [ubuntu-latest]
15+
os: [ubuntu-latest, macOS-latest, windows-latest]
1316
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
1417

1518
steps:
16-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3
1720
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v5
21+
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
1922
with:
2023
python-version: ${{ matrix.python-version }}
2124
- name: Install dependencies
2225
run: |
2326
pip install pip==25.1.0
2427
pip install -r requirements.txt
25-
python -m build --wheel
26-
pip install dist/*.whl
28+
python -m pip install .
2729
- name: Test with pytest
2830
run: |
2931
cd tests/ && python -m pytest --cov jmespath --cov-report term-missing
32+

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ hypothesis==5.35.4
66
# Setuptools is no longer provided by default in Python 3.12+
77
setuptools==71.1.0 ; python_version >= '3.12'
88
packaging==24.1 ; python_version >= '3.12'
9-
build==1.2.2.post1

tests/test_compliance.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,20 @@ def _walk_files():
4848

4949

5050
def load_cases(full_path):
51-
all_test_data = json.load(open(full_path), object_pairs_hook=OrderedDict)
52-
for test_data in all_test_data:
53-
given = test_data['given']
54-
for case in test_data['cases']:
55-
if 'result' in case:
56-
test_type = 'result'
57-
elif 'error' in case:
58-
test_type = 'error'
59-
elif 'bench' in case:
60-
test_type = 'bench'
61-
else:
62-
raise RuntimeError("Unknown test type: %s" % json.dumps(case))
63-
yield (given, test_type, case)
51+
with open(full_path, 'r', encoding='utf-8') as f:
52+
all_test_data = json.load(f, object_pairs_hook=OrderedDict)
53+
for test_data in all_test_data:
54+
given = test_data['given']
55+
for case in test_data['cases']:
56+
if 'result' in case:
57+
test_type = 'result'
58+
elif 'error' in case:
59+
test_type = 'error'
60+
elif 'bench' in case:
61+
test_type = 'bench'
62+
else:
63+
raise RuntimeError(f"Unknown test type: {json.dumps(case)}")
64+
yield (given, test_type, case)
6465

6566

6667
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)