improve documentation from review remark #148
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build python package | |
on: | |
pull_request: # Apply to all pull requests | |
push: # Apply to all branches | |
env: | |
PYTHON_VERSION: 3.8 | |
PIP_VERSION: 22.0.4 | |
WHEEL_VERSION: 0.37.0 | |
HTML_TEST_RUNNER_VERSION: 1.2.1 | |
RELEASE_VERSION: 0 | |
jobs: | |
build-python: | |
runs-on: ubuntu-latest | |
steps: | |
# Run `git checkout` | |
- uses: actions/checkout@v4 | |
- name: Source dependency versions | |
working-directory: config | |
run: | | |
cat versions.txt >> $GITHUB_ENV | |
- name: Detect release version | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: | | |
echo RELEASE_VERSION=1 >> $GITHUB_ENV | |
- name: Install Protoc | |
run: | | |
sudo apt-get update && apt-get install -y apt-utils && apt-get install -y unzip | |
mkdir ${{ runner.temp }}/protoc_install | |
wget https://github.com/protocolbuffers/protobuf/releases/download/v${{ env.COMMON_PROTOC_VERSION }}/protoc-${{ env.COMMON_PROTOC_VERSION }}-linux-x86_64.zip -P ${{ runner.temp }}/protoc_install | |
unzip ${{ runner.temp }}/protoc_install/*.zip -d ${{ runner.temp }}/protoc_install/protoc | |
echo "${{ runner.temp }}/protoc_install/protoc/bin" >> $GITHUB_PATH | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install python dependencies | |
run: python -m pip install --no-cache-dir --upgrade pip==${PIP_VERSION} wheel==${WHEEL_VERSION} | |
- name: Protobuf compile | |
working-directory: ./python | |
run: ./build_protobuf.sh | |
- name: build wheel | |
working-directory: ./python | |
run: python setup.py sdist bdist_wheel | |
- name: Archive wheel | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist | |
path: python/dist | |
retention-days: 1 | |
run-tests-python: | |
runs-on: ubuntu-latest | |
needs: build-python | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Download t2iapi wheel artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
- name: Install t2iapi package | |
run: python -m pip install t2iapi*.whl | |
- name: pip freeze | |
run: python -m pip freeze --no-cache-dir > pip_freeze.txt | |
- name: install html test runner | |
run: python -m pip install html-testRunner==${HTML_TEST_RUNNER_VERSION} | |
- name: run unit tests | |
run: python ./tests/python/html_report.py | |
- name: Archive freeze information | |
uses: actions/upload-artifact@v4 | |
with: | |
name: freeze | |
path: pip_freeze.txt | |
retention-days: 1 | |
- name: Archive test results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: html_unit_test | |
path: unittest_results/*.html | |
retention-days: 1 | |
deploy-pypi-packages: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') | |
needs: run-tests-python | |
permissions: | |
contents: write | |
steps: | |
- name: Download t2iapi wheel artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist/ | |
- name: Download t2iapi test results artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: html_unit_test | |
path: unittest_results/ | |
- name: Download pip freeze | |
uses: actions/download-artifact@v4 | |
with: | |
name: freeze | |
path: freeze/ | |
- name: Publish t2iapi to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
- name: Attach artifacts to github release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
dist/*.whl | |
freeze/pip_freeze.txt | |
unittest_results/*.html | |
prerelease: ${{ !startsWith(github.ref, 'refs/tags/v') }} |