-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: improve efficiency and add auto unit testing
- Loading branch information
Showing
3 changed files
with
80 additions
and
7 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,34 +4,55 @@ on: | |
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'setup.py' | ||
pull_request: | ||
branches: | ||
- "main" | ||
paths: | ||
- 'setup.py' | ||
|
||
jobs: | ||
release: | ||
check-version-changed: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version_changed: ${{ steps.version-change.outputs.version_changed }} | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: Check if version changed | ||
id: version-change | ||
run: | | ||
VERSION_CHANGE=$(git diff HEAD^ HEAD -- setup.py | grep -e "^+.*version.*=" -e "^-.*version.*=" | wc -l) | ||
if [ "$VERSION_CHANGE" -eq 0 ]; then | ||
echo "Version not changed" | ||
echo "::set-output name=version_changed::false" | ||
else | ||
echo "Version changed" | ||
echo "::set-output name=version_changed::true" | ||
fi | ||
release: | ||
needs: check-version-changed | ||
if: needs.check-version-changed.outputs.version_changed == 'true' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Extract Version from setup.py | ||
id: get_version | ||
run: | | ||
echo "::set-output name=VERSION::$(python setup.py --version)" | ||
- name: Create and Push Tag | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git tag v${{ steps.get_version.outputs.VERSION }} | ||
git push origin v${{ steps.get_version.outputs.VERSION }} | ||
- name: Create GitHub Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Run Unit Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- "main" | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Run Unit Tests | ||
run: | | ||
python -m unittest discover tests |