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

View File

@ -29,6 +29,11 @@ pipeline {
description: 'Specify build type. Values: pr / e2e / nightly / release', description: 'Specify build type. Values: pr / e2e / nightly / release',
defaultValue: 'pr', defaultValue: 'pr',
) )
booleanParam(
name: 'RUN_CONTRACT_TESTS',
description: 'Whether to run optional and slow contract tests.',
defaultValue: false,
)
} }
environment { environment {
@ -39,51 +44,32 @@ pipeline {
BUILD_ENV = 'prod' BUILD_ENV = 'prod'
NIX_CONF_DIR = "${env.WORKSPACE}/nix" NIX_CONF_DIR = "${env.WORKSPACE}/nix"
LOG_FILE = utils.pkgFilename(ext: 'log', arch: 'tests') LOG_FILE = utils.pkgFilename(ext: 'log', arch: 'tests')
CLJ_LINTER_PRINT_WARNINGS = 'true'
} }
stages { stages {
stage('Checks') { stage('Test') {
parallel { parallel {
stage('Lint') { stage('Lint') {
steps { steps { make('lint') }
sh """#!/bin/bash
set -eo pipefail
make lint CLJ_LINTER_PRINT_WARNINGS=true 2>&1 | tee ${LOG_FILE}
"""
}
} }
stage('Unit Tests') { stage('Unit') {
steps { steps { make('test-unit') }
sh """#!/bin/bash }
set -eo pipefail stage('Component') {
make test-unit 2>&1 | tee -a ${LOG_FILE} steps { make('test-component') }
"""
}
} }
} }
} }
stage('Contract Tests') { stage('Heavy Test') {
steps { parallel {
sh """#!/bin/bash stage('Contract') {
set -eo pipefail when { expression { params.RUN_CONTRACT_TESTS } }
make test-contract 2>&1 | tee -a ${LOG_FILE} steps { make('test-contract') }
""" }
} stage('Integration') {
} steps { make('test-integration') }
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('Upload') { stage('Upload') {
@ -100,3 +86,10 @@ pipeline {
always { sh 'make purge' } 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 ## Running the tests
To run these tests there are two methods. To run these tests there are two methods.
`make component-test` `make test-component`
setups and runs the test suite once. 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. setups and runs the test suite and watches for code changes will then retrigger the test suite.
## Writing Tests ## Writing Tests
@ -52,4 +52,4 @@ It's worth knowing that our tests are compiled to JS and then run in the tempora
### Jest ### 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 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: 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 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. Check [component tests doc](./component-tests-overview.md) for more.