|
5 | 5 | branches: |
6 | 6 | - master |
7 | 7 | pull_request: |
8 | | - branches: |
9 | | - - "**" |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.head_ref || github.run_id }} |
| 11 | + cancel-in-progress: true |
10 | 12 |
|
11 | 13 | jobs: |
12 | | - build: |
13 | | - runs-on: ${{ matrix.os }} |
| 14 | + lint: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v3 |
| 18 | + - uses: actions/setup-python@v3 |
| 19 | + with: |
| 20 | + python-version: "3.9" |
| 21 | + - uses: pre-commit/action@v2.0.3 |
| 22 | + |
| 23 | + # Make sure commit messages follow the conventional commits convention: |
| 24 | + # https://www.conventionalcommits.org |
| 25 | + commitlint: |
| 26 | + name: Lint Commit Messages |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v3 |
| 30 | + with: |
| 31 | + fetch-depth: 0 |
| 32 | + - uses: wagoid/commitlint-github-action@v4.1.11 |
| 33 | + |
| 34 | + test: |
14 | 35 | strategy: |
| 36 | + fail-fast: false |
15 | 37 | matrix: |
16 | | - os: [ubuntu-latest, macos-latest, windows-latest] |
17 | | - python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "pypy-3.7"] |
18 | | - include: |
19 | | - - os: ubuntu-latest |
20 | | - venvcmd: . env/bin/activate |
| 38 | + python-version: |
| 39 | + - "3.7" |
| 40 | + - "3.8" |
| 41 | + - "3.9" |
| 42 | + - "3.10" |
| 43 | + - "3.11" |
| 44 | + - "pypy-3.7" |
| 45 | + os: |
| 46 | + - ubuntu-latest |
| 47 | + - macos-latest |
| 48 | + - windows-latest |
| 49 | + extension: |
| 50 | + - "skip_cython" |
| 51 | + - "use_cython" |
| 52 | + exclude: |
21 | 53 | - os: macos-latest |
22 | | - venvcmd: . env/bin/activate |
| 54 | + extension: use_cython |
23 | 55 | - os: windows-latest |
24 | | - venvcmd: env\Scripts\Activate.ps1 |
| 56 | + extension: use_cython |
| 57 | + - os: windows-latest |
| 58 | + python-version: "pypy-3.7" |
| 59 | + runs-on: ${{ matrix.os }} |
25 | 60 | steps: |
26 | | - - uses: actions/checkout@v2 |
27 | | - - name: Set up Python ${{ matrix.python-version }} |
28 | | - uses: actions/setup-python@v2 |
| 61 | + - uses: actions/checkout@v3 |
| 62 | + - name: Install poetry |
| 63 | + run: pipx install poetry |
| 64 | + - name: Set up Python |
| 65 | + uses: actions/setup-python@v4 |
29 | 66 | with: |
30 | 67 | python-version: ${{ matrix.python-version }} |
31 | | - architecture: 'x64' |
32 | | - - uses: actions/cache@v2 |
33 | | - id: cache |
| 68 | + cache: "poetry" |
| 69 | + - name: Install Dependencies no cython |
| 70 | + if: ${{ matrix.extension == 'skip_cython' }} |
| 71 | + env: |
| 72 | + SKIP_CYTHON: 1 |
| 73 | + run: poetry install --only=main,dev |
| 74 | + - name: Install Dependencies with cython |
| 75 | + if: ${{ matrix.extension != 'skip_cython' }} |
| 76 | + run: poetry install --only=main,dev |
| 77 | + - name: Test with Pytest |
| 78 | + run: poetry run pytest --durations=20 --timeout=60 -v --cov=zeroconf --cov-branch --cov-report xml --cov-report html --cov-report term-missing tests |
| 79 | + - name: Upload coverage to Codecov |
| 80 | + uses: codecov/codecov-action@v3 |
34 | 81 | with: |
35 | | - path: env |
36 | | - key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/Makefile') }}-${{ hashFiles('**/requirements-dev.txt') }} |
37 | | - restore-keys: | |
38 | | - ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/Makefile') }} |
39 | | - - name: Install dependencies |
40 | | - if: steps.cache.outputs.cache-hit != 'true' |
41 | | - run: | |
42 | | - python -m venv env |
43 | | - ${{ matrix.venvcmd }} |
44 | | - pip install --upgrade -r requirements-dev.txt pytest-github-actions-annotate-failures |
45 | | - - name: Validate readme |
46 | | - if: ${{ runner.os == 'Linux' && matrix.python-version != 'pypy-3.7' }} |
47 | | - run: | |
48 | | - ${{ matrix.venvcmd }} |
49 | | - python -m readme_renderer README.rst -o - |
50 | | - - name: Run flake8 |
51 | | - if: ${{ runner.os == 'Linux' && matrix.python-version != 'pypy-3.7' }} |
52 | | - run: | |
53 | | - ${{ matrix.venvcmd }} |
54 | | - make flake8 |
55 | | - - name: Run mypy |
56 | | - if: ${{ runner.os == 'Linux' && matrix.python-version != 'pypy-3.7' }} |
57 | | - run: | |
58 | | - ${{ matrix.venvcmd }} |
59 | | - make mypy |
60 | | - - name: Run black_check |
61 | | - if: ${{ runner.os == 'Linux' && matrix.python-version != 'pypy-3.7' }} |
62 | | - run: | |
63 | | - ${{ matrix.venvcmd }} |
64 | | - make black_check |
65 | | - - name: Run tests |
| 82 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 83 | + |
| 84 | + release: |
| 85 | + runs-on: ubuntu-latest |
| 86 | + environment: release |
| 87 | + if: github.ref == 'refs/heads/master' |
| 88 | + needs: |
| 89 | + - test |
| 90 | + - lint |
| 91 | + - commitlint |
| 92 | + |
| 93 | + steps: |
| 94 | + - uses: actions/checkout@v3 |
| 95 | + with: |
| 96 | + fetch-depth: 0 |
| 97 | + |
| 98 | + # Run semantic release: |
| 99 | + # - Update CHANGELOG.md |
| 100 | + # - Update version in code |
| 101 | + # - Create git tag |
| 102 | + # - Create GitHub release |
| 103 | + # - Publish to PyPI |
| 104 | + - name: Python Semantic Release |
| 105 | + uses: relekang/python-semantic-release@v7.32.2 |
| 106 | + with: |
| 107 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 108 | + pypi_token: ${{ secrets.PYPI_TOKEN }} |
| 109 | + |
| 110 | + build_wheels: |
| 111 | + needs: [release] |
| 112 | + |
| 113 | + name: Build wheels on ${{ matrix.os }} |
| 114 | + runs-on: ${{ matrix.os }} |
| 115 | + strategy: |
| 116 | + matrix: |
| 117 | + os: [ubuntu-20.04, windows-2019, macOS-11] |
| 118 | + |
| 119 | + steps: |
| 120 | + - uses: actions/checkout@v3 |
| 121 | + with: |
| 122 | + fetch-depth: 0 |
| 123 | + ref: "master" |
| 124 | + |
| 125 | + # Used to host cibuildwheel |
| 126 | + - name: Set up Python |
| 127 | + uses: actions/setup-python@v4 |
| 128 | + |
| 129 | + - name: Install python-semantic-release |
| 130 | + run: python -m pip install python-semantic-release |
| 131 | + |
| 132 | + - name: Get Release Tag |
| 133 | + id: release_tag |
| 134 | + shell: bash |
66 | 135 | run: | |
67 | | - ${{ matrix.venvcmd }} |
68 | | - make test_coverage |
69 | | - - name: Report coverage to Codecov |
70 | | - uses: codecov/codecov-action@v1 |
| 136 | + echo "::set-output name=newest_release_tag::$(semantic-release print-version --current)" |
| 137 | +
|
| 138 | + - uses: actions/checkout@v3 |
| 139 | + with: |
| 140 | + ref: "v${{ steps.release_tag.outputs.newest_release_tag }}" |
| 141 | + fetch-depth: 0 |
| 142 | + |
| 143 | + - name: Install cibuildwheel |
| 144 | + run: python -m pip install cibuildwheel==2.11.3 |
| 145 | + |
| 146 | + - name: Build wheels |
| 147 | + run: python -m cibuildwheel --output-dir wheelhouse |
| 148 | + # to supply options, put them in 'env', like: |
| 149 | + env: |
| 150 | + CIBW_SKIP: cp36-* |
| 151 | + CIBW_BEFORE_ALL_LINUX: apt-get install -y gcc || yum install -y gcc || apk add gcc |
| 152 | + CIBW_BUILD_VERBOSITY: 3 |
| 153 | + REQUIRE_CYTHON: 1 |
| 154 | + |
| 155 | + - uses: actions/upload-artifact@v3 |
| 156 | + with: |
| 157 | + path: ./wheelhouse/*.whl |
| 158 | + |
| 159 | + upload_pypi: |
| 160 | + needs: [build_wheels] |
| 161 | + runs-on: ubuntu-latest |
| 162 | + environment: release |
| 163 | + |
| 164 | + steps: |
| 165 | + - uses: actions/download-artifact@v3 |
| 166 | + with: |
| 167 | + # unpacks default artifact into dist/ |
| 168 | + # if `name: artifact` is omitted, the action will create extra parent dir |
| 169 | + name: artifact |
| 170 | + path: dist |
| 171 | + |
| 172 | + - uses: pypa/gh-action-pypi-publish@v1.5.0 |
| 173 | + with: |
| 174 | + user: __token__ |
| 175 | + password: ${{ secrets.PYPI_TOKEN }} |
| 176 | + repository_url: https://test.pypi.org/legacy/ |
| 177 | + |
| 178 | + # To test: repository_url: https://test.pypi.org/legacy/ |
0 commit comments