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