Skip to content

Commit

Permalink
Finishing CICD for GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ldynia authored and ldynia committed May 5, 2021
1 parent a71b7ce commit 7ca14c5
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 215 deletions.
107 changes: 0 additions & 107 deletions .github/workflows/ci.yaml

This file was deleted.

149 changes: 145 additions & 4 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,153 @@
name: WIP
name: Continuous Integration & Delivery
on:
pull_request:
branches: [ master ]
workflow_dispatch:
branches: [ master, actions ]
jobs:
demo:
test:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- python: 3.6
django: 2.2
toxenv: py36-django22
- python: 3.6
django: 3.0
toxenv: py36-django30
- python: 3.7
django: 2.2
toxenv: py37-django22
- python: 3.7
django: 3.0
toxenv: py37-django30
- python: 3.8
django: 2.2
toxenv: py38-django22
- python: 3.8
django: 3.0
toxenv: py38-django30
- python: 3.9
django: 2.2
toxenv: py39-django22
- python: 3.9
django: 3.0
toxenv: py39-django30
steps:
- uses: actions/checkout@v2
- name: Run a one-line script
- uses: actions/setup-python@v1
name: Set up Python ${{ matrix.python }} ${{ matrix.django }}
with:
python-version: ${{ matrix.python }}
- name: Install pip packages
run: |
echo Hello, world 1!
pip install pip --upgrade
pip install codecov poetry tox
- name: "Run tox - testenv: ${{ matrix.toxenv }}"
env:
DJANGO: ${{ matrix.django }}
TOXENV: ${{ matrix.toxenv }}
run: tox
- name: Run notification script
env:
GITHUB_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
GITHUB_JOB_STATUS: ${{ job.status }}
GITHUB_RUN_URL: ${{ github.event.repository.url }}/actions/runs/${{ github.run_id }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
run: ./scripts/notification.sh

quality:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- python: 3.6
toxenv: quality
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
name: Set up Python ${{ matrix.python }}
with:
python-version: ${{ matrix.python }}
- name: Install pip packages
run: |
pip install pip --upgrade
pip install poetry tox
- name: "Run tox - testenv: ${{ matrix.toxenv }}"
env:
TOXENV: ${{ matrix.toxenv }}
run: tox

security:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- python: 3.6
toxenv: security
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
name: Set up Python ${{ matrix.python }}
with:
python-version: ${{ matrix.python }}
- name: Install pip packages
run: |
pip install pip --upgrade
pip install poetry tox
- name: "Run tox - testenv: ${{ matrix.toxenv }}"
env:
TOXENV: ${{ matrix.toxenv }}
run: tox

# # AUTHOR: Lukasz Dynowski
# # TODO: Uncomment this code only if we agreed for Continuous Delivery.
# # TODO: Update PYPI envars to production values!
# publish:
# needs:
# - test
# - security
# - quality
# runs-on: ubuntu-latest
# strategy:
# matrix:
# include:
# - python: 3.6
# toxenv: build
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-python@v1
# name: Set up Python ${{ matrix.python }}
# with:
# python-version: ${{ matrix.python }}
# - name: Install pip packages
# run: |
# pip install pip --upgrade
# pip install poetry tox
# - name: Bump package version
# run: ./scripts/bump.py --dry-run no
# - name: "Build package - testenv: ${{ matrix.toxenv }}"
# env:
# TOXENV: ${{ matrix.toxenv }}
# run: tox
# - name: "Publish - testenv: ${{ matrix.toxenv }}"
# env:
# PYPI_ACCESS_TOKEN: ${{ secrets.PYPI_ACCESS_TOKEN }}
# # Values production 'https://pypi.org/', testing 'https://test.pypi.org/legacy/'
# PYPI_REPOSITORY_URL: https://test.pypi.org/legacy/
# # Values production 'pypi', testing 'testpypi'
# PYPI_REPOSITORY: testpypi
# PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
# run: |
# poetry config repositories.$PYPI_REPOSITORY $PYPI_REPOSITORY_URL
# poetry config pypi-token.$PYPI_REPOSITORY $PYPI_ACCESS_TOKEN
# poetry publish -r $PYPI_REPOSITORY -u $PYPI_USERNAME
# - name: Create bump commit
# uses: EndBug/add-and-commit@latest
# with:
# author_name: github_actions
# author_email: github_actions
# message: PR Auto bumping package version
# add: pyproject.toml
46 changes: 0 additions & 46 deletions .travis.yml

This file was deleted.

18 changes: 2 additions & 16 deletions scripts/bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,7 @@ def get_args():
help="Patch version bump. Empty flag will auto bump current version.",
)
parser.add_argument(
"--update",
type=str,
default="yes",
choices=["yes", "no"],
help="Make update to config file.",
)
parser.add_argument(
"--dry-run",
type=str,
default="yes",
choices=["yes", "no"],
help="Print versions.",
"--dry-run", type=str, default="yes", choices=["yes", "no"], help="Dry run"
)

return parser.parse_args()
Expand Down Expand Up @@ -132,10 +121,7 @@ def bump_version(major, minor, patch):
if args.dry_run == "yes":
print(f"Current version: {CURRENT_VERSION}")
print(f"New version: {NEW_VERSION}")
exit(0)

# Update package version
if args.update == "yes":
else:
with open(pyproject_file_path, "r") as file:
content = file.read()

Expand Down
4 changes: 0 additions & 4 deletions scripts/notification.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/bin/sh

# TODO: Update/missing GitHub Actions environment variables with TELEGRAM_TOKEN
# TODO: Update/missing GitHub Actions environment variables with TELEGRAM_CHAT_ID
# TODO: Once this script is working file `travis_telegram_notification.sh` should be deleted!

# Get the token from Travis environment vars and build the bot URL:
BOT_URL="https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage"

Expand Down
37 changes: 0 additions & 37 deletions scripts/travis_telegram_notification.sh

This file was deleted.

Loading

0 comments on commit 7ca14c5

Please sign in to comment.