Skip to content

Reordering bump - test - push #20

Reordering bump - test - push

Reordering bump - test - push #20

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches:
- master
- dev
jobs:
test:
runs-on: ubuntu-latest
services:
redis:
image: redis:alpine
ports:
- 6379:6379
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install flake8 black bandit mypy types-requests
- name: Run tests before version bump
run: pytest -v
- name: Calculate and update version
id: version
run: |
VERSION=$(grep -Po '(?<=VERSION = ")[^"]*' app.py)
if [ "${{ github.ref }}" == "refs/heads/master" ]; then
NEW_VERSION=$(python -c "major, minor, patch = map(int, '$VERSION'.split('.')); patch += 1; print(f'{major}.{minor}.{patch}')")
else
NEW_VERSION=$(python -c "major, minor, patch = map(int, '$VERSION'.split('.')); patch += 1; print(f'{major}.{minor}.{patch}-dev')")
fi
sed -i "s/VERSION = .*/VERSION = \"$NEW_VERSION\"/" app.py
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
- name: Commit version change
if: success()
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git add app.py
git commit -m "Bump version to $NEW_VERSION"
git tag -a v$NEW_VERSION -m "Release $NEW_VERSION"
git push origin HEAD --tags
- name: Run Flake8
run: flake8 .
- name: Run Black
run: black --check .
- name: Run Bandit
run: bandit -r . --severity-level medium
- name: Run mypy
run: mypy app.py app_test.py