Skip to content

Commit

Permalink
Migrate app-tests and app-page-layout-tests jobs to GitHub Actions
Browse files Browse the repository at this point in the history
Split the non-pageslayout functional tests to their own job for a bit of
extra parallelism.

Image pre-building/caching doesn't seem to be working the same way in
GitHub Actions, so I've dropped it for now and we can add it back in
later on.
  • Loading branch information
legoktm committed Aug 15, 2024
1 parent b29ac77 commit d3a0cb0
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 111 deletions.
108 changes: 0 additions & 108 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,94 +101,6 @@ jobs:
DOCKER_BUILD_ARGUMENTS="--cache-from securedrop-test-focal-py3:${fromtag:-latest}" securedrop/bin/dev-shell \
bash -c "/opt/venvs/securedrop-app-code/bin/pip3 install --require-hashes -r requirements/python3/develop-requirements.txt && make -C .. verify-mo"
app-tests:
machine:
image: ubuntu-2004:current
enabled: true
environment:
DOCKER_API_VERSION: 1.24
BASE_OS: focal
parallelism: 3
steps:
- checkout
- *rebaseontarget
- *createcachedir
- *restorecache
- *loadimagelayers
- *dockerimagebuild
- *saveimagelayers
- *savecache

- run:
name: Run tests
command: |
JOB_TESTFILES=$(cd securedrop; circleci tests glob 'tests/test*py' 'tests/{files,functional}/test*py')
echo "JOB_TESTFILES: ${JOB_TESTFILES}"
RUN_TESTFILES=$(echo "$JOB_TESTFILES" |circleci tests split --split-by=timings)
echo "RUN_TESTFILES: ${RUN_TESTFILES}"
export TESTFILES=$RUN_TESTFILES
fromtag=$(docker images |grep securedrop-test-focal-py3 |head -n1 |awk '{print $2}')
DOCKER_BUILD_ARGUMENTS="--cache-from securedrop-test-focal-py3:${fromtag:-latest}" make test
no_output_timeout: 15m

- store_test_results:
path: ~/project/test-results

- store_artifacts:
path: ~/project/test-results

app-page-layout-tests:
machine:
image: ubuntu-2004:current
enabled: true
environment:
DOCKER_API_VERSION: 1.24
BASE_OS: focal
parallelism: 5
steps:
- checkout
- *rebaseontarget
- *createcachedir
- *restorecache
- *loadimagelayers
- *dockerimagebuild
- *saveimagelayers
- *savecache

- run:
name: Run tests
command: |
JOB_TESTFILES=$(cd securedrop; circleci tests glob 'tests/functional/pageslayout/test*py')
echo "JOB_TESTFILES: ${JOB_TESTFILES}"
RUN_TESTFILES=$(echo "$JOB_TESTFILES" |circleci tests split --split-by=timings)
echo "RUN_TESTFILES: ${RUN_TESTFILES}"
export TESTFILES=$RUN_TESTFILES
fromtag=$(docker images |grep securedrop-test-focal-py3 |head -n1 |awk '{print $2}')
DOCKER_BUILD_ARGUMENTS="--cache-from securedrop-test-focal-py3:${fromtag:-latest}" make test
no_output_timeout: 15m

# Once HTML can be expected to validate, remove "|| true" and
# "informational" status---in other words, fail if validation fails!
- run:
name: Validate HTML (informational)
command: |
fromtag=$(docker images |grep securedrop-test-focal-py3 |head -n1 |awk '{print $2}')
DOCKER_BUILD_ARGUMENTS="--cache-from securedrop-test-focal-py3:${fromtag:-latest}" \
make validate-test-html || true
- run:
name: Validate accessibility (informational)
command: |
fromtag=$(docker images |grep securedrop-test-focal-py3 |head -n1 |awk '{print $2}')
DOCKER_BUILD_ARGUMENTS="--cache-from securedrop-test-focal-py3:${fromtag:-latest}" \
make accessibility-summary || true
- store_test_results:
path: ~/project/test-results

- store_artifacts:
path: ~/project/test-results

translation-tests:
machine:
image: ubuntu-2004:current
Expand Down Expand Up @@ -268,26 +180,6 @@ workflows:
context:
- circleci-slack
<<: *slack-fail-post-step
- app-tests:
filters:
branches:
ignore:
- /update-builder-.*/
requires:
- lint
context:
- circleci-slack
<<: *slack-fail-post-step
- app-page-layout-tests:
filters:
branches:
ignore:
- /update-builder-.*/
requires:
- lint
context:
- circleci-slack
<<: *slack-fail-post-step
- staging-test-with-rebase:
filters:
branches:
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,45 @@ jobs:
make lint
make verify-mo
test-app:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build image
run: |
DOCKER_BUILD_VERBOSE=true ./securedrop/bin/dev-shell true
- name: Run application tests
run: |
make test-app
test-functional:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build image
run: |
DOCKER_BUILD_VERBOSE=true ./securedrop/bin/dev-shell true
- name: Run functional tests
run: |
make test-functional
test-pageslayout:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build image
run: |
DOCKER_BUILD_VERBOSE=true ./securedrop/bin/dev-shell true
- name: Run page layout tests
run: |
make test-pageslayout
- name: Validate HTML (informational)
run: |
make validate-test-html || true
- name: Validate accessibility (informational)
run: |
make accessibility-summary || true
rust:
runs-on: ubuntu-latest
# Keep version in sync with rust-toolchain.toml
Expand Down
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,24 @@ otp: ## Show (and opportunistically copy) the current development OTP (to the cl

.PHONY: test
test: ## Run the test suite in a Docker container.
@echo "███ Running SecureDrop application tests..."
@echo "███ Running all SecureDrop tests..."
@$(DEVSHELL) $(SDBIN)/run-test -v $${TESTFILES:-tests}
@echo

.PHONY: test-focal
test-focal: test
.PHONY: test-app
test-app: ## Run the application tests
@echo "███ Running SecureDrop application tests..."
TESTFILES="$(shell cd securedrop; echo tests/test*py)" $(MAKE) test

.PHONY: test-functional
test-functional: ## Run the functional tests
@echo "███ Running SecureDrop functional tests..."
TESTFILES="$(shell cd securedrop; echo tests/functional/test*py)" $(MAKE) test

.PHONY: test-pageslayout
test-pageslayout: ## Run the page layout tests
@echo "███ Running page layout tests..."
TESTFILES="$(shell cd securedrop; echo tests/functional/pageslayout/test*py)" $(MAKE) test

.PHONY: rust-test
rust-test:
Expand Down

0 comments on commit d3a0cb0

Please sign in to comment.