|
| 1 | +name: Test |
| 2 | +on: |
| 3 | + push: |
| 4 | + pull_request: |
| 5 | + schedule: |
| 6 | + - cron: '3 2 1 * *' # M H d m w (monthly at 2:03) |
| 7 | +jobs: |
| 8 | + check: |
| 9 | + if: github.event_name != 'pull_request' || github.head_ref != 'devel' |
| 10 | + name: Check |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v2 |
| 14 | + with: |
| 15 | + fetch-depth: 0 |
| 16 | + - uses: actions/setup-python@v2 |
| 17 | + with: |
| 18 | + python-version: '3.x' |
| 19 | + - name: set PYSHA |
| 20 | + run: echo "PYSHA=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV |
| 21 | + - uses: actions/cache@v1 |
| 22 | + with: |
| 23 | + path: ~/.cache/pre-commit |
| 24 | + key: pre-commit|${{ env.PYSHA }}|${{ hashFiles('.pre-commit-config.yaml') }} |
| 25 | + - name: Test |
| 26 | + run: | |
| 27 | + pip install -U tox |
| 28 | + tox -e setup.py |
| 29 | + - name: Self install |
| 30 | + run: pip install -U .[dev] |
| 31 | + - name: Build |
| 32 | + run: | |
| 33 | + python setup.py sdist bdist_wheel |
| 34 | + twine check dist/* |
| 35 | + - uses: reviewdog/action-setup@v1 |
| 36 | + - if: github.event_name != 'schedule' |
| 37 | + name: flake8 |
| 38 | + run: | |
| 39 | + pre-commit run -a flake8 | reviewdog -f=pep8 -name=Format -tee -reporter=github-check -filter-mode nofilter |
| 40 | + env: |
| 41 | + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + - name: Lint |
| 43 | + run: pre-commit run -a --show-diff-on-failure |
| 44 | + test: |
| 45 | + if: github.event_name != 'pull_request' || github.head_ref != 'devel' |
| 46 | + strategy: |
| 47 | + matrix: |
| 48 | + python: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, pypy3] |
| 49 | + name: Python ${{ matrix.python }} |
| 50 | + runs-on: ubuntu-latest |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v2 |
| 53 | + with: |
| 54 | + fetch-depth: 0 |
| 55 | + - uses: actions/setup-python@v2 |
| 56 | + with: |
| 57 | + python-version: ${{ matrix.python }} |
| 58 | + - name: Install |
| 59 | + run: pip install -U tox |
| 60 | + - name: Test |
| 61 | + run: | |
| 62 | + if [[ "$PYVER" == py* ]]; then |
| 63 | + tox -e $PYVER # basic:pypy |
| 64 | + else |
| 65 | + tox -e py${PYVER/./} # normal |
| 66 | + fi |
| 67 | + env: |
| 68 | + PYVER: ${{ matrix.python }} |
| 69 | + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 70 | + - name: Coveralls Parallel |
| 71 | + uses: AndreMiras/coveralls-python-action@develop |
| 72 | + with: |
| 73 | + parallel: true |
| 74 | + finish: |
| 75 | + if: github.event_name != 'pull_request' || github.head_ref != 'devel' |
| 76 | + name: Coverage |
| 77 | + continue-on-error: ${{ github.event_name != 'push' }} |
| 78 | + needs: test |
| 79 | + runs-on: ubuntu-latest |
| 80 | + steps: |
| 81 | + - name: Coveralls Finished |
| 82 | + uses: AndreMiras/coveralls-python-action@develop |
| 83 | + with: |
| 84 | + parallel-finished: true |
| 85 | + deploy: |
| 86 | + if: github.event_name != 'pull_request' || github.head_ref != 'devel' |
| 87 | + name: Deploy |
| 88 | + needs: [check, test] |
| 89 | + runs-on: ubuntu-latest |
| 90 | + steps: |
| 91 | + - uses: actions/checkout@v2 |
| 92 | + with: |
| 93 | + fetch-depth: 0 |
| 94 | + - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') |
| 95 | + uses: casperdcl/deploy-pypi@v1 |
| 96 | + with: |
| 97 | + build: true |
| 98 | + gpg_key: ${{ secrets.GPG_KEY }} |
| 99 | + password: ${{ secrets.PYPI_TOKEN }} |
| 100 | + skip_existing: true |
| 101 | + - id: collect_assets |
| 102 | + name: Collect assets |
| 103 | + run: | |
| 104 | + echo "::set-output name=asset_path::$(ls dist/*.whl)" |
| 105 | + echo "::set-output name=asset_name::$(basename dist/*.whl)" |
| 106 | + echo "::set-output name=asset_path_sig::$(ls dist/*.whl.asc 2>/dev/null)" |
| 107 | + echo "::set-output name=asset_name_sig::$(basename dist/*.whl.asc 2>/dev/null)" |
| 108 | + git log --pretty='format:%d%n- %s%n%b---' $(git tag --sort=v:refname | tail -n2 | head -n1)..HEAD > _CHANGES.md |
| 109 | + - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') |
| 110 | + id: create_release |
| 111 | + uses: actions/create-release@v1 |
| 112 | + env: |
| 113 | + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
| 114 | + with: |
| 115 | + tag_name: ${{ github.ref }} |
| 116 | + release_name: argopt ${{ github.ref }} stable |
| 117 | + body_path: _CHANGES.md |
| 118 | + draft: true |
| 119 | + - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') |
| 120 | + uses: actions/upload-release-asset@v1 |
| 121 | + env: |
| 122 | + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
| 123 | + with: |
| 124 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 125 | + asset_path: ${{ steps.collect_assets.outputs.asset_path }} |
| 126 | + asset_name: ${{ steps.collect_assets.outputs.asset_name }} |
| 127 | + asset_content_type: application/zip |
| 128 | + - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') |
| 129 | + uses: actions/upload-release-asset@v1 |
| 130 | + env: |
| 131 | + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
| 132 | + with: |
| 133 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 134 | + asset_path: ${{ steps.collect_assets.outputs.asset_path_sig }} |
| 135 | + asset_name: ${{ steps.collect_assets.outputs.asset_name_sig }} |
| 136 | + asset_content_type: text/plain |
0 commit comments