ci: make contract tests stage optional

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2024-03-27 13:51:45 +01:00
parent e44b29f3a6
commit 9e71fc2d14
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
4 changed files with 49 additions and 56 deletions

View File

@ -375,25 +375,25 @@ test-contract: export SHADOW_NS_REGEXP := ^tests\.contract-test.*$$
test-contract: ##@test Run contract tests
test-contract: _test-clojure
android-test: jsbundle
android-test: export TARGET := android
android-test:
test-android: jsbundle
test-android: export TARGET := android
test-android: ##@test Android Gradle test
cd android && ./gradlew test
component-test-watch: export TARGET := clojure
component-test-watch: export COMPONENT_TEST := true
component-test-watch: export BABEL_ENV := test
component-test-watch: export JEST_USE_SILENT_REPORTER := false
component-test-watch: ##@ Watch tests and re-run no changes to cljs files
test-component-watch: export TARGET := clojure
test-component-watch: export COMPONENT_TEST := true
test-component-watch: export BABEL_ENV := test
test-component-watch: export JEST_USE_SILENT_REPORTER := false
test-component-watch: ##@ Watch tests and re-run no changes to cljs files
@scripts/check-metro-shadow-process.sh
rm -rf ./component-spec
nodemon --exec 'yarn shadow-cljs compile component-test && jest --config=test/jest/jest.config.js --testEnvironment node ' -e cljs
component-test: export TARGET := clojure
component-test: export COMPONENT_TEST := true
component-test: export BABEL_ENV := test
component-test: export JEST_USE_SILENT_REPORTER := false
component-test: ##@test Run component tests once in NodeJS
test-component: export TARGET := clojure
test-component: export COMPONENT_TEST := true
test-component: export BABEL_ENV := test
test-component: export JEST_USE_SILENT_REPORTER := false
test-component: ##@test Run component tests once in NodeJS
@scripts/check-metro-shadow-process.sh
rm -rf ./component-spec
yarn shadow-cljs compile component-test && \

View File

@ -29,6 +29,11 @@ pipeline {
description: 'Specify build type. Values: pr / e2e / nightly / release',
defaultValue: 'pr',
)
booleanParam(
name: 'RUN_CONTRACT_TESTS',
description: 'Whether to run optional and slow contract tests.',
defaultValue: false,
)
}
environment {
@ -39,51 +44,32 @@ pipeline {
BUILD_ENV = 'prod'
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
LOG_FILE = utils.pkgFilename(ext: 'log', arch: 'tests')
CLJ_LINTER_PRINT_WARNINGS = 'true'
}
stages {
stage('Checks') {
stage('Test') {
parallel {
stage('Lint') {
steps {
sh """#!/bin/bash
set -eo pipefail
make lint CLJ_LINTER_PRINT_WARNINGS=true 2>&1 | tee ${LOG_FILE}
"""
}
steps { make('lint') }
}
stage('Unit Tests') {
steps {
sh """#!/bin/bash
set -eo pipefail
make test-unit 2>&1 | tee -a ${LOG_FILE}
"""
}
stage('Unit') {
steps { make('test-unit') }
}
stage('Component') {
steps { make('test-component') }
}
}
}
stage('Contract Tests') {
steps {
sh """#!/bin/bash
set -eo pipefail
make test-contract 2>&1 | tee -a ${LOG_FILE}
"""
}
}
stage('Integration Tests') {
steps {
sh """#!/bin/bash
set -eo pipefail
make test-integration 2>&1 | tee -a ${LOG_FILE}
"""
}
}
stage('Component Tests') {
steps {
sh """#!/bin/bash
set -eo pipefail
make component-test 2>&1 | tee -a ${LOG_FILE}
"""
stage('Heavy Test') {
parallel {
stage('Contract') {
when { expression { params.RUN_CONTRACT_TESTS } }
steps { make('test-contract') }
}
stage('Integration') {
steps { make('test-integration') }
}
}
}
stage('Upload') {
@ -100,3 +86,10 @@ pipeline {
always { sh 'make purge' }
}
}
def make(target) {
sh """#!/bin/bash
set -eo pipefail
make ${target} 2>&1 | tee -a ${LOG_FILE}
"""
}

View File

@ -16,10 +16,10 @@ Both of these links are showing it for React-Testing-Library (not Native) howeve
## Running the tests
To run these tests there are two methods.
`make component-test`
`make test-component`
setups and runs the test suite once.
`make component-test-watch`
`make test-component-watch`
setups and runs the test suite and watches for code changes will then retrigger the test suite.
## Writing Tests
@ -38,7 +38,7 @@ There is a file of utility functions defined in "src/test_helpers/component.cljs
## Configuration
Status Mobile has a bespoke tech stack, as such there is more complexities to configuring the tests.
### Shadow-CLJS
### Shadow-CLJS
the configuration for compiling our tests are defined in the "shadow-cljs.edn" file.
The three main parts of this are
`:target :npm-module`
@ -47,9 +47,9 @@ Needed for the configuration we are using
a vector of entry points for the test files.
and the `ns-regexp` to specify what tests to find. Since we have multiple forms of tests we decided that "component-spec" is the least likely to detect the wrong file type.
It's worth knowing that our tests are compiled to JS and then run in the temporary folder `component-tests`.
It's worth knowing that our tests are compiled to JS and then run in the temporary folder `component-tests`.
### Jest
There is also further configuration for Jest in "test/jest". There is a jest config file which has some mostly standard configuration pieces, where the tests live, what environment variables are set etc. This is documented by Jest here: https://jestjs.io/docs/configuration
There is also a setup file which is used to set some global and default values. Additionally this file is used to mock some of the react native (among other) dependencies
There is also a setup file which is used to set some global and default values. Additionally this file is used to mock some of the react native (among other) dependencies.

View File

@ -54,13 +54,13 @@ Here I'm showing a terminal-only experience using Tmux (left pane Emacs, right p
To run tests:
```
make component-test
make test-component
```
Also test watcher can be launched. It will re-run the entire test suite when any file is modified
```
make component-test-watch
make test-component-watch
```
Check [component tests doc](./component-tests-overview.md) for more.