Skip to content

Commit b87577c

Browse files
authored
refresh project to match pallets (#1159)
2 parents f6dc4da + 87b0991 commit b87577c

16 files changed

+471
-262
lines changed

setup.cfg .flake8

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Config goes in pyproject.toml unless a tool doesn't support that.
2-
31
[flake8]
42
extend-select =
53
# bugbear

.github/workflows/lock.yaml

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ on:
88
schedule:
99
- cron: '0 0 * * *'
1010

11+
permissions:
12+
issues: write
13+
pull-requests: write
14+
15+
concurrency:
16+
group: lock
17+
1118
jobs:
1219
lock:
1320
runs-on: ubuntu-latest
1421
steps:
15-
- uses: dessant/lock-threads@v3
22+
- uses: dessant/lock-threads@c1b35aecc5cdb1a34539d14196df55838bb2f836
1623
with:
17-
github-token: ${{ github.token }}
1824
issue-inactive-days: 14
1925
pr-inactive-days: 14

.github/workflows/publish.yaml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Publish
2+
on:
3+
push:
4+
tags:
5+
- '*'
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
hash: ${{ steps.hash.outputs.hash }}
11+
steps:
12+
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
13+
- uses: actions/setup-python@5ccb29d8773c3f3f653e1705f474dfaa8a06a912
14+
with:
15+
python-version: '3.x'
16+
cache: 'pip'
17+
cache-dependency-path: 'pdm.lock'
18+
- uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12
19+
with:
20+
path: ~/.cache/pdm
21+
key: ${{ matrix.python }}-pdm-${{ hashFiles('pdm.lock') }}
22+
restore-keys: ${{ matrix.python }}-pdm-
23+
- run: pip install pdm
24+
# Use the commit date instead of the current date during the build.
25+
- run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
26+
- run: pdm build
27+
# Generate hashes used for provenance.
28+
- name: generate hash
29+
id: hash
30+
run: cd dist && echo "hash=$(sha256sum * | base64 -w0)" >> $GITHUB_OUTPUT
31+
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
32+
with:
33+
path: ./dist
34+
provenance:
35+
needs: ['build']
36+
permissions:
37+
actions: read
38+
id-token: write
39+
contents: write
40+
# Can't pin with hash due to how this workflow works.
41+
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
42+
with:
43+
base64-subjects: ${{ needs.build.outputs.hash }}
44+
create-release:
45+
# Upload the sdist, wheels, and provenance to a GitHub release. They remain
46+
# available as build artifacts for a while as well.
47+
needs: ['provenance']
48+
runs-on: ubuntu-latest
49+
permissions:
50+
contents: write
51+
steps:
52+
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
53+
- name: create release
54+
run: >
55+
gh release create --draft --repo ${{ github.repository }}
56+
${{ github.ref_name }}
57+
*.intoto.jsonl/* artifact/*
58+
env:
59+
GH_TOKEN: ${{ github.token }}
60+
publish-pypi:
61+
needs: ['provenance']
62+
# Wait for approval before attempting to upload to PyPI. This allows reviewing the
63+
# files in the draft release.
64+
environment: 'publish'
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
68+
# Try uploading to Test PyPI first, in case something fails.
69+
- uses: pypa/gh-action-pypi-publish@c7f29f7adef1a245bd91520e94867e5c6eedddcc
70+
with:
71+
password: ${{ secrets.TEST_PYPI_TOKEN }}
72+
repository_url: https://test.pypi.org/legacy/
73+
packages_dir: artifact/
74+
- uses: pypa/gh-action-pypi-publish@c7f29f7adef1a245bd91520e94867e5c6eedddcc
75+
with:
76+
password: ${{ secrets.PYPI_TOKEN }}
77+
packages_dir: artifact/

.github/workflows/tests.yaml

+12-5
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,31 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
include:
27+
- {name: '3.11', python: '3.11', tox: py311}
28+
- {name: 'Lowest', python: '3.11', tox: py311-lowest}
2729
- {name: '3.10', python: '3.10', tox: py310}
28-
- {name: 'Lowest', python: '3.10', tox: py310-lowest}
2930
- {name: '3.9', python: '3.9', tox: py39}
3031
- {name: '3.8', python: '3.8', tox: py38}
3132
- {name: '3.7', python: '3.7', tox: py37}
32-
- {name: 'Typing', python: '3.10', os: ubuntu-latest, tox: typing}
33+
- {name: 'Typing', python: '3.11', os: ubuntu-latest, tox: typing}
3334
steps:
34-
- uses: actions/checkout@v3
35-
- uses: actions/setup-python@v4
35+
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c
36+
- uses: actions/setup-python@5ccb29d8773c3f3f653e1705f474dfaa8a06a912
3637
with:
3738
python-version: ${{ matrix.python }}
3839
cache: 'pip'
3940
cache-dependency-path: 'pdm.lock'
40-
- uses: actions/cache@v3
41+
- uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12
4142
with:
4243
path: ~/.cache/pdm
4344
key: ${{ matrix.python }}-pdm-${{ hashFiles('pdm.lock') }}
4445
restore-keys: ${{ matrix.python }}-pdm-
46+
- name: cache mypy
47+
uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12
48+
with:
49+
path: ./.mypy_cache
50+
key: mypy|${{ matrix.python }}|${{ hashFiles('pyproject.toml') }}
51+
if: matrix.tox == 'typing'
4552
- run: |
4653
pip install pdm
4754
pdm config install.cache true

0 commit comments

Comments
 (0)