From 51f06ab0f415142cf523de41dfae750616ba6ee5 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sat, 12 Feb 2022 22:20:13 +0200 Subject: [PATCH] Tune GitHub CI --- .github/workflows/ci.yaml | 77 ++++++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 22 ----------- .pre-commit-config.yaml | 14 +------ 3 files changed, 79 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/ci.yaml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..499df26 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,77 @@ +--- +name: CI + +on: + push: + branches: [master] + tags: [v*] + pull_request: + branches: [master] + workflow_dispatch: + +jobs: + lint: + name: Run linters + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - name: Install check-wheel-content, pre-commit, and twine + run: python -m pip install build pre-commit check-wheel-contents twine + - name: Build package + run: python -m build + - name: Run linter + run: python -m pre_commit run --all-files --show-diff-on-failure + - name: Check wheel contents + run: check-wheel-contents dist/*.whl + - name: Check by twine + run: python -m twine check dist/* + + test: + strategy: + matrix: + python-version: ['3.7', '3.8', '3.9', '3.10'] + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install Python ${{ matrix.python-version }} dependencies + run: | + python -m pip install --upgrade pip + pip install . + - name: Run pytest + run: pytest + + + deploy: + name: Deploy + environment: release + # Run only on pushing a tag + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + needs: [lint, test] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.4.0 + with: + fetch-depth: 0 + - name: Install build + run: python -m pip install build pre-commit check-wheel-contents twine + - name: Build package + run: python -m build + - name: PyPI upload + uses: pypa/gh-action-pypi-publish@v1.5.0 + with: + packages_dir: dist + password: ${{ secrets.PYPI_API_TOKEN }} + - name: GitHub Release + uses: ncipollo/release-action@v1 + with: + name: pytest-aiohttp ${{ github.ref_name }} + artifacts: dist/* + bodyFile: README.rst + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index eec5ce5..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Test -on: [push, pull_request] -jobs: - test: - runs-on: ubuntu-latest - - strategy: - matrix: - python-version: [3.7, 3.8, "3.10"] - - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install Python ${{ matrix.python-version }} dependencies - run: | - python -m pip install --upgrade pip - pip install . - - name: Run pytest - run: pytest \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bf5f9e2..659ad51 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,22 +46,12 @@ repos: rev: v1.9.0 hooks: - id: python-use-type-annotations -- repo: https://github.com/rhysd/actionlint - rev: v1.6.8 - hooks: - - id: actionlint-docker - args: - - -ignore - - 'SC2155:' - - -ignore - - 'SC2086:' - - -ignore - - 'SC1004:' - repo: https://github.com/sirosen/check-jsonschema rev: 0.9.1 hooks: - id: check-github-actions + - id: check-github-workflows ci: skip: - - actionlint-docker - check-github-actions + - check-github-workflows