Skip to content

Commit

Permalink
Merge branch 'BerkhanBerkdemir-implement-actions-ci-pipeline'
Browse files Browse the repository at this point in the history
  • Loading branch information
drybjed committed Oct 11, 2024
2 parents cba4b89 + e338f07 commit 9dd7989
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 30 deletions.
117 changes: 98 additions & 19 deletions .github/workflows/debops-ci-pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,64 @@
---
# Copyright (C) 2021 Maciej Delmanowski <[email protected]>
# Copyright (C) 2021 DebOps <https://debops.org/>
# Copyright (C) 2023 Berkhan Berkdemir <[email protected]>
# Copyright (C) 2021-2024 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-or-later

# TODO: The CI pipeline is not finished yet, it needs more work around
# preparing the environment and Ansible configuration for execution.

name: DebOps CI pipeline
on: [ 'workflow_dispatch' ]
name: 'DebOps CI Pipeline'
on: [ 'push', 'pull_request' ]

jobs:
bootstrap_playbook:
runs-on: 'ubuntu-latest'
steps:

- name: Checkout code
uses: actions/checkout@v4

- name: Prepare the CI pipeline environment
uses: './.github/workflows/prepare-ci-pipeline'

- name: Apply the playbook on the host
env:
PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1
run: |
source venv/bin/activate
cd ~/src/controller
debops run bootstrap --diff
debops run bootstrap --diff
common_playbook:
runs-on: 'ubuntu-latest'
steps:

- name: Checkout code
uses: actions/checkout@v4

- name: Prepare the CI pipeline environment
uses: './.github/workflows/prepare-ci-pipeline'

- name: Apply the playbook on the host
env:
PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1
run: |
source venv/bin/activate
cd ~/src/controller
debops run common --diff
debops run common --diff
apt_role:
runs-on: 'ubuntu-latest'
steps:

- name: Check out the repository
uses: 'actions/checkout@v3'
- name: Checkout code
uses: actions/checkout@v4

- name: Prepare the CI pipeline environment
uses: './.github/workflows/prepare-ci-pipeline'
Expand All @@ -25,6 +68,7 @@ jobs:
PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1
run: |
source venv/bin/activate
cd ~/src/controller
debops run service/apt --diff
debops run service/apt --diff
Expand All @@ -34,8 +78,8 @@ jobs:
runs-on: 'ubuntu-latest'
steps:

- name: Check out the repository
uses: 'actions/checkout@v3'
- name: Checkout code
uses: actions/checkout@v4

- name: Prepare the CI pipeline environment
uses: './.github/workflows/prepare-ci-pipeline'
Expand All @@ -45,17 +89,18 @@ jobs:
PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1
run: |
source venv/bin/activate
cd ~/src/controller
debops run service/apt_listchanges --diff
debops run service/apt_listchanges --diff
python_role:
mariadb_server_role:
runs-on: 'ubuntu-latest'
steps:

- name: Check out the repository
uses: 'actions/checkout@v3'
- name: Checkout code
uses: actions/checkout@v4

- name: Prepare the CI pipeline environment
uses: './.github/workflows/prepare-ci-pipeline'
Expand All @@ -65,27 +110,61 @@ jobs:
PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1
run: |
source venv/bin/activate
cd ~/src/controller
printf "[debops_service_python]\nlocalhost\n" >> ansible/inventory/hosts
debops run service/python --diff
debops run service/python --diff
cat <<EOL >> ansible/inventory/hosts
[debops_service_mariadb_server]
localhost
EOL
debops run service/mariadb_server --diff
debops run service/mariadb_server --diff
common_playbook:
postgresql_server_role:
runs-on: 'ubuntu-latest'
steps:

- name: Check out the repository
uses: 'actions/checkout@v3'
- name: Checkout code
uses: actions/checkout@v4

- name: Prepare the CI pipeline environment
uses: './.github/workflows/prepare-ci-pipeline'

