Skip to content

Commit

Permalink
* added pre-commit setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimroshdy committed Feb 7, 2024
1 parent ba9708e commit a0f5369
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/actions/install-run-code/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ runs:
- run: pyfiglet ${{ inputs.project_name }}
shell: bash
- run: python simple_loop.py
shell: bash
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/ci_multi_arch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
context: .
platforms: linux/amd64, linux/arm64
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.ref_name }}
tags: ghcr.io/${{ github.repository }}:${{ github.ref_name }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,4 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# End of https://www.toptal.com/developers/gitignore/api/python
# End of https://www.toptal.com/developers/gitignore/api/python
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,3 @@ RUN chmod +x simple_loop.py

# Entrypoint
CMD ["python","simple_loop.py"]


3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
![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)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/ibrahimroshdy/continuous_integration/main.svg)](https://results.pre-commit.ci/latest/github/ibrahimroshdy/continuous_integration/main)

## About

Expand All @@ -22,7 +23,7 @@ continuous_integration
│ ├── 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
│ └── workflows # This project's Workflows
│ └── ci_workflow.yml # Workflow instructions file
├── .gitignore # git ignore file
├── pyproject.toml
Expand Down
20 changes: 10 additions & 10 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Continuous Integration
# 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
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
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 Structure
### Folder Structure
```
continuous_integration
Expand All @@ -19,22 +19,22 @@ continuous_integration
│ ├── 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
│ └── workflows # This project's Workflows
│ └── ci_workflow.yml # Workflow instructions file
├── .gitignore
├── pyproject.toml
└── simple_loop.py
```


### Getting Started
### Getting Started

There is no need to run the project locally, but in case it is needed here is the quick start instructions used.
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
Create a virtualenv
```bash
virtualenv venv -p python3
```
Expand All @@ -54,7 +54,7 @@ Run poetry install to install all needed python packages
poetry install
```

Run pyfiglet because you can
Run pyfiglet because you can
```bash
pyfiglet Continuous Integration
```
Expand All @@ -64,7 +64,7 @@ Finally, run code
python simple_loop.py
```

You should have something like that:
You should have something like that:

```bash
This is a progress bar of the simple loop script
Expand Down
2 changes: 0 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,3 @@ markdown_extensions:
- toc:
permalink: true
separator: "_"


2 changes: 1 addition & 1 deletion simple_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ def __ignored_func():
print("This is an ignored function and this message will not be printed")


if __name__ == '__main__':
if __name__ == "__main__":
print("This is a progress bar of the simple loop script")
simple_loop_func(1000000)

0 comments on commit a0f5369

Please sign in to comment.