From 0748ff30ff288b158140c93d569f91e2cdb70f49 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Fri, 15 Dec 2023 18:00:01 -0500 Subject: [PATCH] Add sdk test job that runs against an active server --- .github/workflows/sdk.yml | 39 +++++++++++++++++++++++++++++++++++++++ client/Makefile | 5 +++++ 2 files changed, 44 insertions(+) create mode 100644 .github/workflows/sdk.yml diff --git a/.github/workflows/sdk.yml b/.github/workflows/sdk.yml new file mode 100644 index 0000000000..010373cf75 --- /dev/null +++ b/.github/workflows/sdk.yml @@ -0,0 +1,39 @@ +name: SDK +on: [push, pull_request] + +defaults: + run: + shell: bash + +jobs: + sdk-with-server: + runs-on: ubuntu-latest + env: + DOCKERIZE_VERSION: "v0.7.0" + steps: + - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + repository: "freedomofpress/securedrop" + ref: "better-tty" + path: "securedrop-server" + - uses: actions/setup-python@v5 + with: + python-version: "3.9" + - name: Install dependencies + run: | + pip install poetry==1.6.1 + wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && + tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && + rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz + - name: Run tests without VCR cassettes + run: | + # Start the server in the background + NUM_SOURCES=5 make -C securedrop-server dev & + # And install deps + poetry -C client install --no-ansi + # Wait for server to come up + dockerize -wait http://127.0.0.1:8080 -timeout 10m + # Run tests + rm client/tests/sdk/data/*.yml + make -C client test-sdk diff --git a/client/Makefile b/client/Makefile index 24e2579a5a..3c7e976363 100644 --- a/client/Makefile +++ b/client/Makefile @@ -75,6 +75,7 @@ clean: ## Clean the workspace of generated resources TESTS ?= tests ITESTS ?= tests/integration FTESTS ?= tests/functional +STESTS ?= tests/sdk TESTOPTS ?= -v --cov-config .coveragerc --cov-report html --cov-report term-missing --cov=securedrop_client --cov-fail-under 90 RANDOM_SEED ?= $(shell bash -c 'echo $$RANDOM') @@ -104,6 +105,10 @@ test-integration: ## Run the integration tests test-functional: ## Run the functional tests @./test-functional.sh +.PHONY: test-sdk +test-sdk: ## Run just the sdk tests + @poetry run pytest -v $(STESTS) + .PHONY: lint lint: ## Run the linters @poetry run flake8 securedrop_client tests