|
| 1 | +name: Unit Testing, Coverage Collection, Package, Release and Publish |
| 2 | + |
| 3 | +on: [ push ] |
| 4 | + |
| 5 | +jobs: |
| 6 | + UnitTesting: |
| 7 | + name: Unit Tests |
| 8 | + runs-on: ubuntu-latest |
| 9 | + |
| 10 | + strategy: |
| 11 | + fail-fast: false |
| 12 | + matrix: |
| 13 | + python-version: [ 3.8, 3.9 ] |
| 14 | + |
| 15 | + env: |
| 16 | + PYTHON: ${{ matrix.python-version }} |
| 17 | + outputs: |
| 18 | + python: ${{ env.PYTHON }} |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@v2 |
| 23 | + |
| 24 | + - name: Setup Python ${{ matrix.python-version }} |
| 25 | + uses: actions/setup-python@v2 |
| 26 | + with: |
| 27 | + python-version: ${{ matrix.python-version }} |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + python -m pip install --upgrade pip |
| 32 | + pip install -r tests/requirements.txt |
| 33 | +
|
| 34 | + - name: Run unit tests |
| 35 | + run: | |
| 36 | + python -m pytest -rA tests/unit |
| 37 | +
|
| 38 | + IssueTesting: |
| 39 | + name: Issue Tests |
| 40 | + runs-on: ubuntu-latest |
| 41 | + |
| 42 | + continue-on-error: true |
| 43 | + strategy: |
| 44 | + fail-fast: false |
| 45 | + matrix: |
| 46 | + python-version: [ 3.8, 3.9 ] |
| 47 | + |
| 48 | + env: |
| 49 | + PYTHON: ${{ matrix.python-version }} |
| 50 | + outputs: |
| 51 | + python: ${{ env.PYTHON }} |
| 52 | + |
| 53 | + steps: |
| 54 | + - name: Checkout repository |
| 55 | + uses: actions/checkout@v2 |
| 56 | + |
| 57 | + - name: Setup Python ${{ matrix.python-version }} |
| 58 | + uses: actions/setup-python@v2 |
| 59 | + with: |
| 60 | + python-version: ${{ matrix.python-version }} |
| 61 | + |
| 62 | + - name: Install dependencies |
| 63 | + run: | |
| 64 | + python -m pip install --upgrade pip |
| 65 | + pip install -r tests/requirements.txt |
| 66 | +
|
| 67 | + - name: Run unit tests |
| 68 | + run: | |
| 69 | + python -m pytest -rA tests/issue |
| 70 | +
|
| 71 | + Coverage: |
| 72 | + name: Collect Coverage Data |
| 73 | + runs-on: ubuntu-latest |
| 74 | + |
| 75 | + env: |
| 76 | + PYTHON: 3.9 |
| 77 | + outputs: |
| 78 | + python: ${{ env.PYTHON }} |
| 79 | + |
| 80 | + steps: |
| 81 | + - name: Checkout repository |
| 82 | + uses: actions/checkout@v2 |
| 83 | + |
| 84 | + - name: Setup Python ${{ env.PYTHON }} |
| 85 | + uses: actions/setup-python@v2 |
| 86 | + with: |
| 87 | + python-version: ${{ env.PYTHON }} |
| 88 | + |
| 89 | + - name: Install dependencies |
| 90 | + run: | |
| 91 | + python -m pip install --upgrade pip |
| 92 | + pip install -r tests/requirements.txt |
| 93 | +
|
| 94 | + - name: Collect coverage |
| 95 | + if: ${{ always() }} |
| 96 | + run: | |
| 97 | + python -m pytest -rA --cov=.. --cov-config=tests/.coveragerc tests/unit |
| 98 | +
|
| 99 | + - name: Convert to cobertura format |
| 100 | + if: ${{ always() }} |
| 101 | + run: | |
| 102 | + coverage xml |
| 103 | +
|
| 104 | + - name: Publish coverage at CodeCov |
| 105 | + if: ${{ always() }} |
| 106 | + uses: codecov/codecov-action@v1 |
| 107 | + with: |
| 108 | + file: ./coverage.xml |
| 109 | + flags: unittests |
| 110 | + env_vars: PYTHON |
| 111 | + |
| 112 | + - name: Publish coverage at Codacy |
| 113 | + if: ${{ always() }} |
| 114 | + uses: codacy/codacy-coverage-reporter-action@master |
| 115 | + with: |
| 116 | + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} |
| 117 | + coverage-reports: ./coverage.xml |
| 118 | + |
| 119 | + Release: |
| 120 | + name: Release Page on GitHub |
| 121 | + runs-on: ubuntu-latest |
| 122 | + |
| 123 | + if: startsWith(github.ref, 'refs/tags') |
| 124 | + needs: |
| 125 | + - UnitTesting |
| 126 | + - IssueTesting |
| 127 | + - Coverage |
| 128 | + |
| 129 | + env: |
| 130 | + PYTHON: ${{ needs.Coverage.outputs.python }} |
| 131 | + outputs: |
| 132 | + python: ${{ env.PYTHON }} |
| 133 | + tag: ${{ steps.getVariables.outputs.gitTag }} |
| 134 | + version: ${{ steps.getVariables.outputs.version }} |
| 135 | + datetime: ${{ steps.getVariables.outputs.datetime }} |
| 136 | + upload_url: ${{ steps.createReleasePage.outputs.upload_url }} |
| 137 | + |
| 138 | + steps: |
| 139 | + - name: Extract Git tag from GITHUB_REF |
| 140 | + id: getVariables |
| 141 | + run: | |
| 142 | + GIT_TAG=${GITHUB_REF#refs/*/} |
| 143 | + RELEASE_VERSION=${GIT_TAG#v} |
| 144 | + RELEASE_DATETIME="$(date --utc '+%d.%m.%Y - %H:%M:%S')" |
| 145 | + # write to step outputs |
| 146 | + echo ::set-output name=gitTag::${GIT_TAG} |
| 147 | + echo ::set-output name=version::${RELEASE_VERSION} |
| 148 | + echo ::set-output name=datetime::${RELEASE_DATETIME} |
| 149 | +
|
| 150 | + - name: Create Release Page |
| 151 | + id: createReleasePage |
| 152 | + uses: actions/create-release@v1 |
| 153 | + env: |
| 154 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 155 | + with: |
| 156 | + tag_name: ${{ steps.getVariables.outputs.gitTag }} |
| 157 | + release_name: ${{ steps.getVariables.outputs.gitTag }} |
| 158 | + body: | |
| 159 | + **Automated Release created on: ${{ steps.getVariables.outputs.datetime }}** |
| 160 | +
|
| 161 | + # New Features |
| 162 | + * tbd |
| 163 | +
|
| 164 | + # Changes |
| 165 | + * tbd |
| 166 | +
|
| 167 | + # Bug Fixes |
| 168 | + * tbd |
| 169 | + draft: false |
| 170 | + prerelease: false |
| 171 | + |
| 172 | + Package: |
| 173 | + name: Package in Wheel Format |
| 174 | + runs-on: ubuntu-latest |
| 175 | + |
| 176 | + if: startsWith(github.ref, 'refs/tags') |
| 177 | + needs: |
| 178 | + - Coverage |
| 179 | + |
| 180 | + env: |
| 181 | + PYTHON: ${{ needs.Coverage.outputs.python }} |
| 182 | + ARTIFACT: pyVHDLParser-wheel |
| 183 | + outputs: |
| 184 | + python: ${{ env.PYTHON }} |
| 185 | + artifact: ${{ env.ARTIFACT }} |
| 186 | + |
| 187 | + steps: |
| 188 | + - name: Checkout repository |
| 189 | + uses: actions/checkout@v2 |
| 190 | + |
| 191 | + - name: Setup Python ${{ env.PYTHON }} |
| 192 | + uses: actions/setup-python@v2 |
| 193 | + with: |
| 194 | + python-version: ${{ env.PYTHON }} |
| 195 | + |
| 196 | + - name: Install dependencies for packaging and release |
| 197 | + run: | |
| 198 | + python -m pip install --upgrade pip |
| 199 | + pip install wheel |
| 200 | +
|
| 201 | + - name: Build Python package (source distribution) |
| 202 | + run: | |
| 203 | + python setup.py sdist |
| 204 | +
|
| 205 | + - name: Build Python package (binary distribution - wheel) |
| 206 | + run: | |
| 207 | + python setup.py bdist_wheel |
| 208 | +
|
| 209 | + - name: Upload 'pyVHDLParser' artifact |
| 210 | + uses: actions/upload-artifact@v2 |
| 211 | + with: |
| 212 | + name: ${{ env.ARTIFACT }} |
| 213 | + path: dist/ |
| 214 | + if-no-files-found: error |
| 215 | + retention-days: 1 |
| 216 | + |
| 217 | + PublishOnPyPI: |
| 218 | + name: Publish to PyPI |
| 219 | + runs-on: ubuntu-latest |
| 220 | + |
| 221 | + if: startsWith(github.ref, 'refs/tags') |
| 222 | + needs: |
| 223 | + - Package |
| 224 | + |
| 225 | + env: |
| 226 | + PYTHON: ${{ needs.Package.outputs.python }} |
| 227 | + ARTIFACT: ${{ needs.Package.outputs.artifact }} |
| 228 | + outputs: |
| 229 | + python: ${{ env.PYTHON }} |
| 230 | + artifact: ${{ env.ARTIFACT }} |
| 231 | + |
| 232 | + steps: |
| 233 | + - name: Download artifacts '${{ env.ARTIFACT }}' from 'Package' job |
| 234 | + uses: actions/download-artifact@v2 |
| 235 | + with: |
| 236 | + name: ${{ env.ARTIFACT }} |
| 237 | + path: dist/ |
| 238 | + |
| 239 | + - name: Setup Python ${{ env.PYTHON }} |
| 240 | + uses: actions/setup-python@v2 |
| 241 | + with: |
| 242 | + python-version: ${{ env.PYTHON }} |
| 243 | + |
| 244 | + - name: Install dependencies for packaging and release |
| 245 | + run: | |
| 246 | + python -m pip install --upgrade pip |
| 247 | + pip install wheel twine |
| 248 | +
|
| 249 | + - name: Release Python package to PyPI |
| 250 | + env: |
| 251 | + TWINE_USERNAME: __token__ |
| 252 | + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 253 | + run: | |
| 254 | + twine upload dist/* |
| 255 | +
|
| 256 | + PublishOnGitHub: |
| 257 | + name: Publish to GitHub |
| 258 | + runs-on: ubuntu-latest |
| 259 | + |
| 260 | + if: startsWith(github.ref, 'refs/tags') |
| 261 | + needs: |
| 262 | + - Package |
| 263 | + - Release |
| 264 | + |
| 265 | + env: |
| 266 | + PYTHON: ${{ needs.Package.outputs.python }} |
| 267 | + ARTIFACT: ${{ needs.Package.outputs.artifact }} |
| 268 | + outputs: |
| 269 | + python: ${{ env.PYTHON }} |
| 270 | + artifact: ${{ env.ARTIFACT }} |
| 271 | + |
| 272 | + steps: |
| 273 | + - name: Download artifacts from 'Package' job |
| 274 | + uses: actions/download-artifact@v2 |
| 275 | + with: |
| 276 | + name: ${{ env.ARTIFACT }} |
| 277 | + path: dist/ |
| 278 | + |
| 279 | + - name: Upload wheel as Release Asset |
| 280 | + uses: actions/upload-release-asset@v1 |
| 281 | + env: |
| 282 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 283 | + with: |
| 284 | + upload_url: ${{ needs.Release.outputs.upload_url }} |
| 285 | + asset_path: dist/pyVHDLParser-${{ needs.Release.outputs.version }}-py3-none-any.whl |
| 286 | + asset_name: pyVHDLParser-${{ needs.Release.outputs.version }}-py3-none-any.whl |
| 287 | + asset_content_type: application/x-wheel+zip |
| 288 | + |
| 289 | + ArtifactCleanUp: |
| 290 | + name: Artifact Cleanup |
| 291 | + runs-on: ubuntu-latest |
| 292 | + |
| 293 | + needs: |
| 294 | + - Package |
| 295 | + - PublishOnPyPI |
| 296 | + - PublishOnGitHub |
| 297 | + |
| 298 | + env: |
| 299 | + ARTIFACT: ${{ needs.Package.outputs.artifact }} |
| 300 | + |
| 301 | + steps: |
| 302 | + - name: Delete all Artifacts |
| 303 | + uses: geekyeggo/delete-artifact@v1 |
| 304 | + with: |
| 305 | + name: | |
| 306 | + ${{ env.ARTIFACT }} |
| 307 | +
|
| 308 | +# TriggerNext: |
| 309 | +# name: Trigger next Workflows |
| 310 | +# needs: [ UnitTesting, Coverage ] |
| 311 | +# runs-on: ubuntu-latest |
| 312 | +# env: |
| 313 | +# PYTHON: 3.9 |
| 314 | +# steps: |
| 315 | +# - name: Trigger Release Workflow |
| 316 | +# if: startsWith(github.ref, 'refs/tags') |
| 317 | +# uses: peter-evans/repository-dispatch@v1 |
| 318 | +# with: |
| 319 | +# token: ${{ secrets.TRIGGER_TOKEN_2 }} |
| 320 | +## repository: vhdl/pyVHDLModel |
| 321 | +# event-type: doRelease |
| 322 | +# client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "PYTHON": "${{ env.PYTHON }}"}' |
0 commit comments