|
| 1 | +name: Unit Testing, Coverage Collection, Package, Release, Documentation and Publish |
| 2 | + |
| 3 | +on: [ push ] |
| 4 | + |
| 5 | +defaults: |
| 6 | + run: |
| 7 | + shell: bash |
| 8 | + |
| 9 | +jobs: |
| 10 | + UnitTesting: |
| 11 | + name: ${{ matrix.icon }} Unit Tests using Python ${{ matrix.python }} |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + include: |
| 18 | + - {python: 3.6, icon: 🔴} |
| 19 | + - {python: 3.7, icon: 🟠} |
| 20 | + - {python: 3.8, icon: 🟡} |
| 21 | + - {python: 3.9, icon: 🟢} |
| 22 | + |
| 23 | + env: |
| 24 | + PYTHON: ${{ matrix.python }} |
| 25 | + outputs: |
| 26 | + python: ${{ env.PYTHON }} |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: ⏬ Checkout repository |
| 30 | + uses: actions/checkout@v2 |
| 31 | + |
| 32 | + - name: 🐍 Setup Python ${{ matrix.python }} |
| 33 | + uses: actions/setup-python@v2 |
| 34 | + with: |
| 35 | + python-version: ${{ matrix.python }} |
| 36 | + |
| 37 | + - name: 🔧 Install dependencies |
| 38 | + run: | |
| 39 | + python -m pip install --upgrade pip |
| 40 | + pip install -r tests/requirements.txt |
| 41 | +
|
| 42 | + - name: ☑ Run unit tests |
| 43 | + run: | |
| 44 | + python -m pytest -rA tests/unit |
| 45 | +
|
| 46 | + Coverage: |
| 47 | + name: 📈 Collect Coverage Data using Python 3.9 |
| 48 | + runs-on: ubuntu-latest |
| 49 | + |
| 50 | + env: |
| 51 | + PYTHON: 3.9 |
| 52 | + outputs: |
| 53 | + python: ${{ env.PYTHON }} |
| 54 | + |
| 55 | + steps: |
| 56 | + - name: ⏬ Checkout repository |
| 57 | + uses: actions/checkout@v2 |
| 58 | + |
| 59 | + - name: 🐍 Setup Python ${{ env.PYTHON }} |
| 60 | + uses: actions/setup-python@v2 |
| 61 | + with: |
| 62 | + python-version: ${{ env.PYTHON }} |
| 63 | + |
| 64 | + - name: 🗂 Install dependencies |
| 65 | + run: | |
| 66 | + python -m pip install --upgrade pip |
| 67 | + pip install -r tests/requirements.txt |
| 68 | +
|
| 69 | + - name: Collect coverage |
| 70 | + continue-on-error: true |
| 71 | + run: | |
| 72 | + python -m pytest -rA --cov=.. --cov-config=tests/.coveragerc tests/unit |
| 73 | +
|
| 74 | + - name: Convert to cobertura format |
| 75 | + run: | |
| 76 | + coverage xml |
| 77 | +
|
| 78 | + - name: 📊 Publish coverage at CodeCov |
| 79 | + continue-on-error: true |
| 80 | + uses: codecov/codecov-action@v1 |
| 81 | + with: |
| 82 | + file: ./coverage.xml |
| 83 | + flags: unittests |
| 84 | + env_vars: PYTHON |
| 85 | + |
| 86 | + - name: 📉 Publish coverage at Codacy |
| 87 | + continue-on-error: true |
| 88 | + uses: codacy/codacy-coverage-reporter-action@master |
| 89 | + with: |
| 90 | + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} |
| 91 | + coverage-reports: ./coverage.xml |
| 92 | + |
| 93 | + Release: |
| 94 | + name: 📝 Create 'Release Page' on GitHub |
| 95 | + runs-on: ubuntu-latest |
| 96 | + |
| 97 | + if: startsWith(github.ref, 'refs/tags') |
| 98 | + needs: |
| 99 | + - UnitTesting |
| 100 | + - Coverage |
| 101 | + |
| 102 | + env: |
| 103 | + PYTHON: ${{ needs.Coverage.outputs.python }} |
| 104 | + outputs: |
| 105 | + python: ${{ env.PYTHON }} |
| 106 | + tag: ${{ steps.getVariables.outputs.gitTag }} |
| 107 | + version: ${{ steps.getVariables.outputs.version }} |
| 108 | + datetime: ${{ steps.getVariables.outputs.datetime }} |
| 109 | + upload_url: ${{ steps.createReleasePage.outputs.upload_url }} |
| 110 | + |
| 111 | + steps: |
| 112 | + - name: 🔁 Extract Git tag from GITHUB_REF |
| 113 | + id: getVariables |
| 114 | + run: | |
| 115 | + GIT_TAG=${GITHUB_REF#refs/*/} |
| 116 | + RELEASE_VERSION=${GIT_TAG#v} |
| 117 | + RELEASE_DATETIME="$(date --utc '+%d.%m.%Y - %H:%M:%S')" |
| 118 | + # write to step outputs |
| 119 | + echo ::set-output name=gitTag::${GIT_TAG} |
| 120 | + echo ::set-output name=version::${RELEASE_VERSION} |
| 121 | + echo ::set-output name=datetime::${RELEASE_DATETIME} |
| 122 | +
|
| 123 | + - name: 📑 Create Release Page |
| 124 | + id: createReleasePage |
| 125 | + uses: actions/create-release@v1 |
| 126 | + env: |
| 127 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 128 | + with: |
| 129 | + tag_name: ${{ steps.getVariables.outputs.gitTag }} |
| 130 | +# release_name: ${{ steps.getVariables.outputs.gitTag }} |
| 131 | + body: | |
| 132 | + **Automated Release created on: ${{ steps.getVariables.outputs.datetime }}** |
| 133 | +
|
| 134 | + # New Features |
| 135 | + * tbd |
| 136 | +
|
| 137 | + # Changes |
| 138 | + * tbd |
| 139 | +
|
| 140 | + # Bug Fixes |
| 141 | + * tbd |
| 142 | + draft: false |
| 143 | + prerelease: false |
| 144 | + |
| 145 | + Package: |
| 146 | + name: 📦 Package in Wheel Format |
| 147 | + runs-on: ubuntu-latest |
| 148 | + |
| 149 | + if: startsWith(github.ref, 'refs/tags') |
| 150 | + needs: |
| 151 | + - Coverage |
| 152 | + |
| 153 | + env: |
| 154 | + PYTHON: ${{ needs.Coverage.outputs.python }} |
| 155 | + ARTIFACT: pyTerminalUI-wheel |
| 156 | + outputs: |
| 157 | + python: ${{ env.PYTHON }} |
| 158 | + artifact: ${{ env.ARTIFACT }} |
| 159 | + |
| 160 | + steps: |
| 161 | + - name: 📥 Checkout repository |
| 162 | + uses: actions/checkout@v2 |
| 163 | + |
| 164 | + - name: 🐍 Setup Python ${{ env.PYTHON }} |
| 165 | + uses: actions/setup-python@v2 |
| 166 | + with: |
| 167 | + python-version: ${{ env.PYTHON }} |
| 168 | + |
| 169 | + - name: 🔧 Install dependencies for packaging and release |
| 170 | + run: | |
| 171 | + python -m pip install --upgrade pip |
| 172 | + pip install wheel |
| 173 | +
|
| 174 | + - name: 🔨 Build Python package (source distribution) |
| 175 | + run: | |
| 176 | + python setup.py sdist |
| 177 | +
|
| 178 | + - name: 🔨 Build Python package (binary distribution - wheel) |
| 179 | + run: | |
| 180 | + python setup.py bdist_wheel |
| 181 | +
|
| 182 | + - name: 📤 Upload 'pyTerminalUI' artifact |
| 183 | + uses: actions/upload-artifact@v2 |
| 184 | + with: |
| 185 | + name: ${{ env.ARTIFACT }} |
| 186 | + path: dist/ |
| 187 | + if-no-files-found: error |
| 188 | + retention-days: 1 |
| 189 | + |
| 190 | + PublishOnPyPI: |
| 191 | + name: 🚀 Publish to PyPI |
| 192 | + runs-on: ubuntu-latest |
| 193 | + |
| 194 | + if: startsWith(github.ref, 'refs/tags') |
| 195 | + needs: |
| 196 | + - Package |
| 197 | + |
| 198 | + env: |
| 199 | + PYTHON: ${{ needs.Package.outputs.python }} |
| 200 | + ARTIFACT: ${{ needs.Package.outputs.artifact }} |
| 201 | + outputs: |
| 202 | + python: ${{ env.PYTHON }} |
| 203 | + artifact: ${{ env.ARTIFACT }} |
| 204 | + |
| 205 | + steps: |
| 206 | + - name: 📥 Download artifacts '${{ env.ARTIFACT }}' from 'Package' job |
| 207 | + uses: actions/download-artifact@v2 |
| 208 | + with: |
| 209 | + name: ${{ env.ARTIFACT }} |
| 210 | + path: dist/ |
| 211 | + |
| 212 | + - name: 🐍 Setup Python ${{ env.PYTHON }} |
| 213 | + uses: actions/setup-python@v2 |
| 214 | + with: |
| 215 | + python-version: ${{ env.PYTHON }} |
| 216 | + |
| 217 | + - name: ⚙ Install dependencies for packaging and release |
| 218 | + run: | |
| 219 | + python -m pip install --upgrade pip |
| 220 | + pip install wheel twine |
| 221 | +
|
| 222 | + - name: ⤴ Release Python package to PyPI |
| 223 | + env: |
| 224 | + TWINE_USERNAME: __token__ |
| 225 | + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 226 | + run: | |
| 227 | + twine upload dist/* |
| 228 | +
|
| 229 | + ArtifactCleanUp: |
| 230 | + name: 🗑️ Artifact Cleanup |
| 231 | + runs-on: ubuntu-latest |
| 232 | + |
| 233 | + needs: |
| 234 | + - Package |
| 235 | + - PublishOnPyPI |
| 236 | + |
| 237 | + env: |
| 238 | + ARTIFACT: ${{ needs.Package.outputs.artifact }} |
| 239 | + |
| 240 | + steps: |
| 241 | + - name: 🗑️ Delete all Artifacts |
| 242 | + uses: geekyeggo/delete-artifact@v1 |
| 243 | + with: |
| 244 | + name: | |
| 245 | + ${{ env.ARTIFACT }} |
0 commit comments