-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from bjhargrave/python-package
schema package: Build a python package with the schema
- Loading branch information
Showing
25 changed files
with
583 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"problemMatcher": [ | ||
{ | ||
"owner": "mypy", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(.+):(\\d+):\\s(error|warning):\\s(.+)$", | ||
"file": 1, | ||
"line": 2, | ||
"severity": 3, | ||
"message": 4 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"problemMatcher": [ | ||
{ | ||
"owner": "pylint-error", | ||
"severity": "error", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(.+):(\\d+):(\\d+):\\s(([EF]\\d{4}):\\s.+)$", | ||
"file": 1, | ||
"line": 2, | ||
"column": 3, | ||
"message": 4, | ||
"code": 5 | ||
} | ||
] | ||
}, | ||
{ | ||
"owner": "pylint-warning", | ||
"severity": "warning", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(.+):(\\d+):(\\d+):\\s(([CRW]\\d{4}):\\s.+)$", | ||
"file": 1, | ||
"line": 2, | ||
"column": 3, | ||
"message": 4, | ||
"code": 5 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: Build, test, and upload PyPI package | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
tags: | ||
- "v*" | ||
pull_request: | ||
branches: | ||
- "main" | ||
release: | ||
types: | ||
- published | ||
|
||
env: | ||
LC_ALL: en_US.UTF-8 | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
# Create and verify release artifacts | ||
# - build source dist (tar ball) and wheel | ||
# - validate artifacts with various tools | ||
# - upload artifacts to GHA | ||
build-package: | ||
name: Build and check packages | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Harden Runner" | ||
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 | ||
with: | ||
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs | ||
|
||
|
||
- name: "Checkout" | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
with: | ||
# for setuptools-scm | ||
fetch-depth: 0 | ||
|
||
- name: "Build and Inspect" | ||
uses: hynek/build-and-inspect-python-package@b4fc3f6ba2b3da04f09659be99e2a29fb6146a61 # v2.6.0 | ||
|
||
# push to Test PyPI on | ||
# - a new GitHub release is published | ||
# - a PR is merged into main branch | ||
publish-test-pypi: | ||
name: Publish packages to test.pypi.org | ||
# environment: publish-test-pypi | ||
if: ${{ (github.repository_owner == 'instructlab') && ((github.event.action == 'published') || ((github.event_name == 'push') && (github.ref == 'refs/heads/main'))) }} | ||
permissions: | ||
contents: read | ||
# see https://docs.pypi.org/trusted-publishers/ | ||
id-token: write | ||
runs-on: ubuntu-latest | ||
needs: build-package | ||
|
||
steps: | ||
- name: "Harden Runner" | ||
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 | ||
with: | ||
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs | ||
|
||
- name: "Download build artifacts" | ||
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 | ||
with: | ||
name: Packages | ||
path: dist | ||
|
||
- name: "Upload to Test PyPI" | ||
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
|
||
# push to Production PyPI on | ||
# - a new GitHub release is published | ||
publish-pypi: | ||
name: Publish release to pypi.org | ||
# environment: publish-pypi | ||
if: ${{ (github.repository_owner == 'instructlab') && (github.event.action == 'published') }} | ||
permissions: | ||
# see https://docs.pypi.org/trusted-publishers/ | ||
id-token: write | ||
# allow gh release upload | ||
contents: write | ||
|
||
runs-on: ubuntu-latest | ||
needs: build-package | ||
|
||
steps: | ||
- name: "Harden Runner" | ||
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0 | ||
with: | ||
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs | ||
|
||
- name: "Download build artifacts" | ||
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 | ||
with: | ||
name: Packages | ||
path: dist | ||
|
||
- name: "Sigstore sign package" | ||
uses: sigstore/gh-action-sigstore-python@61f6a500bbfdd9a2a339cf033e5421951fbc1cd2 # v2.1.1 | ||
with: | ||
inputs: | | ||
./dist/*.tar.gz | ||
./dist/*.whl | ||
- name: "Upload artifacts and signatures to GitHub release" | ||
run: | | ||
gh release upload '${{ github.ref_name }}' dist/* --repo '${{ github.repository }}' | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# PyPI does not accept .sigstore artifacts and | ||
# gh-action-pypi-publish has no option to ignore them. | ||
- name: "Remove sigstore signatures before uploading to PyPI" | ||
run: | | ||
rm ./dist/*.sigstore | ||
- name: "Upload to PyPI" | ||
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
paths: | ||
- '**.py' | ||
- 'src/instructlab/schema/v*/**/*.json' | ||
- 'pyproject.toml' | ||
- 'tox.ini' | ||
- 'scripts/**' | ||
- '.github/workflows/test.yml' # This workflow | ||
pull_request: | ||
branches: | ||
- "main" | ||
paths: | ||
- '**.py' | ||
- 'src/instructlab/schema/v*/**/*.json' | ||
- 'pyproject.toml' | ||
- 'tox.ini' | ||
- 'scripts/**' | ||
- '.github/workflows/test.yml' # This workflow | ||
|
||
env: | ||
LC_ALL: en_US.UTF-8 | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test: | ||
name: "${{ matrix.python }} on ${{ matrix.platform }}" | ||
runs-on: "${{ matrix.platform }}" | ||
strategy: | ||
matrix: | ||
python: | ||
- "3.9" | ||
- "3.10" | ||
- "3.11" | ||
- "3.12" | ||
platform: | ||
- "ubuntu-latest" | ||
steps: | ||
- name: "Harden Runner" | ||
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 | ||
with: | ||
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs | ||
|
||
- name: "Checkout" | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: "Setup Python ${{ matrix.python }}" | ||
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
|
||
- name: "Install tox" | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install tox tox-gh | ||
- name: "Unit tests" | ||
run: | | ||
tox |
Oops, something went wrong.