Version control - initial #18
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: 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: 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 | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git commit -am "Bump version to $NEW_VERSION" | |
git tag -a v$NEW_VERSION -m "Release $NEW_VERSION" | |
git push origin HEAD --tags | |
- name: Run tests | |
run: pytest -v | |
- 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 |