From e8d958a8e2d4ef2751bb00cba678c76648838917 Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 11:30:47 +0700 Subject: [PATCH 01/22] refactor: change lib --- pyproject.toml | 4 +++- uv.lock | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2cabab2..4dea062 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,8 @@ dependencies = [ "pydantic>=2.10.6", "pydantic-extra-types[all]>=2.10.2", "pydantic-settings>=2.8.0", + "pytest>=8.3.5", + "pytest-asyncio>=0.26.0", ] [project.scripts] @@ -88,7 +90,7 @@ addopts = [ ] cache_dir = ".cache/pytest" doctest_optionflags = "NUMBER IGNORE_EXCEPTION_DETAIL" -markers = ["slow: mark tests as slow"] +markers = ["slow: mark tests as slow", "asyncio: mark tests as async"] testpaths = ["tests"] verbosity_assertions = 2 xfail_strict = true diff --git a/uv.lock b/uv.lock index 1fa3ea0..efe8c0d 100644 --- a/uv.lock +++ b/uv.lock @@ -153,6 +153,8 @@ dependencies = [ { name = "pydantic" }, { name = "pydantic-extra-types", extra = ["all"] }, { name = "pydantic-settings" }, + { name = "pytest" }, + { name = "pytest-asyncio" }, ] [package.dev-dependencies] @@ -182,6 +184,8 @@ requires-dist = [ { name = "pydantic", specifier = ">=2.10.6" }, { name = "pydantic-extra-types", extras = ["all"], specifier = ">=2.10.2" }, { name = "pydantic-settings", specifier = ">=2.8.0" }, + { name = "pytest", specifier = ">=8.3.5" }, + { name = "pytest-asyncio", specifier = ">=0.26.0" }, ] [package.metadata.requires-dev] @@ -749,7 +753,7 @@ name = "importlib-metadata" version = "8.6.1" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "zipp", marker = "python_full_version < '3.11'" }, + { name = "zipp", marker = "python_full_version < '3.10'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/33/08/c1395a292bb23fd03bdf572a1357c5a733d3eecbab877641ceacab23db6e/importlib_metadata-8.6.1.tar.gz", hash = "sha256:310b41d755445d74569f993ccfc22838295d9fe005425094fad953d7f15c8580", size = 55767 } wheels = [ @@ -1987,6 +1991,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/30/3d/64ad57c803f1fa1e963a7946b6e0fea4a70df53c1a7fed304586539c2bac/pytest-8.3.5-py3-none-any.whl", hash = "sha256:c69214aa47deac29fad6c2a4f590b9c4a9fdb16a403176fe154b79c0b4d4d820", size = 343634 }, ] +[[package]] +name = "pytest-asyncio" +version = "0.26.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pytest" }, + { name = "typing-extensions", marker = "python_full_version < '3.10'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/8e/c4/453c52c659521066969523e87d85d54139bbd17b78f09532fb8eb8cdb58e/pytest_asyncio-0.26.0.tar.gz", hash = "sha256:c4df2a697648241ff39e7f0e4a73050b03f123f760673956cf0d72a4990e312f", size = 54156 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/20/7f/338843f449ace853647ace35870874f69a764d251872ed1b4de9f234822c/pytest_asyncio-0.26.0-py3-none-any.whl", hash = "sha256:7b51ed894f4fbea1340262bdae5135797ebbe21d8638978e35d31c6d19f72fb0", size = 19694 }, +] + [[package]] name = "pytest-benchmark" version = "5.1.0" From f1b1fd3a43e369781f78c693523a7da9327712c4 Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 11:31:25 +0700 Subject: [PATCH 02/22] refactor: convention code --- src/cat/core/net_ease/controller.py | 44 ++++++++++++++++------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/cat/core/net_ease/controller.py b/src/cat/core/net_ease/controller.py index 2111fc3..816c07a 100644 --- a/src/cat/core/net_ease/controller.py +++ b/src/cat/core/net_ease/controller.py @@ -7,12 +7,11 @@ from cat.core.net_ease.dto import SalaryOutput from cat.core.net_ease.services import ( - calculate_tax, calculate_insurance, calculate_personal_deduction, + calculate_tax, ) - if TYPE_CHECKING: from fastapi import UploadFile @@ -20,7 +19,10 @@ def handle_convert_gross_to_net( - gross_salary: float, number_of_dependents: int, region: int, tax_config_dep: TaxConfig + gross_salary: float, + number_of_dependents: int, + region: int, + tax_config_dep: TaxConfig, ) -> SalaryOutput: """Convert gross salary to net salary. @@ -64,14 +66,16 @@ async def handle_upload_excel(file: UploadFile, tax_config_dep: TaxConfig) -> Wo # Prepare a new workbook to write the result to new_wb = Workbook() new_sheet = new_wb.active - new_sheet.append([ - "ID", - "Employee Name", - "Gross Salary", - "Number of Dependents", - "Region", - "Net Salary", - ]) + new_sheet.append( + [ + "ID", + "Employee Name", + "Gross Salary", + "Number of Dependents", + "Region", + "Net Salary", + ] + ) # Iterate through the rows in the original sheet for row in sheet.iter_rows(min_row=2, values_only=True): @@ -92,13 +96,15 @@ async def handle_upload_excel(file: UploadFile, tax_config_dep: TaxConfig) -> Wo ) # Write the result to the new sheet - new_sheet.append([ - employee_id, - employee_name, - gross_salary, - number_of_dependents, - region, - net_salary_output.net_salary, - ]) + new_sheet.append( + [ + employee_id, + employee_name, + gross_salary, + number_of_dependents, + region, + net_salary_output.net_salary, + ] + ) return new_wb From ad180230fd6e484008b23152833a90658adc117b Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 11:31:52 +0700 Subject: [PATCH 03/22] feat: unit test --- tests/core/netease/test_controller.py | 90 +++++++++++++++++++++++++++ tests/core/netease/test_services.py | 65 +++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 tests/core/netease/test_controller.py create mode 100644 tests/core/netease/test_services.py diff --git a/tests/core/netease/test_controller.py b/tests/core/netease/test_controller.py new file mode 100644 index 0000000..955a833 --- /dev/null +++ b/tests/core/netease/test_controller.py @@ -0,0 +1,90 @@ +from io import BytesIO + +import pytest +from fastapi import UploadFile +from openpyxl import Workbook +from pytest_mock import MockerFixture + +from cat.core.net_ease.constants import TaxBracket, TaxConfig +from cat.core.net_ease.controller import ( + handle_convert_gross_to_net, + handle_upload_excel, +) +from cat.core.net_ease.dto import SalaryOutput + +tax_config = TaxConfig( + BRACKETS=[ + TaxBracket(limit=5_000_000, rate=0.05), + TaxBracket(limit=10_000_000, rate=0.10), + TaxBracket(limit=18_000_000, rate=0.15), + TaxBracket(limit=32_000_000, rate=0.20), + TaxBracket(limit=52_000_000, rate=0.25), + TaxBracket(limit=80_000_000, rate=0.30), + TaxBracket(limit=float("inf"), rate=0.35), + ] +) + + +def test_handle_convert_gross_to_net(mocker: MockerFixture): + mock_insurance = mocker.patch("cat.core.net_ease.controller.calculate_insurance") + mock_insurance.return_value = 10_000_000 + mock_deduction = mocker.patch( + "cat.core.net_ease.controller.calculate_personal_deduction" + ) + mock_deduction.return_value = 5_000_000 + mock_tax = mocker.patch("cat.core.net_ease.controller.calculate_tax") + mock_tax.return_value = 2_000_000 + + output = handle_convert_gross_to_net( + gross_salary=20_000_000, + number_of_dependents=2, + region=1, + tax_config_dep=tax_config, + ) + + assert isinstance(output, SalaryOutput) + assert output.gross_salary == 20_000_000 + assert output.net_salary == 8_000_000 + assert output.insurance_amount == 10_000_000 + assert output.personal_income_tax == 2_000_000 + + +@pytest.mark.asyncio +async def test_handle_upload_excel(tmp_path): + # Tạo workbook giả + wb = Workbook() + ws = wb.active + ws.append(["ID", "Employee Name", "Gross Salary", "Number of Dependents", "Region"]) + ws.append([1, "Alice", 20000000, 2, 1]) + ws.append([2, "Bob", 30000000, 1, 2]) + + # Lưu vào bytes + file_stream = BytesIO() + wb.save(file_stream) + file_stream.seek(0) + + # Tạo UploadFile giả + upload_file = UploadFile( + filename="tests/data_test/data_test_gross_net.xlsx", file=file_stream + ) + + # Gọi hàm upload + result_wb = await handle_upload_excel(upload_file, tax_config) + + assert isinstance(result_wb, Workbook) + + result_sheet = result_wb.active + rows = list(result_sheet.iter_rows(values_only=True)) + + # Header + 2 nhân viên + assert len(rows) == 3 + assert rows[0] == ( + "ID", + "Employee Name", + "Gross Salary", + "Number of Dependents", + "Region", + "Net Salary", + ) + assert rows[1][1] == "Alice" + assert isinstance(rows[1][-1], float) # Net Salary diff --git a/tests/core/netease/test_services.py b/tests/core/netease/test_services.py new file mode 100644 index 0000000..d32fb98 --- /dev/null +++ b/tests/core/netease/test_services.py @@ -0,0 +1,65 @@ +import pytest + +from cat.core.net_ease.constants import ConstantsSalary, TaxConfig +from cat.core.net_ease.services import ( + calculate_insurance, + calculate_personal_deduction, + calculate_tax, +) + + +def test_calculate_personal_deduction() -> None: + assert calculate_personal_deduction(0) == ConstantsSalary.BASIC_DEDUCTION + assert ( + calculate_personal_deduction(2) + == ConstantsSalary.BASIC_DEDUCTION + 2 * ConstantsSalary.DEPENDENT_DEDUCTION + ) + + +@pytest.mark.parametrize( + "gross_salary, region, expected", + [ + ( + 20_000_000, + 1, + pytest.approx( + min(20_000_000, ConstantsSalary.LIMIT_BH) * ConstantsSalary.BHXH_RATE + + min(20_000_000, ConstantsSalary.LIMIT_BH) * ConstantsSalary.BHYT_RATE + + min(20_000_000, ConstantsSalary.LIMIT_BHTN_V1) + * ConstantsSalary.BHTN_RATE + ), + ), + ( + 100_000_000, + 2, + pytest.approx( + ConstantsSalary.LIMIT_BH * ConstantsSalary.BHXH_RATE + + ConstantsSalary.LIMIT_BH * ConstantsSalary.BHYT_RATE + + ConstantsSalary.LIMIT_BHTN_V2 * ConstantsSalary.BHTN_RATE + ), + ), + ], +) +def test_calculate_insurance(gross_salary, region, expected): + assert calculate_insurance(gross_salary, region) == expected + + +def test_calculate_tax(): + tax_config = TaxConfig() + + # Case: 4,000,000 income → 5% bracket only + assert calculate_tax(4_000_000, tax_config) == 4_000_000 * 0.05 + + # Case: 10,000,000 income → spans 5% + 10% + expected_tax = 5_000_000 * 0.05 + (10_000_000 - 5_000_000) * 0.10 + assert calculate_tax(10_000_000, tax_config) == expected_tax + + # Case: 50,000,000 income → spans multiple brackets + expected_tax = ( + 5_000_000 * 0.05 + + 5_000_000 * 0.10 + + 8_000_000 * 0.15 + + 14_000_000 * 0.20 + + (50_000_000 - 32_000_000) * 0.25 + ) + assert calculate_tax(50_000_000, tax_config) == expected_tax From 0733d68e58ecb35d14b5123b348ea2f036030a3c Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 11:33:07 +0700 Subject: [PATCH 04/22] chore: change gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4fa82ef..1385ce8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ __pycache__ packages/dev_ui/src/dev_ui/common/config/__pycache__/ .venv/ -venv/ +.cache/ \ No newline at end of file From 9cee8a8c95d2a95a460ec86cc61e3f74d8074723 Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 12:51:52 +0700 Subject: [PATCH 05/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 57 +++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/github-actions-demo.yml diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml new file mode 100644 index 0000000..35caaf5 --- /dev/null +++ b/.github/workflows/github-actions-demo.yml @@ -0,0 +1,57 @@ +name: NETEASE-CICD + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + test: + name: Run unit tests + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.12" + + - name: Install uv + run: | + curl -Ls https://astral.sh/uv/install.sh | sh + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + + - name: Install dependencies with uv + run: | + uv sync + - name: Run unit tests + run: | + uv test + +# build: +# name: Build and publish +# runs-on: ubuntu-latest +# steps: +# - name: Checkout code +# uses: actions/checkout@v3 + +# - name: Set up Python +# uses: actions/setup-python@v4 +# with: +# python-version: "3.12" + +# - name: Install uv +# run: | +# curl -Ls https://astral.sh/uv/install.sh | sh +# echo "$HOME/.cargo/bin" >> $GITHUB_PATH + +# - name: Install dependencies with uv +# run: | +# uv sync + +# - name: Build and publish with uv +# run: | +# uv build --publish From 20b31540f38d3bcf62b226b83c06dda185db2839 Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 12:55:05 +0700 Subject: [PATCH 06/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 35caaf5..c50d56c 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -29,7 +29,7 @@ jobs: uv sync - name: Run unit tests run: | - uv test + uv run python pytest # build: # name: Build and publish From b46c1b69649fc9182ab52e2c02cf1b8511cb1b62 Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 12:56:54 +0700 Subject: [PATCH 07/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index c50d56c..24e9eca 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -29,7 +29,7 @@ jobs: uv sync - name: Run unit tests run: | - uv run python pytest + uv run python pytest tests/core/netease/test_*.py # build: # name: Build and publish From 2808582d71dd54b1f70d5d0153a0da94a6d53fd3 Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 12:58:27 +0700 Subject: [PATCH 08/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 24e9eca..5c98a03 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -29,7 +29,8 @@ jobs: uv sync - name: Run unit tests run: | - uv run python pytest tests/core/netease/test_*.py + pytest tests/core/netease/test_controller.py + pytest tests/core/netease/test_service.py # build: # name: Build and publish From 6b4bde305d377a0ce43d06df3fffbb5265bb36a1 Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 13:04:41 +0700 Subject: [PATCH 09/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 5c98a03..7764f35 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -29,6 +29,7 @@ jobs: uv sync - name: Run unit tests run: | + source .venv/bin/activate pytest tests/core/netease/test_controller.py pytest tests/core/netease/test_service.py From 27f1a56cefda77b2c39b7f0539aa751a2fdadfbf Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 13:44:16 +0700 Subject: [PATCH 10/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 7764f35..21eebb7 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -31,7 +31,7 @@ jobs: run: | source .venv/bin/activate pytest tests/core/netease/test_controller.py - pytest tests/core/netease/test_service.py + pytest tests/core/netease/test_services.py # build: # name: Build and publish From e6579b8e8e585f5891acdce4e24945b30c92a3d3 Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 14:24:22 +0700 Subject: [PATCH 11/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 53 +++++++++++------------ 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 21eebb7..27ab0d7 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -8,13 +8,13 @@ on: jobs: test: - name: Run unit tests + name: ✅ Run Unit Tests runs-on: ubuntu-latest steps: - - name: Checkout code + - name: 🔍 Checkout code uses: actions/checkout@v3 - - name: Set up Python + - name: 🐍 Set up Python uses: actions/setup-python@v4 with: python-version: "3.12" @@ -24,36 +24,33 @@ jobs: curl -Ls https://astral.sh/uv/install.sh | sh echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - name: Install dependencies with uv + - name: 📦 Install dependencies with uv run: | uv sync - - name: Run unit tests + - name: 🧪 Run Unit Tests run: | source .venv/bin/activate pytest tests/core/netease/test_controller.py pytest tests/core/netease/test_services.py -# build: -# name: Build and publish -# runs-on: ubuntu-latest -# steps: -# - name: Checkout code -# uses: actions/checkout@v3 - -# - name: Set up Python -# uses: actions/setup-python@v4 -# with: -# python-version: "3.12" - -# - name: Install uv -# run: | -# curl -Ls https://astral.sh/uv/install.sh | sh -# echo "$HOME/.cargo/bin" >> $GITHUB_PATH - -# - name: Install dependencies with uv -# run: | -# uv sync + build-push: + name: 🚀 Build and Push Docker Images + runs-on: ubuntu-latest + needs: test + steps: + - name: 🐳 Checkout Code + uses: actions/checkout@v3 -# - name: Build and publish with uv -# run: | -# uv build --publish + - name: 🏗️ Build Image + run: | + docker compose -f docker/services/netease.yaml + docker compose -f docker/services/streamlit.yaml + - name: 🔐 Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: 🚀 Push Image + run: | + docker push ${{ secrets.DOCKERHUB_USERNAME }}/netease:latest + docker push ${{ secrets.DOCKERHUB_USERNAME }}/streamlit:latest From 50d3752fb6275075e9b4bfe709eedb0d8826963a Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 14:29:57 +0700 Subject: [PATCH 12/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 27ab0d7..f0a3d3f 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -52,5 +52,5 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - name: 🚀 Push Image run: | - docker push ${{ secrets.DOCKERHUB_USERNAME }}/netease:latest - docker push ${{ secrets.DOCKERHUB_USERNAME }}/streamlit:latest + docker push ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/netease:latest + docker push ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/streamlit:latest From 05954652ad88a49f4262e69290b2a44c506bf058 Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 14:36:14 +0700 Subject: [PATCH 13/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index f0a3d3f..216f89c 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -40,16 +40,15 @@ jobs: steps: - name: 🐳 Checkout Code uses: actions/checkout@v3 - - - name: 🏗️ Build Image - run: | - docker compose -f docker/services/netease.yaml - docker compose -f docker/services/streamlit.yaml - name: 🔐 Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: 🏗️ Build Image + run: | + docker build -f net.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/netease:latest . + docker build -f docker/streamlit.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/streamlit:latest . - name: 🚀 Push Image run: | docker push ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/netease:latest From 155835f934fef0b7c9bd8b4365705e5d101604db Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 14:37:49 +0700 Subject: [PATCH 14/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 216f89c..a3a230b 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -40,14 +40,16 @@ jobs: steps: - name: 🐳 Checkout Code uses: actions/checkout@v3 + - name: 🔐 Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: 🏗️ Build Image run: | - docker build -f net.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/netease:latest . + docker build -f docker/net.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/netease:latest . docker build -f docker/streamlit.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/streamlit:latest . - name: 🚀 Push Image run: | From e4558b6b9889a755f312f351e15f910e0beb8462 Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 14:40:25 +0700 Subject: [PATCH 15/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index a3a230b..74c6c27 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -41,16 +41,15 @@ jobs: - name: 🐳 Checkout Code uses: actions/checkout@v3 + - name: 🏗️ Build Image + run: | + docker build -f docker/net.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/netease:latest . + docker build -f docker/streamlit.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/streamlit:latest . - name: 🔐 Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: 🏗️ Build Image - run: | - docker build -f docker/net.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/netease:latest . - docker build -f docker/streamlit.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/streamlit:latest . - name: 🚀 Push Image run: | docker push ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/netease:latest From 0968a0cc8c1c06bc64c348911c770dc871aa19d0 Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 14:43:05 +0700 Subject: [PATCH 16/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 74c6c27..b6a02a6 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -45,12 +45,13 @@ jobs: run: | docker build -f docker/net.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/netease:latest . docker build -f docker/streamlit.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/streamlit:latest . - - name: 🔐 Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + # - name: 🔐 Login to DockerHub + # uses: docker/login-action@v3 + # with: + # username: ${{ secrets.DOCKERHUB_USERNAME }} + # password: ${{ secrets.DOCKERHUB_TOKEN }} - name: 🚀 Push Image run: | + docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password ${{ secrets.DOCKERHUB_TOKEN }} docker push ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/netease:latest docker push ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/streamlit:latest From 56e7ab1a7c9e1f1d8f7a613444a40b8a89f32dc4 Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 14:46:39 +0700 Subject: [PATCH 17/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index b6a02a6..3df79b5 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -43,8 +43,8 @@ jobs: - name: 🏗️ Build Image run: | - docker build -f docker/net.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/netease:latest . - docker build -f docker/streamlit.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/streamlit:latest . + docker build -f docker/net.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/netease:latest . + docker build -f docker/streamlit.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/streamlit:latest . # - name: 🔐 Login to DockerHub # uses: docker/login-action@v3 # with: @@ -53,5 +53,7 @@ jobs: - name: 🚀 Push Image run: | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password ${{ secrets.DOCKERHUB_TOKEN }} + docker tag ${{ secrets.DOCKERHUB_USERNAME }}/netease:latest mocdiep/ci-demo/netease:latest docker push ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/netease:latest + docker tag ${{ secrets.DOCKERHUB_USERNAME }}/streamlit:latest mocdiep/ci-demo/streamlit:latest docker push ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/streamlit:latest From 9c6442af404543ac7df78ee835f800eb71d373f4 Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 15:26:43 +0700 Subject: [PATCH 18/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 3df79b5..16ade3e 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -52,7 +52,6 @@ jobs: # password: ${{ secrets.DOCKERHUB_TOKEN }} - name: 🚀 Push Image run: | - docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password ${{ secrets.DOCKERHUB_TOKEN }} docker tag ${{ secrets.DOCKERHUB_USERNAME }}/netease:latest mocdiep/ci-demo/netease:latest docker push ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/netease:latest docker tag ${{ secrets.DOCKERHUB_USERNAME }}/streamlit:latest mocdiep/ci-demo/streamlit:latest From 887b19bb9bed6882edc1f608b0930892246f74cc Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 16:56:54 +0700 Subject: [PATCH 19/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 16ade3e..33a2bb7 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -45,14 +45,14 @@ jobs: run: | docker build -f docker/net.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/netease:latest . docker build -f docker/streamlit.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/streamlit:latest . - # - name: 🔐 Login to DockerHub - # uses: docker/login-action@v3 - # with: - # username: ${{ secrets.DOCKERHUB_USERNAME }} - # password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: 🔐 Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} - name: 🚀 Push Image run: | - docker tag ${{ secrets.DOCKERHUB_USERNAME }}/netease:latest mocdiep/ci-demo/netease:latest - docker push ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/netease:latest - docker tag ${{ secrets.DOCKERHUB_USERNAME }}/streamlit:latest mocdiep/ci-demo/streamlit:latest - docker push ${{ secrets.DOCKERHUB_USERNAME }}/ci-demo/streamlit:latest + docker tag ${{ secrets.DOCKERHUB_USERNAME }}/netease:latest alaricle/ci-demo/netease:latest + docker push alaricle/ci-demo/netease:latest + docker tag ${{ secrets.DOCKERHUB_USERNAME }}/streamlit:latest alaricle/ci-demo/streamlit:latest + docker push alaricle/ci-demo/streamlit:latest From 8beafbf56c207bb50f050ec196384b5765e6576a Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 16:58:41 +0700 Subject: [PATCH 20/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 33a2bb7..4c347c6 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -43,8 +43,8 @@ jobs: - name: 🏗️ Build Image run: | - docker build -f docker/net.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/netease:latest . - docker build -f docker/streamlit.dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/streamlit:latest . + docker build -f docker/net.dockerfile -t ${{ secrets.DOCKER_USERNAME }}/netease:latest . + docker build -f docker/streamlit.dockerfile -t ${{ secrets.DOCKER_USERNAME }}/streamlit:latest . - name: 🔐 Login to DockerHub uses: docker/login-action@v3 with: @@ -52,7 +52,7 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} - name: 🚀 Push Image run: | - docker tag ${{ secrets.DOCKERHUB_USERNAME }}/netease:latest alaricle/ci-demo/netease:latest + docker tag ${{ secrets.DOCKER_USERNAME }}/netease:latest alaricle/ci-demo/netease:latest docker push alaricle/ci-demo/netease:latest - docker tag ${{ secrets.DOCKERHUB_USERNAME }}/streamlit:latest alaricle/ci-demo/streamlit:latest + docker tag ${{ secrets.DOCKER_USERNAME }}/streamlit:latest alaricle/ci-demo/streamlit:latest docker push alaricle/ci-demo/streamlit:latest From bc38ad2f85518745f025737479c77e183135082e Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 17:03:09 +0700 Subject: [PATCH 21/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 4c347c6..309ef82 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -52,6 +52,7 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} - name: 🚀 Push Image run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} docker tag ${{ secrets.DOCKER_USERNAME }}/netease:latest alaricle/ci-demo/netease:latest docker push alaricle/ci-demo/netease:latest docker tag ${{ secrets.DOCKER_USERNAME }}/streamlit:latest alaricle/ci-demo/streamlit:latest From 1b9a18c14595642f3bdec225baeb35f8b7f4ad1c Mon Sep 17 00:00:00 2001 From: HungLM1506 Date: Tue, 15 Apr 2025 17:19:38 +0700 Subject: [PATCH 22/22] chore: add github action --- .github/workflows/github-actions-demo.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 309ef82..d7d3579 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -53,7 +53,7 @@ jobs: - name: 🚀 Push Image run: | docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} - docker tag ${{ secrets.DOCKER_USERNAME }}/netease:latest alaricle/ci-demo/netease:latest - docker push alaricle/ci-demo/netease:latest - docker tag ${{ secrets.DOCKER_USERNAME }}/streamlit:latest alaricle/ci-demo/streamlit:latest - docker push alaricle/ci-demo/streamlit:latest + docker tag ${{ secrets.DOCKER_USERNAME }}/netease:latest alaricle/netease:latest + docker push alaricle/netease:latest + docker tag ${{ secrets.DOCKER_USERNAME }}/streamlit:latest alaricle/streamlit:latest + docker push alaricle/streamlit:latest