From 64c9fcdfcc5b7870b72a5d3fff6decb5cac64875 Mon Sep 17 00:00:00 2001 From: Eyo Chen Date: Sat, 24 May 2025 15:07:51 +0800 Subject: [PATCH 1/7] feat: add ci --- .github/workflows/ci.yml | 57 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..803c652 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,57 @@ +name: CI Pipeline + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + + services: + mongodb-test: + image: mongo:latest + ports: + - 27017:27017 + options: >- + --health-cmd "mongosh --eval 'db.runCommand({ ping: 1 })'" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.9' + + - name: Install uv + run: | + curl -LsSf https://astral.sh/uv/install.sh | sh + echo "$HOME/.cargo/bin" >> $GITHUB_PATH + + - name: Install dependencies + run: | + uv pip install --system -r pyproject.toml + uv pip install --system pytest flake8 + + - name: Run linter (flake8) + run: | + flake8 src/ --max-line-length=88 --extend-ignore=E203 + + - name: Generate protobuf files + run: make generate + + - name: Run tests + run: make test + + - name: Cleanup + if: always() + run: | + docker-compose down -v + rm -rf __pycache__ tests/__pycache__ \ No newline at end of file From 7539e654240206c39c43286a659fb575bbe48499 Mon Sep 17 00:00:00 2001 From: Eyo Chen Date: Sat, 24 May 2025 15:09:25 +0800 Subject: [PATCH 2/7] fix: remove linter --- .github/workflows/ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 803c652..a3403ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,11 +38,6 @@ jobs: - name: Install dependencies run: | uv pip install --system -r pyproject.toml - uv pip install --system pytest flake8 - - - name: Run linter (flake8) - run: | - flake8 src/ --max-line-length=88 --extend-ignore=E203 - name: Generate protobuf files run: make generate From 8a53387b60e96783138aad36225bf483948ec576 Mon Sep 17 00:00:00 2001 From: Eyo Chen Date: Sat, 24 May 2025 15:20:22 +0800 Subject: [PATCH 3/7] fix: install docker --- .github/workflows/ci.yml | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3403ec..adb5c8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,21 +10,15 @@ jobs: test: runs-on: ubuntu-latest - services: - mongodb-test: - image: mongo:latest - ports: - - 27017:27017 - options: >- - --health-cmd "mongosh --eval 'db.runCommand({ ping: 1 })'" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - steps: - name: Checkout code uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + install: true + - name: Set up Python uses: actions/setup-python@v5 with: @@ -43,6 +37,8 @@ jobs: run: make generate - name: Run tests + env: + PYTHONPATH: ./src run: make test - name: Cleanup From da9fe95817a227d14fb83bc7891f5916a56a1922 Mon Sep 17 00:00:00 2001 From: Eyo Chen Date: Sat, 24 May 2025 15:22:42 +0800 Subject: [PATCH 4/7] fix: install docker compose --- .github/workflows/ci.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index adb5c8c..a5bbd68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,19 @@ jobs: with: install: true + - name: Install Docker Compose + run: | + sudo curl -L "https://github.com/docker/compose/releases/download/v2.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + docker-compose --version + + - name: Start Docker Compose services + run: | + docker-compose up -d + env: + COMPOSE_DOCKER_CLI_BUILD: 1 + DOCKER_BUILDKIT: 1 + - name: Set up Python uses: actions/setup-python@v5 with: From 0205984d45fc252a3c9ae43c0dea0b2242011cda Mon Sep 17 00:00:00 2001 From: Eyo Chen Date: Sat, 24 May 2025 15:26:17 +0800 Subject: [PATCH 5/7] fix: install dev dependency --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5bbd68..0912c3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: - name: Install dependencies run: | - uv pip install --system -r pyproject.toml + uv pip install --system -r pyproject.toml --group dev - name: Generate protobuf files run: make generate From 7e88f0abe79b6cacea7d40f0214217073d411689 Mon Sep 17 00:00:00 2001 From: Eyo Chen Date: Sat, 24 May 2025 15:29:59 +0800 Subject: [PATCH 6/7] temp: make test failed --- .github/workflows/ci.yml | 2 +- tools/tests/run_tests.sh | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0912c3c..a5bbd68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: - name: Install dependencies run: | - uv pip install --system -r pyproject.toml --group dev + uv pip install --system -r pyproject.toml - name: Generate protobuf files run: make generate diff --git a/tools/tests/run_tests.sh b/tools/tests/run_tests.sh index 33054f2..756335b 100755 --- a/tools/tests/run_tests.sh +++ b/tools/tests/run_tests.sh @@ -41,8 +41,11 @@ print_emoji_line "=>" "${YELLOW}" docker-compose up -d mongodb-test uv run src/tests/tools/wait_for_mongo.py PYTHONPATH=./src python -m pytest src/tests/ -if [ $? -eq 0 ]; then +pytest_exit_code=$? +if [ $pytest_exit_code -eq 0 ]; then echo -e "${GREEN}🎉 Tests passed successfully!" + exit 0 else echo -e "${RED}❌ Tests failed!" + exit $pytest_exit_code fi \ No newline at end of file From 7366254e866cd8ccda28bf4618b3bf0544f6ac8e Mon Sep 17 00:00:00 2001 From: Eyo Chen Date: Sat, 24 May 2025 15:42:53 +0800 Subject: [PATCH 7/7] fix: correct --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5bbd68..0912c3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: - name: Install dependencies run: | - uv pip install --system -r pyproject.toml + uv pip install --system -r pyproject.toml --group dev - name: Generate protobuf files run: make generate