diff --git a/.github/workflows/main-build-and-publish.yaml b/.github/workflows/main-branch.yaml similarity index 64% rename from .github/workflows/main-build-and-publish.yaml rename to .github/workflows/main-branch.yaml index 6cfe947..3db6c51 100644 --- a/.github/workflows/main-build-and-publish.yaml +++ b/.github/workflows/main-branch.yaml @@ -5,7 +5,7 @@ on: branches: [main] jobs: - test-build-and-publish: + test-and-build-and-update-metadata: name: Test, build, and publish the package runs-on: ubuntu-latest @@ -36,6 +36,7 @@ jobs: if ! `git diff --quiet`; then echo "pip freeze caused file changes, failing!" + git diff exit 1 fi @@ -43,8 +44,10 @@ jobs: run: | source venv/bin/activate make style + if ! `git diff --quiet`; then echo "make style caused file changes, failing!" + git diff exit 1 fi @@ -52,38 +55,23 @@ jobs: run: | source venv/bin/activate make nose - export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_REQLESS="$(cat VERSION)" + coverage report | tee .meta/coverage/report.txt + coverage-badge -f -o .meta/coverage/badge.svg python -m build - name: Checkout tdg5/github-action-pack uses: actions/checkout@v4 with: path: .github/actions/tdg5/github-action-pack - ref: v0.0.4 + ref: v0.0.5 repository: tdg5/github-action-pack - - name: Increment version - uses: ./.github/actions/tdg5/github-action-pack/packages/increment-version-file-action/src + - name: Commit and push code coverage snapshot + uses: ./.github/actions/tdg5/github-action-pack/packages/stage-files-and-commit-and-push-action/src with: authorEmail: dannyguinther+spamburglar@gmail.com authorName: Spamburglar - commitMessage: "[skip actions] Increment version for next development cycle" - versionFilePath: VERSION - versionFormat: python - - - name: Publish package to pypi - env: - TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} - TWINE_USERNAME: __token__ - run: | - source venv/bin/activate - python -m twine upload dist/* - - # Add the tag after publishing the package so it is more likely that we - # end up with a package without a tag than a tag without a package. - - name: Create and push tag for published version - run: | - VERSION="$(git show HEAD~1:VERSION)" - TAG_NAME="v${VERSION}" - git tag "$TAG_NAME" HEAD~1 - git push origin "$TAG_NAME" + commitMessage: "[skip actions] Update code coverage snapshot" + optionalFilePaths: | + .meta/coverage/badge.svg + .meta/coverage/report.txt diff --git a/.github/workflows/other-check-quality-and-tests.yaml b/.github/workflows/other-branch.yaml similarity index 87% rename from .github/workflows/other-check-quality-and-tests.yaml rename to .github/workflows/other-branch.yaml index f3d4347..0442ba4 100644 --- a/.github/workflows/other-check-quality-and-tests.yaml +++ b/.github/workflows/other-branch.yaml @@ -1,4 +1,4 @@ -name: Style, test, build, and publish the package +name: Style, test, and build package on: push: @@ -6,7 +6,7 @@ on: jobs: style-test-and-build: - name: Test, build, and publish the package + name: Style, test, and build package runs-on: ubuntu-latest steps: @@ -50,5 +50,5 @@ jobs: run: | source venv/bin/activate make nose - export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_REQLESS="$(cat VERSION)" + coverage report python -m build diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..847a3fb --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,94 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Release version' + required: true + default: '1.2.3' + +jobs: + test-and-build-and-publish-and-release: + env: + VERSION: ${{ github.event.inputs.version }} + name: Test, build, publish, and release the package + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v3 + with: + submodules: true + token: ${{ secrets.PAT_GITHUB_ACTIONS }} + + - uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Install dependencies + run: | + sudo apt-get update && sudo apt-get install -y redis-server + python -m venv venv + source venv/bin/activate + pip install -r requirements.txt + + - name: Check requirements.txt is up to date + run: | + source venv/bin/activate + pip install .[all] + pip uninstall -y reqless + pip freeze > requirements.txt + + if ! `git diff --quiet`; then + echo "pip freeze caused file changes, failing!" + git diff + exit 1 + fi + + - name: Check style + run: | + source venv/bin/activate + make style + + if ! `git diff --quiet`; then + echo "make style caused file changes, failing!" + git diff + exit 1 + fi + + - name: Run tests and build package + run: | + source venv/bin/activate + make nose + coverage report | tee .meta/coverage/report.txt + coverage-badge -f -o .meta/coverage/badge.svg + export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_REQLESS="$VERSION" + python -m build + + - name: Publish package to pypi + env: + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + TWINE_USERNAME: __token__ + run: | + source venv/bin/activate + python -m twine upload dist/* + + - name: Configure git actor + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Create and push tag for published version + env: + GITHUB_TOKEN: ${{ secrets.PAT_GITHUB_ACTIONS }} + RELEASE_NAME: v${{ github.event.inputs.version }} + run: | + git tag -m "$RELEASE_NAME" "$RELEASE_NAME" + git push origin "$RELEASE_NAME" + + gh release create \ + --generate-notes \ + --target "$GITHUB_REF" \ + --title "$RELEASE_NAME" \ + "$RELEASE_NAME" diff --git a/.gitignore b/.gitignore index 84ba002..cd903ef 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ build/* dist/* htmlcov/* -qless_with_throttles.egg-info/* +reqless.egg-info/* .vagrant MANIFEST .tox/ diff --git a/.meta/coverage/badge.svg b/.meta/coverage/badge.svg new file mode 100644 index 0000000..2d1c743 --- /dev/null +++ b/.meta/coverage/badge.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + coverage + coverage + 37% + 37% + + diff --git a/.meta/coverage/report.txt b/.meta/coverage/report.txt new file mode 100644 index 0000000..bb556a6 --- /dev/null +++ b/.meta/coverage/report.txt @@ -0,0 +1,69 @@ +Name Stmts Miss Cover +----------------------------------------------------------------------------------------------------- +/usr/lib/python3/dist-packages/pkg_resources/__init__.py 1532 1497 2% +/usr/lib/python3/dist-packages/pkg_resources/_vendor/packaging/_structures.py 41 40 2% +/usr/lib/python3/dist-packages/pkg_resources/_vendor/packaging/requirements.py 72 62 14% +/usr/lib/python3/dist-packages/pkg_resources/_vendor/packaging/specifiers.py 306 294 4% +/usr/lib/python3/dist-packages/pkg_resources/_vendor/packaging/version.py 160 140 12% +/usr/lib/python3/dist-packages/pkg_resources/_vendor/pyparsing.py 2513 2301 8% +/usr/lib/python3/dist-packages/pkg_resources/_vendor/six.py 444 442 1% +/usr/lib/python3/dist-packages/pkg_resources/extern/__init__.py 36 33 8% +qmore/__init__.py 0 0 100% +qmore/client.py 42 1 98% +reqless/__init__.py 146 1 99% +reqless/abstract/__init__.py 15 0 100% +reqless/abstract/abstract_client.py 23 0 100% +reqless/abstract/abstract_config.py 18 0 100% +reqless/abstract/abstract_job.py 56 0 100% +reqless/abstract/abstract_job_data.py 6 0 100% +reqless/abstract/abstract_job_processor.py 20 1 95% +reqless/abstract/abstract_jobs.py 10 0 100% +reqless/abstract/abstract_queue.py 27 0 100% +reqless/abstract/abstract_queue_identifiers_transformer.py 4 0 100% +reqless/abstract/abstract_queue_jobs.py 8 0 100% +reqless/abstract/abstract_queue_resolver.py 4 0 100% +reqless/abstract/abstract_queues.py 7 0 100% +reqless/abstract/abstract_throttle.py 11 0 100% +reqless/abstract/abstract_throttles.py 4 0 100% +reqless/abstract/abstract_workers.py 6 0 100% +reqless/config.py 50 0 100% +reqless/exceptions.py 4 0 100% +reqless/importer.py 26 0 100% +reqless/job.py 280 15 95% +reqless/listener.py 49 0 100% +reqless/logger.py 13 0 100% +reqless/proctitle.py 3 0 100% +reqless/queue.py 89 0 100% +reqless/queue_resolvers/__init__.py 4 0 100% +reqless/queue_resolvers/qmore_dynamic_mapping_queue_identifiers_transformer.py 50 0 100% +reqless/queue_resolvers/qmore_dynamic_priority_queue_identifiers_transformer.py 61 0 100% +reqless/queue_resolvers/transforming_queue_resolver.py 13 0 100% +reqless/throttle.py 29 0 100% +reqless/util.py 7 0 100% +reqless/workers/__init__.py 2 0 100% +reqless/workers/forking.py 55 2 96% +reqless/workers/greenlet.py 50 0 100% +reqless/workers/serial.py 29 0 100% +reqless/workers/util.py 39 1 97% +reqless/workers/worker.py 78 3 96% +reqless_test/__init__.py 0 0 100% +reqless_test/common.py 31 1 97% +reqless_test/test_client.py 144 6 96% +reqless_test/test_config.py 43 0 100% +reqless_test/test_events.py 36 1 97% +reqless_test/test_forking.py 61 6 90% +reqless_test/test_greenlet.py 67 15 78% +reqless_test/test_importer.py 18 0 100% +reqless_test/test_job.py 257 5 98% +reqless_test/test_job_processor_api.py 31 2 94% +reqless_test/test_listener.py 34 0 100% +reqless_test/test_qmore_client.py 57 0 100% +reqless_test/test_qmore_dynamic_mapping_queue_identifiers_transformer.py 123 0 100% +reqless_test/test_qmore_dynamic_priority_queue_identifiers_transformer.py 133 0 100% +reqless_test/test_queue.py 78 0 100% +reqless_test/test_serial.py 91 0 100% +reqless_test/test_transforming_queue_resolver.py 20 0 100% +reqless_test/test_worker.py 53 0 100% +reqless_test/test_worker_util.py 64 3 95% +----------------------------------------------------------------------------------------------------- +TOTAL 7783 4872 37% diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6e9ea74..0d06c27 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -58,7 +58,7 @@ repos: args: [--markdown-linebreak-ext=md] exclude: reqless/lua|reqless/qless-core - id: end-of-file-fixer - exclude: README.md|VERSION|reqless/lua|reqless/qless-core + exclude: README.md|reqless/lua|reqless/qless-core - id: check-docstring-first - id: debug-statements - id: name-tests-test diff --git a/README.md b/README.md index bc19339..5878ce9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![code coverage](https://github.com/tdg5/reqless-py/raw/main/.meta/coverage/badge.svg)](https://raw.githubusercontent.com/tdg5/reqless-py/main/.meta/coverage/report.txt) +[![license](https://img.shields.io/github/license/tdg5/reqless-py.svg)](https://github.com/tdg5/reqless-py/blob/main/LICENSE) + # reqless This is a fork of [seomoz/qless-py](https://github.com/seomoz/qless-py) that diff --git a/VERSION b/VERSION deleted file mode 100644 index 6aa54b8..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.13.1a0 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index ee6a52b..c1de964 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,6 +54,7 @@ dev = [ ] test = [ "coverage", + "coverage-badge~=1.1.0", "mock", "nose", "rednose", diff --git a/requirements.txt b/requirements.txt index 1120a56..7c73a54 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,6 +9,7 @@ charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 coverage==7.3.0 +coverage-badge==1.1.0 cryptography==42.0.5 decorator==5.1.1 distlib==0.3.7