diff --git a/.github/actionlint-matcher.json b/.github/actionlint-matcher.json new file mode 100644 index 00000000..a99709f7 --- /dev/null +++ b/.github/actionlint-matcher.json @@ -0,0 +1,17 @@ +{ + "problemMatcher": [ + { + "owner": "actionlint", + "pattern": [ + { + "code": 5, + "column": 3, + "file": 1, + "line": 2, + "message": 4, + "regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$" + } + ] + } + ] +} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 12aafa0d..186b31b5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,43 @@ on: workflow_dispatch: jobs: + lint: + name: Run linters + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + prerelease: ${{ steps.version.outputs.prerelease }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-python@v2 + with: + python-version: '3.9' + - name: Install GitHub matcher for ActionLint checker + run: | + echo "::add-matcher::.github/actionlint-matcher.json" + - name: Install check-wheel-content, and twine + run: python -m pip install build check-wheel-contents tox twine + - name: Build package + run: python -m build + - name: Run tox for linter + run: python -m tox -e lint + - name: List result + run: ls -l dist + - name: Check wheel contents + run: check-wheel-contents dist/*.whl + - name: Check long_description + run: python -m twine check dist/* + - name: Get version info + id: version + run: tox -e version-info + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: dist + path: dist + test: name: Python ${{ matrix.python-version }} runs-on: ubuntu-latest @@ -21,6 +58,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} @@ -41,7 +80,7 @@ jobs: check: name: Check if: always() - needs: [test] + needs: [lint, test] runs-on: ubuntu-latest steps: - name: Decide whether the needed jobs succeeded or failed @@ -51,23 +90,36 @@ jobs: - name: Upload coverage uses: aio-libs/upload-coverage@v21.9.4 - package: - name: Build & verify package + deploy: + name: Deploy + environment: release + # Run only on pushing a tag + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + needs: [lint, check] runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - name: Checkout + uses: actions/checkout@v2.4.0 with: - python-version: '3.9' - - - name: Install poetry, check-wheel-content, and twine - run: python -m pip install build check-wheel-contents twine - - name: Build package - run: python -m build - - name: List result - run: ls -l dist - - name: Check wheel contents - run: check-wheel-contents dist/*.whl - - name: Check long_description - run: python -m twine check dist/* + fetch-depth: 0 + - name: Download distributions + uses: actions/download-artifact@v2 + with: + name: dist + path: dist + - name: Collected dists + run: | + tree dist + - name: PyPI upload + uses: pypa/gh-action-pypi-publish@v1.4.2 + with: + packages_dir: dist + password: ${{ secrets.PYPI_API_TOKEN }} + - name: GitHub Release + uses: ncipollo/release-action@v1 + with: + name: pytest-asyncio ${{ needs.lint.outputs.version }} + artifacts: dist + bodyFile: README.rst + prerelease: ${{ needs.lint.outputs.prerelease }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/tools/get-version.py b/tools/get-version.py new file mode 100644 index 00000000..e988a32c --- /dev/null +++ b/tools/get-version.py @@ -0,0 +1,17 @@ +import json +import sys +from importlib import metadata + +from packaging.version import parse as parse_version + + +def main(): + version_string = metadata.version("pytest-asyncio") + version = parse_version(version_string) + print(f"::set-output name=version::{version}") + prerelease = json.dumps(version.is_prerelease) + print(f"::set-output name=prerelease::{prerelease}") + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tox.ini b/tox.ini index dc09b8c5..0092b03e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,20 +1,25 @@ [tox] minversion = 3.14.0 -envlist = py37, py38, py39, py310, lint +envlist = py37, py38, py39, py310, lint, version-info skip_missing_interpreters = true +passenv = + CI [testenv] extras = testing commands = make test +allowlist_externals = + make [testenv:lint] skip_install = true basepython = python3.9 -extras = tests deps = - pre-commit + pre-commit == 2.16.0 commands = make lint +allowlist_externals = + make [testenv:coverage-report] deps = coverage @@ -23,6 +28,13 @@ commands = coverage combine coverage report +[testenv:version-info] +basepython = python3.9 +deps = + packaging == 21.3 +commands = + python ./tools/get-version.py + [gh-actions] python = 3.7: py37