Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

配置流水线与单测 #234

Merged
merged 7 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
template: |
## What’s Changed

$CHANGES
73 changes: 21 additions & 52 deletions .github/workflows/python-build.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,33 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package
name: PR Check

on:
pull_request:
branches: [ "main", "release" ]

permissions:
contents: read

jobs:
package:
runs-on: ubuntu-latest
test-api-only:

strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10"]
os: [ macos-latest, windows-latest, ubuntu-latest ]
python-version: ["3.9", "3.10", "3.11", "3.12"]
pydantic: ["pydantic>=2.0.0", "pydantic<2.0.0"]

runs-on: ${{ matrix.os }}
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v2
- name: Set up python
id: setup-python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
#----------------------------------------------
# lint & test
#----------------------------------------------
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
poetry run pytest
#----------------------------------------------
# build & upload
#----------------------------------------------
- name: Build package
run: poetry build
- name: Upload distribution
uses: actions/upload-artifact@v3
with:
name: distribution
path: dist/*
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install requirements
run: |
pip install poetry
poetry export --with=dev --without-hashes -o requirements.txt
pip install -r requirements.txt
pip install "${{ matrix.pydantic }}"
- name: Test with pytest
run: pytest
95 changes: 46 additions & 49 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,54 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package
name: Release

on:
release:
types: [ published ]

permissions:
contents: read
push:
tags:
- v*

jobs:
upload:
publish-pypi-github:
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/nonebot-plugin-pixivbot
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write

steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v2
- name: Set up python
id: setup-python
uses: actions/setup-python@v2
with:
python-version: 3.x
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
#----------------------------------------------
# build & publish
#----------------------------------------------
- name: Build package
run: poetry build
- name: Upload distribution
uses: actions/upload-artifact@v3
- uses: actions/checkout@v3

- name: Setup Python environment
uses: actions/setup-python@v3
with:
name: distribution
path: dist/*
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
python-version: "3.11"

- name: Setup Poetry
run: |
pip install poetry

- run: |
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- uses: release-drafter/release-drafter@v5
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
name: Release ${{ env.TAG_NAME }}
tag: ${{ env.TAG_NAME }}
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish PyPI and Github
run: |
poetry build
ls dist/
gh release upload --clobber ${{ env.TAG_NAME }} dist/*.tar.gz dist/*.whl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish pypi
uses: pypa/gh-action-pypi-publish@release/v1
2 changes: 0 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import nonebot
from nonebot.adapters.qqguild import Adapter

nonebot.init()

driver = nonebot.get_driver()
driver.register_adapter(Adapter)

nonebot.load_plugin("nonebot_plugin_pixivbot")

Expand Down
Loading
Loading