Skip to content

Commit ecafed3

Browse files
authored
new staging workflow (#435)
* new staging workflow separted into 3 jobs - bump version, build and publish the test package - delete the tag when fails - install published test package, perform hardware test - delete the tag when fails - cherrypick the bumped version to dev * Update .pylintrc * Update build-and-publish-TestPyPI.yml added comment explaining newly added job
1 parent 10b7c90 commit ecafed3

File tree

4 files changed

+114
-31
lines changed

4 files changed

+114
-31
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[bumpversion]
22
tag_name = rc/v{new_version}
3-
current_version = 1.2.21
3+
current_version = 1.2.27

.github/workflows/build-and-publish-TestPyPI.yml

Lines changed: 111 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,20 @@ jobs:
2222
with:
2323
persist-credentials: false
2424
# cut assumes version number is surrounded by double-quotes.
25-
- name: Get Current Version
26-
run: echo "current_version=$(grep "version" setup.py | cut -d '"' -f2)" >> $GITHUB_ENV
25+
- name: Get Original Version
26+
run: echo "original_version=$(grep "version" setup.py | cut -d '"' -f2)" >> $GITHUB_ENV
2727
- name: Auto Bump Package Version
2828
uses: FragileTech/bump-version@main
2929
with:
30-
current_version: "${{ env.current_version }}"
30+
current_version: "${{ env.original_version }}"
3131
files: setup.py
3232
part: patch
3333
commit_name: bot-edgepi
3434
commit_email: bot@edgepi.com
3535
login: bot-edgepi
3636
token: "${{ secrets.ACTIONS_BOT_TOKEN }}"
37+
- name: Get Current Version
38+
run: echo "current_version=$(grep "version" setup.py | cut -d '"' -f2)" >> $GITHUB_ENV
3739
- name: Set up Python
3840
uses: actions/setup-python@v3
3941
with:
@@ -48,8 +50,113 @@ jobs:
4850
- name: Publish Distribution to TestPyPI
4951
uses: pypa/gh-action-pypi-publish@v1.9.0
5052
with:
53+
verbose: true
5154
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
5255
repository_url: https://test.pypi.org/legacy/
56+
# Handling Failure Delete Tag: this step only gets executed when there's a failed step.
57+
# When the job finishes with failed step, the tag created from bump version acrtion gets deleted
58+
- name: Handling Failure Delete tag
59+
if: failure()
60+
env:
61+
commit_name: bot-edgepi
62+
commit_email: bot@edgepi.com
63+
login: bot-edgepi
64+
token: "${{ secrets.ACTIONS_BOT_TOKEN }}"
65+
run: |
66+
set -x
67+
# Setup Git env and user
68+
git config user.name ${{ env.commit_name }}
69+
git config user.email ${{ env.commit_email }}
70+
git config --global pull.rebase false
71+
BRANCH=${GITHUB_REF#refs/heads/}
72+
git pull --no-edit ${{ env.login }} $BRANCH
73+
git config --global url."https://${{ env.login }}:${{ env.token }}@github.com/".insteadOf "https://github.com/"
74+
# merge done by git pull does not update submodules changed in $BRANCH
75+
git submodule update --init --recursive
76+
77+
# Delete Git tags
78+
git tag -d rc/v${{ env.current_version }}
79+
git push origin --delete rc/v${{ env.current_version }}
80+
git config --global --unset url."https://${{ env.login }}:${{ env.token }}@github.com/".insteadOf
81+
82+
# Decrementing the current version number, this may be needed later.
83+
# my_var=$(echo $(grep "version" setup.py | cut -d '"' -f2 | cut -d '.' -f3))
84+
# my_var=$(echo $((my_var-1)))
85+
# Write the reverted version number back to setup file and
86+
# sed -i "s/\(version=\"[0-9]\+\.[0-9]\+\.\)[0-9]\+\"/\1$my_var\"/" setup.py
87+
# sed -i "s/\(current_version = [0-9]\+\.[0-9]\+\.\)[0-9]\+/\1$my_var/" .bumpversion.cfg
88+
# git add . && git commit -m "Failed Publish Job --- decremented version" && git push
89+
90+
Hardware_Test:
91+
needs: publish
92+
name: Hardware Tests
93+
runs-on: [self-hosted, linux, ARM64, integration]
94+
strategy:
95+
fail-fast: false
96+
matrix:
97+
python-version: ["3.9"]
98+
steps:
99+
# Wait for 1 minutes for TestPyPI to be updated
100+
- name: Sleep for 1 minute
101+
run: sleep 60s
102+
shell: bash
103+
- name: Checkout
104+
uses: actions/checkout@v3
105+
with:
106+
ref: staging
107+
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
108+
fetch-depth: 0
109+
- name: Install Dependencies and check SDK versions
110+
run: |
111+
python -m venv venv_hardware_test
112+
source venv_hardware_test/bin/activate
113+
python -m pip install --upgrade pip
114+
python -m pip install pytest
115+
if [ -f requirements_hw_test.txt ]; then pip install -r requirements_hw_test.txt; fi
116+
echo "actual_sdk_version=$(pip list | grep edgepi | cut -d ' ' -f2)" >> $GITHUB_ENV
117+
echo "expected_sdk_version=$(grep "version" setup.py | cut -d '"' -f2)" >> $GITHUB_ENV
118+
- name: Compare versions
119+
run: |
120+
if [ ${{env.expected_sdk_version}} != ${{env.actual_sdk_version}} ]; then
121+
echo "SDK Version Mismatch"
122+
exit 1
123+
fi
124+
- name: Test with pytest
125+
run: |
126+
source venv_hardware_test/bin/activate
127+
python -m pytest ./tests/hardware_tests
128+
# Handling Failure Delete Tag: this step only gets executed when there's a failed step.
129+
# When the job finishes with failed step, the tag created from bump version acrtion gets deleted
130+
- name: Handling Failure Delete tag
131+
if: failure()
132+
env:
133+
commit_name: bot-edgepi
134+
commit_email: bot@edgepi.com
135+
login: bot-edgepi
136+
token: "${{ secrets.ACTIONS_BOT_TOKEN }}"
137+
run: |
138+
set -x
139+
# Setup Git env and user
140+
git config user.name ${{ env.commit_name }}
141+
git config user.email ${{ env.commit_email }}
142+
git config --global pull.rebase false
143+
BRANCH=${GITHUB_REF#refs/heads/}
144+
git remote add ${{ env.login }} https://${{ env.login }}:${{ env.token }}@github.com/$GITHUB_REPOSITORY
145+
git pull --no-edit ${{ env.login }} $BRANCH
146+
git config --global url."https://${{ env.login }}:${{ env.token }}@github.com/".insteadOf "https://github.com/"
147+
# merge done by git pull does not update submodules changed in $BRANCH
148+
git submodule update --init --recursive
149+
150+
# Delete Git tags
151+
git tag -d rc/v${{ env.expected_sdk_version }}
152+
git push origin --delete rc/v${{ env.expected_sdk_version }}
153+
git config --global --unset url."https://${{ env.login }}:${{ env.token }}@github.com/".insteadOf
154+
155+
Bump_version_on_dev:
156+
name: Bump version numbers in Dev
157+
needs: Hardware_Test
158+
runs-on: ubuntu-latest
159+
steps:
53160
- name: Checkout Dev
54161
uses: actions/checkout@v3
55162
with:
@@ -68,29 +175,4 @@ jobs:
68175
git config user.name ${{ env.commit_name }}
69176
git config user.email ${{ env.commit_email }}
70177
git cherry-pick ${{ env.bump_commit }}
71-
git push origin dev
72-
73-
74-
# Hardware_Test:
75-
# needs: publish
76-
# name: Hardware Tests
77-
# runs-on: [self-hosted, linux, ARM64, hw-test]
78-
# strategy:
79-
# fail-fast: false
80-
# matrix:
81-
# python-version: ["3.9"]
82-
83-
# steps:
84-
# - name: Checkout
85-
# uses: actions/checkout@v3
86-
# - name: Install Dependencies
87-
# run: |
88-
# python -m venv venv_hardware_test
89-
# source venv_hardware_test/bin/activate
90-
# python -m pip install --upgrade pip
91-
# python -m pip install pytest
92-
# if [ -f requirements_hw_test.txt ]; then pip install -r requirements_hw_test.txt; fi
93-
# - name: Test with pytest
94-
# run: |
95-
# source venv_hardware_test/bin/activate
96-
# python -m pytest ./tests/hardware_tests
178+
git push origin dev

.pylintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ disable=logging-fstring-interpolation,
88
duplicate-code,
99
no-else-return,
1010
no-else-raise,
11+
too-many-positional-arguments,
1112
logging-fstring-interpolation
1213

1314
[LOGGING]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setuptools.setup(
99
name="edgepi-python-sdk",
10-
version="1.2.21",
10+
version="1.2.27",
1111
author="S.Park",
1212
author_email="spark@osensa.com",
1313
description="EdgePi Python SDK package",

0 commit comments

Comments
 (0)