-
-
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.
feat: add `.env.*`, `Makefile` and CI
- Loading branch information
Showing
12 changed files
with
814 additions
and
2 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,19 @@ | ||
# ===== Priority order of environment variables ===== | ||
# = 1. Shell environment variables ===== | ||
# = 2. Environment variables in .env file ===== | ||
# = 1. .env.example ===== | ||
# = 2. .env.local ===== | ||
# = ! In CI/CD, only .env.ci is used. ===== | ||
# = ! In test, only .env.test is used. ===== | ||
# =================================================== | ||
|
||
# ===== Following environment variables are required in SHELL environment. ====== | ||
GENKAIERA_IS_CI=1 | ||
GENKAIERA_IS_TEST=1 | ||
|
||
# ===== Following environment variables are required in .env file. ====== | ||
# Database | ||
GENKAIERA_POSTGRES_HOST=postgres | ||
GENKAIERA_POSTGRES_PORT=5432 | ||
GENKAIERA_POSTGRES_USER=genkaiera_api | ||
GENKAIERA_POSTGRES_PASSWORD=hM7UCyG61f5aKKy8LOuWlfEhZffuD9gCRia3w+rKrYg0I3sa3PaKP4e7IDrXNfmd |
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 @@ | ||
# ===== Priority order of environment variables ===== | ||
# = 1. Shell environment variables ===== | ||
# = 2. Environment variables in .env file ===== | ||
# = 1. .env.example ===== | ||
# = 2. .env.local ===== | ||
# = ! In CI/CD, only .env.ci is used. ===== | ||
# = ! In test, only .env.test is used. ===== | ||
# =================================================== | ||
|
||
# ===== Following environment variables are required in SHELL environment. ====== | ||
GENKAIERA_IS_CI=0 | ||
GENKAIERA_IS_TEST=0 | ||
|
||
# ===== Following environment variables are required in .env file. ====== | ||
# Database | ||
GENKAIERA_POSTGRES_HOST=postgres | ||
GENKAIERA_POSTGRES_PORT=5432 | ||
GENKAIERA_POSTGRES_USER=genkaiera_api | ||
GENKAIERA_POSTGRES_PASSWORD=hM7UCyG61f5aKKy8LOuWlfEhZffuD9gCRia3w+rKrYg0I3sa3PaKP4e7IDrXNfmd |
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 @@ | ||
# ===== Priority order of environment variables ===== | ||
# = 1. Shell environment variables ===== | ||
# = 2. Environment variables in .env file ===== | ||
# = 1. .env.example ===== | ||
# = 2. .env.local ===== | ||
# = ! In CI/CD, only .env.ci is used. ===== | ||
# = ! In test, only .env.test is used. ===== | ||
# =================================================== | ||
|
||
# ===== Following environment variables are required in SHELL environment. ====== | ||
GENKAIERA_IS_CI=0 | ||
GENKAIERA_IS_TEST=0 | ||
|
||
# ===== Following environment variables are required in .env file. ====== | ||
# Database | ||
GENKAIERA_POSTGRES_HOST=postgres | ||
GENKAIERA_POSTGRES_PORT=5432 | ||
GENKAIERA_POSTGRES_USER=genkaiera_api | ||
GENKAIERA_POSTGRES_PASSWORD=hM7UCyG61f5aKKy8LOuWlfEhZffuD9gCRia3w+rKrYg0I3sa3PaKP4e7IDrXNfmd |
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 @@ | ||
# ===== Priority order of environment variables ===== | ||
# = 1. Shell environment variables ===== | ||
# = 2. Environment variables in .env file ===== | ||
# = 1. .env.example ===== | ||
# = 2. .env.local ===== | ||
# = ! In CI/CD, only .env.ci is used. ===== | ||
# = ! In test, only .env.test is used. ===== | ||
# =================================================== | ||
|
||
# ===== Following environment variables are required in SHELL environment. ====== | ||
GENKAIERA_IS_CI=0 | ||
GENKAIERA_IS_TEST=1 | ||
|
||
# ===== Following environment variables are required in .env file. ====== | ||
# Database | ||
GENKAIERA_POSTGRES_HOST=postgres | ||
GENKAIERA_POSTGRES_PORT=5432 | ||
GENKAIERA_POSTGRES_USER=genkaiera_api | ||
GENKAIERA_POSTGRES_PASSWORD=hM7UCyG61f5aKKy8LOuWlfEhZffuD9gCRia3w+rKrYg0I3sa3PaKP4e7IDrXNfmd |
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,80 @@ | ||
name: Python CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
permissions: write-all | ||
|
||
env: | ||
DOCKER_BUILDKIT: 1 | ||
COMPOSE_DOCKER_CLI_BUILD: 1 | ||
IMAGE_CACHE_DIR: /tmp/cache/docker-image | ||
IMAGE_CACHE_KEY: cache-image | ||
|
||
jobs: | ||
flake8: | ||
name: Run flake8 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run flake8 | ||
env: | ||
GENKAIERA_IS_CI: "1" | ||
run: | | ||
make flake8 | ||
mypy: | ||
name: Run mypy | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run mypy | ||
env: | ||
GENKAIERA_IS_CI: "1" | ||
run: | | ||
make mypy | ||
black: | ||
name: Run black | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run black | ||
env: | ||
GENKAIERA_IS_CI: "1" | ||
run: | | ||
make black_check | ||
pytest: | ||
name: Run pytest | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run pytest | ||
env: | ||
GENKAIERA_IS_CI: "1" | ||
run: | | ||
make pytest_ci | ||
- name: Create Coverage Comment | ||
id: coverageComment | ||
uses: MishaKav/pytest-coverage-comment@main | ||
with: | ||
pytest-coverage-path: pytest-coverage.txt | ||
junitxml-path: ./pytest.xml | ||
|
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,99 @@ | ||
# CI | ||
ifeq ($(GENKAIERA_IS_CI),"1") | ||
ifneq (,$(wildcard ./.env.ci)) | ||
include .env.ci | ||
export | ||
else | ||
$(error ".env.ci file is missing") | ||
endif | ||
|
||
# TEST | ||
else ifeq ($(GENKAIERA_IS_TEST),"1") | ||
ifneq (,$(wildcard ./.env.test)) | ||
include .env.test | ||
export | ||
else | ||
$(error ".env.test file is missing") | ||
endif | ||
|
||
# LOCAL | ||
else | ||
ifneq (,$(wildcard ./.env.example)) | ||
include .env.example | ||
export | ||
else | ||
$(error ".env.example file is missing") | ||
endif | ||
|
||
ifneq (,$(wildcard ./.env.local)) | ||
include .env.local | ||
export | ||
else | ||
$(error ".env.local file is missing") | ||
endif | ||
endif | ||
|
||
.PHONE: build | ||
build: | ||
docker compose build --build-arg BUILDKIT_INLINE_CACHE=1 | ||
|
||
.PHONY: up | ||
up: | ||
docker compose up -d --build | ||
|
||
.PHONY: down | ||
down: | ||
docker compose down | ||
|
||
.PHONY: restart | ||
restart: | ||
docker compose restart | ||
|
||
.PHONY: destroy | ||
destroy: | ||
docker compose down --rmi all --volumes --remove-orphans | ||
|
||
.PHONY: logs | ||
logs: | ||
docker compose logs -f | ||
|
||
.PHONY: shell | ||
shell: | ||
docker compose run --rm app bash | ||
|
||
.PHONY: flake8 | ||
flake8: | ||
docker compose run --rm app bash -c "python ./script/run_command.py flake8 ./" | ||
|
||
.PHONY: mypy | ||
mypy: | ||
docker compose run --rm app bash -c "python ./script/run_command.py mypy ./" | ||
|
||
.PHONY: black | ||
black: | ||
docker compose run --rm app bash -c "python ./script/run_command.py black ./" | ||
|
||
.PHONY: black_check | ||
black_check: | ||
docker compose run --rm app bash -c "python ./script/run_command.py black ./ --check" | ||
|
||
.PHONY: isort | ||
isort: | ||
docker compose run --rm app bash -c "python ./script/run_command.py isort ./" | ||
|
||
.PHONY: isort_check | ||
isort_check: | ||
docker compose run --rm app bash -c "python ./script/run_command.py isort ./ --check-only" | ||
|
||
.PHONY: pytest_html | ||
pytest_html: | ||
docker compose run --rm app bash -c "python ./script/run_command.py pytest -v ./test/ --cov=./src/ --cov-report=html --html=report.html" | ||
|
||
.PHONY: pytest_xml | ||
pytest_xml: | ||
docker compose run --rm app bash -c "python ./script/run_command.py pytest -v ./test/ --cov=./src/ --cov-report=xml" | ||
|
||
.PHONY: pytest_ci | ||
pytest_ci: | ||
$(MAKE) up | ||
docker compose run --rm app bash -c "python r./script/un_command.py pytest -v ./test/ --cov=./src/ --junitxml=pytest.xml --cov-report=term-missing:skip-covered | tee pytest-coverage.txt" |
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
Oops, something went wrong.