From 9155fdbb31d372729731d81da376261fad1e5c4d Mon Sep 17 00:00:00 2001 From: Emmanuel Evbuomwan Date: Wed, 27 Nov 2024 12:11:49 +0100 Subject: [PATCH] feat: github actions to run docker unit tests --- .github/workflows/tests.yml | 43 +++++++++++++++++++++++++++++++++++-- bin/smoke-test-registry.sh | 1 + 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3423067f9..1ce27c993 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,7 +17,7 @@ env: KARAPACE_DOTENV: ${{ github.workspace }}/karapace.config.env jobs: - tests: + unit-tests: runs-on: ubuntu-latest strategy: matrix: @@ -41,11 +41,49 @@ jobs: with: go-version: '1.21.0' + - name: Install requirements + run: make install + + - name: Resolve Karapace version + run: | + source ./venv/bin/activate + KARAPACE_VERSION=$(python -c "from karapace import version; print(version.__version__)") + echo KARAPACE_VERSION=$KARAPACE_VERSION >> $GITHUB_ENV + + - name: Run containers + run: KARAPACE_VERSION=${{ env.KARAPACE_VERSION }} docker compose --file=container/compose.yml up --build --wait --detach + - run: make install-dev - - run: make unit-tests + - run: make unit-tests-in-docker env: COVERAGE_FILE: ".coverage.${{ matrix.python-version }}" PYTEST_ARGS: "--cov=src --cov-append --numprocesses 4" + KARAPACE_VERSION=: ${{ env.KARAPACE_VERSION }} + + integration-tests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ '3.10', '3.11', '3.12' ] + env: + PYTEST_ADDOPTS: >- + --log-dir=/tmp/ci-logs + --log-file=/tmp/ci-logs/pytest.log + --showlocals + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + cache: pip + python-version: ${{ matrix.python-version }} + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.21.0' + - run: make integration-tests env: COVERAGE_FILE: ".coverage.${{ matrix.python-version }}" @@ -57,6 +95,7 @@ jobs: with: name: karapace-integration-test-logs-${{ matrix.python-version }} path: /tmp/ci-logs + - name: Archive coverage file uses: actions/upload-artifact@v4 with: diff --git a/bin/smoke-test-registry.sh b/bin/smoke-test-registry.sh index 71f4e4fc7..aab54ac76 100755 --- a/bin/smoke-test-registry.sh +++ b/bin/smoke-test-registry.sh @@ -6,6 +6,7 @@ for ((i = 0; i <= retries; i++)); do response=$( curl --silent --verbose --fail --request POST \ --header 'Content-Type: application/vnd.schemaregistry.v1+json' \ + --header 'Authorization: Basic Og==' \ --data '{"schema": "{\"type\": \"record\", \"name\": \"Obj\", \"fields\":[{\"name\": \"age\", \"type\": \"int\"}]}"}' \ http://localhost:8081/subjects/test-key/versions )