diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..e4ba1fe --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,49 @@ +name: Deploy Pages + +on: + push: + branches: + - main # Trigger the workflow only on pushes to the main branch + +jobs: + documents: + strategy: + max-parallel: 4 + matrix: + python-version: [ '3.11' ] + + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip build + python -m pip install -r requirements.txt + + - name: Set up Git + run: | + git config user.name "${{ github.repository_owner }}" + git config user.email "${{ secrets.GH_EMAIL }}" + git remote add gh-token "https://${{ secrets.PAT }}@github.com/ibrahimroshdy/continuous_integration.git" + git fetch gh-token + git checkout main # Ensure you are on the 'main' branch + git pull origin main + + - name: Fetch gh-pages branch + run: git fetch gh-token gh-pages:gh-pages + + - name: Deploy documents + run: python -m mkdocs gh-deploy -v --clean --remote-name gh-token + + - name: Push changes to gh-pages branch + run: git push gh-token gh-pages diff --git a/README.md b/README.md index 7abb6da..7769e92 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This project contains a `simple_loop.py` python file that prints a progress bar The aim of this project to serve a sample project for implementing GitHub's workflow using workflow files, and custom actions and multiple jobs. -### Folder Stucture +### Folder Structure ``` continuous_integration │ diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..7abb6da --- /dev/null +++ b/docs/index.md @@ -0,0 +1,72 @@ +# Continuous Integration +![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54) +[![Continuous Integration](https://github.com/ibrahimroshdy/continuous_integration/actions/workflows/ci_workflow.yml/badge.svg?branch=main)](https://github.com/ibrahimroshdy/continuous_integration/actions/workflows/ci_workflow.yml) +[![codecov](https://codecov.io/gh/ibrahimroshdy/continuous_integration/branch/main/graph/badge.svg?token=Y56VABDZA7)](https://codecov.io/gh/ibrahimroshdy/continuous_integration) + +## About +A sample project of adding continuous integration +to GitHub and utilising the GitHub actions, workflows and job settings. +This project contains a `simple_loop.py` python file that prints a progress bar of a for loop. +The aim of this project to serve a sample project for implementing GitHub's +workflow using workflow files, and custom actions and multiple jobs. + +### Folder Stucture +``` +continuous_integration +│ +├── README.md +├── .github # gitHub workflow directory +│ ├── actions # Custom actions directory +│ │ └── install-run-code # This project's Custom Action to be referred to by name in workflows +│ │ └── action.yml # Action instructions file [Must be named action] +│ └── workflows # This project's Workflows +│ └── ci_workflow.yml # Workflow instructions file +├── .gitignore +├── pyproject.toml +└── simple_loop.py +``` + + +### Getting Started + +There is no need to run the project locally, but in case it is needed here is the quick start instructions used. +Note: Those are the same instructions in `.github/workflows/ci_workflows.yml` and `.github/actions/install-run-code/actions.yml` + +Project is also setup for a Docker Multi-arch build for `arm64` and `amd64`. Read more about it in this [article](https://ibrahimroshdy.medium.com/how-to-build-your-docker-images-using-multi-arch-to-support-arm64-m1-macbook-6ebc42a47cd7). + +Create a virtualenv +```bash + virtualenv venv -p python3 +``` + +Activate your venv +```bash +source venv/bin/activate +``` + +Install poetry and pyfiglet using pip +```bash +pip install poetry pyfiglet +``` + +Run poetry install to install all needed python packages +```bash +poetry install +``` + +Run pyfiglet because you can +```bash +pyfiglet Continuous Integration +``` + +Finally, run code +```bash +python simple_loop.py +``` + +You should have something like that: + +```bash +This is a progress bar of the simple loop script +100%|███████| 1000000/1000000 [00:00<00:00, 4474649.76it/s] +``` diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..d1ef0a1 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,120 @@ +# mkdocs.yml - WitnessAI Documentation Configuration + +# Site Information +site_name: Continuous Integration +site_description: Continuous Integration with Github Actions and Docker Multi-Arch Buildx for amd64 and arm64. +site_author: ibrahimroshdy + +# Copyright Information +copyright: Copyright © 2024 Ibrahim Roshdy + +# Repository Information +repo_url: https://github.com/ibrahimroshdy/continuous_integration +repo_name: ir/continuous_integration + +# Edit Button Configuration +edit_uri: "" + +# Plugins Configuration +plugins: + - search + - mkdocstrings: + handlers: + python: + import: + - https://docs.python.org/3/objects.inv + - https://installer.readthedocs.io/en/stable/objects.inv # demonstration purpose in the docs + - https://mkdocstrings.github.io/autorefs/objects.inv + - https://docs.celeryproject.org/en/stable/objects.inv + paths: [ src ] + options: + # docstring_style: google + docstring_options: + ignore_init_summary: true + # docstring_section_style: list + filters: [ "!^_" ] + heading_level: 4 + inherited_members: true + merge_init_into_class: true + separate_signature: true + show_root_heading: true + show_root_full_path: true + show_signature_annotations: true + show_symbol_type_heading: true + show_symbol_type_toc: true + signature_crossrefs: true + summary: true + +# Theme Configuration +theme: + name: material + # logo: logo.png + # favicon: logo.png + icon: + repo: fontawesome/brands/github + features: + - announce.dismiss + - content.action.edit + - content.action.view + - content.code.annotate + - content.code.copy + # - content.code.select + # - content.tabs.link + - content.tooltips + # - header.autohide + # - navigation.expand + - navigation.footer + - navigation.indexes + # - navigation.instant + # - navigation.instant.prefetch + # - navigation.instant.progress + # - navigation.prune + - navigation.sections +# - navigation.tabs +# - navigation.tabs.sticky + # - navigation.top + - navigation.tracking + - search.highlight + - search.share + - search.suggest + - toc.follow + # - toc.integrate + palette: + - media: "(prefers-color-scheme)" + toggle: + icon: material/brightness-auto + name: Switch to light mode + - media: "(prefers-color-scheme: light)" + scheme: default + primary: green + accent: black + toggle: + icon: material/weather-sunny + name: Switch to dark mode + - media: "(prefers-color-scheme: dark)" + scheme: slate + primary: green + accent: black + toggle: + icon: material/weather-night + name: Switch to system preference + + +# Navigation Configuration +nav: + - Index: index.md + + +# Markdown Extensions +markdown_extensions: + - abbr + - admonition + - attr_list + - def_list + - footnotes + - md_in_html + - toc: + permalink: true + separator: "_" + + diff --git a/pyproject.toml b/pyproject.toml index d21881c..5272c62 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,6 +10,13 @@ tqdm = "^4.64.0" codecov = "^2.1.13" coverage = "^6.4.2" testresources = "^2.0.1" +mkdocs = "^1.5.3" +mkdocs-autorefs = "0.5.0" +mkdocs-macros-plugin = "1.0.5" +mkdocs-material = "9.5.1" +mkdocs-material-extensions = "1.3.1" +mkdocstrings = "0.24.0" +mkdocstrings-python = "1.7.5" [tool.poetry.dev-dependencies] diff --git a/requirements.txt b/requirements.txt index 23a729e..3a29e2c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,3 +9,9 @@ requests==2.28.2 testresources==2.0.1 tqdm==4.64.1 urllib3==1.26.14 +mkdocs-autorefs==0.5.0 +mkdocs-macros-plugin==1.0.5 +mkdocs-material==9.5.1 +mkdocs-material-extensions==1.3.1 +mkdocstrings==0.24.0 +mkdocstrings-python==1.7.5