Skip to content

Merge branch 'staging-dummy' of https://github.com/EdgePi-Cloud/edgep… #43

Merge branch 'staging-dummy' of https://github.com/EdgePi-Cloud/edgep…

Merge branch 'staging-dummy' of https://github.com/EdgePi-Cloud/edgep… #43

# This workflow will increment version patch number, cherry pick this new version to dev,
# and build and publish the package to TestPyPI upon push or merge to staging branch
name: Staging Dummy Publish
on:
push:
branches:
- 'staging-dummy'
# needed to stop endless commit loop by auto-bump
paths-ignore:
- setup.py
- .bumpversion.cfg
jobs:
publish:
name: Staging Publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
# cut assumes version number is surrounded by double-quotes.
- name: Get Original Version
run: echo "original_version=$(grep "version" setup.py | cut -d '"' -f2)" >> $GITHUB_ENV
- name: Auto Bump Package Version
uses: FragileTech/bump-version@main
with:
current_version: "${{ env.original_version }}"
files: setup.py
part: patch
commit_name: bot-edgepi
commit_email: bot@edgepi.com
login: bot-edgepi
token: "${{ secrets.ACTIONS_BOT_TOKEN }}"
- name: Get Current Version
run: echo "current_version=$(grep "version" setup.py | cut -d '"' -f2)" >> $GITHUB_ENV
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements_build.txt ]; then python -m pip install -r requirements_build.txt; fi
- name: Build Package
run: |
python -m build
- name: Publish Distribution to TestPyPI
uses: pypa/gh-action-pypi-publish@v1.9.0
with:
verbose: true
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Handling Failure Delete tag
if: failure()
env:
commit_name: bot-edgepi
commit_email: bot@edgepi.com
login: bot-edgepi
token: "${{ secrets.ACTIONS_BOT_TOKEN }}"
run: |
set -x
# Setup Git env and user
git config user.name ${{ env.commit_name }}
git config user.email ${{ env.commit_email }}
git config --global pull.rebase false
BRANCH=${GITHUB_REF#refs/heads/}
git pull --no-edit ${{ env.login }} $BRANCH
git config --global url."https://${{ env.login }}:${{ env.token }}@github.com/".insteadOf "https://github.com/"
# merge done by git pull does not update submodules changed in $BRANCH
git submodule update --init --recursive
# Delete Git tags
git tag -d rc/v${{ env.current_version }}
git push origin --delete rc/v${{ env.current_version }}
git config --global --unset url."https://${{ env.login }}:${{ env.token }}@github.com/".insteadOf
# Decrementing the current version number, this may be needed later.
# my_var=$(echo $(grep "version" setup.py | cut -d '"' -f2 | cut -d '.' -f3))
# my_var=$(echo $((my_var-1)))
# Write the reverted version number back to setup file and
# sed -i "s/\(version=\"[0-9]\+\.[0-9]\+\.\)[0-9]\+\"/\1$my_var\"/" setup.py
# sed -i "s/\(current_version = [0-9]\+\.[0-9]\+\.\)[0-9]\+/\1$my_var/" .bumpversion.cfg
# git add . && git commit -m "Failed Publish Job --- decremented version" && git push
Hardware_Test:
needs: publish
name: Hardware Tests
runs-on: ubuntu-latest
runs-on: [self-hosted, linux, ARM64, integration]

Check failure on line 92 in .github/workflows/build-and-publish-TestPyPI-dummy.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build-and-publish-TestPyPI-dummy.yml

Invalid workflow file

You have an error in your yaml syntax on line 92
strategy:
fail-fast: false
matrix:
python-version: ["3.9"]
steps:
# Wait for 1 minutes for TestPyPI to be updated
- name: Sleep for 1 minute
run: sleep 60s
shell: bash
- name: Checkout
uses: actions/checkout@v3
with:
ref: staging-dummy
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
fetch-depth: 0
- name: Install Dependencies and check SDK versions
run: |
python -m venv venv_hardware_test
source venv_hardware_test/bin/activate
python -m pip install --upgrade pip
python -m pip install pytest
if [ -f requirements_hw_test.txt ]; then pip install -r requirements_hw_test.txt; fi
echo "actual_sdk_version=$(pip list | grep edgepi | cut -d ' ' -f2)" >> $GITHUB_ENV
echo "expected_sdk_version=$(grep "version" setup.py | cut -d '"' -f2)" >> $GITHUB_ENV
- name: Compare versions
run: |
if [ ${{env.expected_sdk_version}} != ${{env.actual_sdk_version}} ]; then
echo "SDK Version Mismatch"
exit 1
fi
- name: Test with pytest
run: |
source venv_hardware_test/bin/activate
python -m pytest ./tests/hardware_tests
- name: Handling Failure Delete tag
if: failure()
env:
commit_name: bot-edgepi
commit_email: bot@edgepi.com
login: bot-edgepi
token: "${{ secrets.ACTIONS_BOT_TOKEN }}"
run: |
set -x
# Setup Git env and user
git config user.name ${{ env.commit_name }}
git config user.email ${{ env.commit_email }}
git config --global pull.rebase false
BRANCH=${GITHUB_REF#refs/heads/}
git remote add ${{ env.login }} https://${{ env.login }}:${{ env.token }}@github.com/$GITHUB_REPOSITORY
git pull --no-edit ${{ env.login }} $BRANCH
git config --global url."https://${{ env.login }}:${{ env.token }}@github.com/".insteadOf "https://github.com/"
# merge done by git pull does not update submodules changed in $BRANCH
git submodule update --init --recursive
# Delete Git tags
git tag -d rc/v${{ env.expected_sdk_version }}
git push origin --delete rc/v${{ env.expected_sdk_version }}
git config --global --unset url."https://${{ env.login }}:${{ env.token }}@github.com/".insteadOf
Bump_version_on_dev:
name: Bump version numbers in Dev
needs: Hardware_Test
runs-on: ubuntu-latest
steps:
- name: Checkout Dev
uses: actions/checkout@v3
with:
ref: dev-dummy
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
fetch-depth: 0
- name: Auto Bump Commit SHA
run: |
echo "bump_commit=$(git log -n 1 origin/staging-dummy --pretty=format:'%H')" >> $GITHUB_ENV
- name: Cherry Pick
env:
commit_name: bot-edgepi
commit_email: bot@edgepi.com
run: |
echo ${{ env.bump_commit }}
git config user.name ${{ env.commit_name }}
git config user.email ${{ env.commit_email }}
git cherry-pick ${{ env.bump_commit }}
git push origin dev-dummy