-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Jiooum102/2-setup-cicd
Setup CI/CD
- Loading branch information
Showing
7 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Code linting CI | ||
on: push | ||
jobs: | ||
black: | ||
runs-on: self-hosted | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
- run: pip install -r requirements.txt | ||
- run: black --check . | ||
|
||
isort: | ||
runs-on: self-hosted | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
- run: pip install -r requirements.txt | ||
- run: isort --check . | ||
|
||
flake8: | ||
runs-on: self-hosted | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
- run: pip install -r requirements.txt | ||
- run: flake8 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
default_language_version: | ||
python: python3.10 | ||
|
||
customCommands: | ||
- key: "W" | ||
command: git commit --no-verify | ||
context: "global" | ||
subprocess: true | ||
|
||
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 | ||
- id: check-added-large-files | ||
- repo: https://github.com/psf/black | ||
rev: 23.11.0 | ||
hooks: | ||
- id: black | ||
language_version: python3.10 | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: 6.1.0 | ||
hooks: | ||
- id: flake8 | ||
- repo: https://github.com/pycqa/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
args: ["--profile=black"] | ||
- repo: local | ||
hooks: | ||
- id: pytest-check | ||
name: pytest-check | ||
stages: [push] | ||
types: [python3] | ||
entry: bash -c 'make dev_test' | ||
language: python | ||
pass_filenames: false | ||
always_run: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
SHELL=/bin/bash | ||
|
||
DEV_ENV_FILE=".env.dev" | ||
|
||
# Run directly from env | ||
# Recommend to create a specific env and activate it first | ||
dev_install: | ||
./scripts/develop.sh install | ||
dev_setup_env: | ||
export PYTHONPATH=`pwd` | ||
source ${DEV_ENV_FILE} | ||
dev_run_server: | ||
./scripts/develop.sh run | ||
dev_test: | ||
./scripts/develop.sh test | ||
dev_test_lint: | ||
./scripts/develop.sh test_lint | ||
dev_fix_lint: | ||
./scripts/develop.sh fix_lint |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[tool.black] | ||
line-length = 120 | ||
skip-string-normalization = 1 | ||
include = '\.pyi?$' | ||
exclude = ''' | ||
/( | ||
\.git | ||
| \.hg | ||
| \.mypy_cache | ||
| \.tox | ||
| \.venv | ||
| _build | ||
| buck-out | ||
| build | ||
| dist | ||
)/ | ||
''' | ||
|
||
[tool.isort] | ||
profile = "black" | ||
lines_after_imports = 2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
black~=23.11.0 | ||
flake8~=6.1.0 | ||
isort~=5.12.0 | ||
pre-commit~=3.5.0 | ||
pytest~=7.4.2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/bash | ||
|
||
cmd=$1 | ||
|
||
ENV_FILE=".env.dev" | ||
|
||
# Check if we run from Gitlab runner (use Gitlab variables, not .env file) | ||
if [[ ! -f $ENV_FILE ]] | ||
then | ||
echo ".env file does not exist on your filesystem. Read from environment variables." | ||
else | ||
source $ENV_FILE | ||
fi | ||
|
||
# constants | ||
IMAGE_NAME=$PROJECT_NAME | ||
COMMIT_HASH=$(git describe --always) | ||
IMAGE_VERSION="${IMAGE_VERSION//\//-}" # Replace / to - because docker tags not support | ||
|
||
usage() { | ||
echo "develop.sh <command> <arguments>" | ||
echo "Available commands:" | ||
echo " install install environment" | ||
echo " test run unit-test" | ||
echo " test_lint run linters" | ||
} | ||
|
||
if [[ -z "$cmd" ]]; then | ||
echo "Missing command" | ||
usage | ||
exit 1 | ||
fi | ||
|
||
install() { | ||
echo "Install requirements ..." | ||
pip install -r requirements.txt | ||
|
||
echo "Install pre-commit for auto linting and testing stage ..." | ||
pre-commit install | ||
} | ||
|
||
test() { | ||
echo "Unit-test running ..." | ||
/bin/bash ./scripts/run_tests.sh run_test | ||
} | ||
|
||
test_lint() { | ||
echo "Run lint test" | ||
black --check . && isort --check . && flake8 | ||
} | ||
|
||
fix_lint() { | ||
echo "Run fix linters" | ||
black . && isort . && flake8 | ||
} | ||
|
||
|
||
case $cmd in | ||
install) | ||
install "$@" | ||
;; | ||
test) | ||
test "$@" | ||
;; | ||
test_lint) | ||
test_lint "$@" | ||
;; | ||
fix_lint) | ||
fix_lint "$@" | ||
;; | ||
*) | ||
echo -n "Unknown command: $cmd" | ||
usage | ||
exit 1 | ||
;; | ||
esac |