- name: Apply the playbook on the host
- name: Apply the role on the host
env:
PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1
run: |
source venv/bin/activate
cd ~/src/controller
debops common --diff
debops common --diff
cat <<EOL >> ansible/inventory/hosts
[debops_service_postgresql_server]
localhost
EOL
debops run service/postgresql_server --diff
debops run service/postgresql_server --diff
python_role:
runs-on: 'ubuntu-latest'
steps:

- name: Checkout code
uses: actions/checkout@v4

- name: Prepare the CI pipeline environment
uses: './.github/workflows/prepare-ci-pipeline'

- name: Apply the role on the host
env:
PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1
run: |
source venv/bin/activate
cd ~/src/controller
cat <<EOL >> ansible/inventory/hosts
[debops_service_python]
localhost
EOL
debops run service/python --diff
debops run service/python --diff
38 changes: 27 additions & 11 deletions .github/workflows/prepare-ci-pipeline/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
# Copyright (C) 2021 Maciej Delmanowski <[email protected]>
# Copyright (C) 2021 DebOps <https://debops.org/>
# Copyright (C) 2023 Berkhan Berkdemir <[email protected]>
# Copyright (C) 2021-2024 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-or-later

name: Prepare CI pipeline environment
Expand All @@ -12,16 +13,31 @@ runs:

- name: Add ~/.local/bin to $PATH
run: 'printf "%s/.local/bin\n" "${HOME}" >> ${GITHUB_PATH}'
shell: 'bash'
shell: bash

- name: Prepare test environment
- name: Install system dependencies
run: |
sudo apt-get -qq update
sudo apt-get remove --purge -yq ansible python python2.7 python2.7-minimal
pip3 install --user --upgrade pip wheel "setuptools==65.7.0"
pip3 install --user --upgrade Jinja2 ansible
pip3 install --user .
debops-init ~/src/controller
printf "[debops_all_hosts]\nlocalhost ansible_connection=local\n" \
>> ~/src/controller/ansible/inventory/hosts
shell: 'bash'
sudo apt-get install build-essential python3-dev libffi-dev libssl-dev \
libsasl2-dev libldap2-dev libpq-dev python3-pip python3-psycopg2
shell: bash

- name: Configure VirtualEnv and install Python dependencies
run: |
python3 -m venv venv
source venv/bin/activate
pip install wheel "setuptools==65.7.0"
pip install -r requirements-integration.txt
pip install .
shell: bash

- name: Initialize DebOps project
run: |
source venv/bin/activate
debops project init ~/src/controller
cd ~/src/controller
cat <<EOL >> ansible/inventory/hosts
[debops_all_hosts]
localhost ansible_connection=local
EOL
shell: bash
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ General
:file:`~/.ssh/authorized_keys` files correctly using optional ``follow``
parameter.

- The DebOps CI pipeline in GitHub Actions is improved and will be executed on
pull requests and pushes to test changes before merging them.

:ref:`debops.gitlab_runner` role
''''''''''''''''''''''''''''''''

Expand Down
28 changes: 28 additions & 0 deletions requirements-integration.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (C) 2023 Berkhan Berkdemir <[email protected]>
# Copyright (C) 2024 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-or-later

# List of Python packages used by GitHub CI pipeline for continuous integration

ansible==8.0.0a1
ansible-core==2.15.0b2
cffi==1.16.0
cryptography==41.0.5
distro==1.8.0
dnspython==2.4.2
future==0.18.3
Jinja2==3.1.2
MarkupSafe==2.1.3
netaddr==0.9.0
packaging==23.2
passlib==1.7.4
pyasn1==0.5.0
pyasn1-modules==0.3.0
pycparser==2.21
pyOpenSSL==23.2.0
python-dotenv==1.0.0
python-ldap==3.4.3
pyxdg==0.28
PyYAML==6.0.1
resolvelib==0.8.1
toml==0.10.2

0 comments on commit 9dd7989

Please sign in to comment.