From dc47d096400e7a4d95dd9516c72876c8ad016dcb Mon Sep 17 00:00:00 2001 From: vnugent Date: Thu, 17 Oct 2024 23:33:46 -0400 Subject: update CI tests and run cross-platform unit testing --- .onedev-buildspec.yml | 75 ++++++++++++++++++++++++++++++++++----- Module.Taskfile.yaml | 8 +++-- Taskfile.yaml | 98 ++++++++++++++++++++++++++++++--------------------- 3 files changed, 131 insertions(+), 50 deletions(-) diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml index f2ae8cb..8bbe9c7 100644 --- a/.onedev-buildspec.yml +++ b/.onedev-buildspec.yml @@ -1,6 +1,5 @@ -version: 35 +version: 36 jobs: - - name: Git mirror push steps: - !PushRepository @@ -27,15 +26,75 @@ jobs: retryDelay: 30 timeout: 3600 -- name: Build and publish - jobExecutor: primary-shell-executor +- name: Unit Testing + steps: + - !CheckoutStep + name: checkout + cloneCredential: !DefaultCredential {} + withLfs: false + withSubmodules: false + checkoutPath: '@project_name@' + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !CommandStep + name: run unit tests + runInContainer: false + interpreter: !DefaultInterpreter + commands: | + cd @project_name@ + task -t Module.Taskfile.yaml test + useTTY: true + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + triggers: + - !BranchUpdateTrigger + branches: '** -master' + retryCondition: never + maxRetries: 3 + retryDelay: 30 + timeout: 14400 +- name: Staging build + steps: + - !CheckoutStep + name: checkout + cloneCredential: !DefaultCredential {} + withLfs: false + withSubmodules: false + checkoutPath: '@project_name@' + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !CommandStep + name: VNBuild build + runInContainer: false + interpreter: !DefaultInterpreter + commands: | + vnbuild build -S --verbose + useTTY: true + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !CommandStep + name: VNBuild mock publish + runInContainer: false + interpreter: !DefaultInterpreter + commands: | + vnbuild publish --sign + useTTY: true + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + triggers: + - !BranchUpdateTrigger + branches: develop master + jobDependencies: + - jobName: Unit Testing + requireSuccessful: true + retryCondition: never + maxRetries: 3 + retryDelay: 30 + timeout: 14400 + +- name: Publish on tag steps: - !CheckoutStep - name: Code checkout + name: checkout cloneCredential: !DefaultCredential {} withLfs: false withSubmodules: false - checkoutPath: '@project_name@/' + checkoutPath: '@project_name@' condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL - !CommandStep name: VNBuild build @@ -59,9 +118,9 @@ jobs: useTTY: true condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL triggers: - - !BranchUpdateTrigger + - !TagCreateTrigger branches: master retryCondition: never maxRetries: 3 retryDelay: 30 - timeout: 3600 \ No newline at end of file + timeout: 14400 diff --git a/Module.Taskfile.yaml b/Module.Taskfile.yaml index d31449a..b7b991c 100644 --- a/Module.Taskfile.yaml +++ b/Module.Taskfile.yaml @@ -17,11 +17,16 @@ tasks: cmds: - git reset --hard - git remote update - - git pull origin {{.BRANCH_NAME}} --verify-signatures + - git pull origin {{ .BRANCH_NAME }} --verify-signatures #updates the project versions for all inlcuded .NET projects - dotnet-gitversion.exe /updateprojectfiles + test: + desc: 'Builds and runs noscrypt unit tests for vnbuild CI systems' + cmds: + - cmd: task test -- -DNC_ENABLE_UTILS=ON + - cmd: wsl task test -- -DNC_ENABLE_UTILS=ON #called by build pipeline to build module build: @@ -33,7 +38,6 @@ tasks: #git archive in the module directory - git archive --format {{.ARCHIVE_FILE_FORMAT}} --output {{.ARCHIVE_FILE_NAME}} HEAD - #called by build pipeline to clean module clean: cmds: diff --git a/Taskfile.yaml b/Taskfile.yaml index cbc4a7a..b19a135 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -15,6 +15,7 @@ version: '3' vars: CMAKE_BUILD_DIR: 'build/{{ OS }}' TEST_EXE_NAME: 'nctest' + CI_BUILD_CONFIG: '{{ .CI_BUILD_CONFIG | default "Release" }}' tasks: @@ -35,7 +36,7 @@ tasks: desc: "Builds a local copy of the library in a debug configuration, then runs the test executable" cmds: - task: build-debug - - cmd: cd {{.CMAKE_BUILD_DIR}} && ctest -C Debug --verbose + - cmd: cd {{ .CMAKE_BUILD_DIR }} && ctest -C Debug --verbose test-mbedtls: desc: "Builds and runs tests for noscrypt using the mbedtls crypto library for the current platform" @@ -44,36 +45,45 @@ tasks: vars: CMAKE_TEST_STATUS: 'ON' BUILD_CONFIG: 'Debug' - CLI_ARGS: '-DNC_FETCH_MBEDTLS=ON {{.CLI_ARGS}}' #fetches and enabled medtls - - cmd: cd {{.CMAKE_BUILD_DIR}} && ctest -C Debug --verbose + CLI_ARGS: '-DNC_FETCH_MBEDTLS=ON {{ .CLI_ARGS }}' #fetches and enabled medtls + + - cmd: cd {{ .CMAKE_BUILD_DIR }} && ctest -C Debug --verbose test-dev: desc: "Re-runs compilation phase and test execution" cmds: - task: compile vars: { BUILD_CONFIG: 'Debug' } - - cmd: cd {{.CMAKE_BUILD_DIR}} && ctest -C Debug --verbose --output-on-failure - - compile: - internal: true - cmds: - - cmake --build {{.CMAKE_BUILD_DIR}} --config {{.BUILD_CONFIG}} + - cmd: cd {{ .CMAKE_BUILD_DIR }} && ctest -C Debug --verbose --output-on-failure build-internal: internal: true cmds: - - cmake -S . -B{{.CMAKE_BUILD_DIR}} -DCMAKE_BUILD_TYPE={{.BUILD_CONFIG}} -DNC_BUILD_TESTS={{ .CMAKE_TEST_STATUS }} {{.CLI_ARGS}} + - cmd: cmake {{ .CLI_ARGS }} + -S . + -B{{ .CMAKE_BUILD_DIR }} + -DCMAKE_BUILD_TYPE={{ .BUILD_CONFIG }} + -DNC_BUILD_TESTS={{ .CMAKE_TEST_STATUS }} + - task: compile - vars: { BUILD_CONFIG: '{{.BUILD_CONFIG}}' } - - cmd: echo "Build complete. Your files can be found in the {{.CMAKE_BUILD_DIR}} directory" + vars: { BUILD_CONFIG: '{{ .BUILD_CONFIG }}' } + + - cmd: echo "Build complete. Your files can be found in the {{ .CMAKE_BUILD_DIR }} directory" silent: true + compile: + internal: true + cmds: + - cmd: cmake + --build {{ .CMAKE_BUILD_DIR }} + --config {{ .BUILD_CONFIG }} + install: desc: "Uses cmake to install the library on your system" cmds: - cmd: echo "Installing noscrypt globally" silent: true - - cmd: cmake --install {{.CMAKE_BUILD_DIR}} {{.CLI_ARGS}} + - cmd: cmake --install {{ .CMAKE_BUILD_DIR }} {{ .CLI_ARGS }} #CI ONLY!! @@ -81,7 +91,7 @@ tasks: #called by build pipeline to build module build: cmds: - - echo "building project {{.PROJECT_NAME}}" + - echo "building project {{ .PROJECT_NAME }}" - cmd: powershell -Command "mkdir bin/ -Force" ignore_error: true @@ -97,51 +107,59 @@ tasks: cmds: - for: [ bin/, build/ ] task: clean-internal - vars: { FILE: '{{.ITEM}}'} + vars: { FILE: '{{ .ITEM }}'} clean-internal: internal: true ignore_error: true cmds: - - cmd: rm -rf '{{.FILE}}' + - cmd: rm -rf '{{ .FILE }}' platforms: [linux, darwin] - - cmd: powershell rm -Recurse -Force '{{.FILE}}' + - cmd: powershell rm -Recurse -Force '{{ .FILE }}' platforms: [windows] build_win_x64: internal: true + platforms: [ windows ] vars: - TARGET_DLL: '{{.PROJECT_DIR}}/{{.BINARY_DIR}}/msvc-x64-release-{{.PROJECT_NAME}}.tgz' - DLL_FILES: '{{.PROJECT_NAME}}.dll {{.PROJECT_NAME}}.lib license.txt' - TARGET_STATIC: '{{.PROJECT_DIR}}/{{.BINARY_DIR}}/msvc-x64-release-{{.PROJECT_NAME}}-static.tgz' - STATIC_FILES: '{{.PROJECT_NAME}}_static.lib license.txt' + TARGET: '{{ .PROJECT_DIR }}/{{ .BINARY_DIR }}/msvc-x64-{{ .CI_BUILD_CONFIG }}-{{ .PROJECT_NAME }}.tgz' BUILD_DIR: 'build/win-x64' + + TAR_FILES: " + {{ .PROJECT_NAME }}.dll + {{ .PROJECT_NAME }}.lib + {{ .PROJECT_NAME }}_static.lib + license.txt" cmds: #remove deps dir to avoid conflicts with vnbuild - defer: powershell rm -Recurse -Force "{{ .BUILD_DIR }}/_deps" #invoke cmake build - - cmake -S . -B {{.BUILD_DIR}} -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DNC_BUILD_TESTS=OFF - - cmake --build {{.BUILD_DIR}} --config Release + - cmd: cmake + -S . + -B {{ .BUILD_DIR }} + -G "Visual Studio 17 2022" + -A x64 + -DCMAKE_BUILD_TYPE={{ .CI_BUILD_CONFIG }} + -DNC_BUILD_TESTS=OFF + + - cmake --build {{ .BUILD_DIR }} --config {{ .CI_BUILD_CONFIG }} #copy license to build dir - - powershell -Command "cp license {{.BUILD_DIR}}/Release/license.txt" + - cmd: powershell cp license '{{ .BUILD_DIR }}/Release/license.txt' #tar up the binaries - - cd {{.BUILD_DIR}}/Release && tar -czf "{{.TARGET_DLL}}" {{.DLL_FILES}} - - #tar up static libs - - cd {{.BUILD_DIR}}/Release && tar -czf "{{.TARGET_STATIC}}" {{.STATIC_FILES}} + - cmd: cd {{ .BUILD_DIR }}/Release && tar -czf "{{ .TARGET }}" {{ .TAR_FILES }} pack_source: internal: true desc: "Packs up the project source code and creates a tarball in the builds binary directory" vars: - TARGET_SOURCE: '{{.PROJECT_DIR}}/{{.BINARY_DIR}}/{{.PROJECT_NAME}}-src.tgz' + TARGET_SOURCE: '{{ .PROJECT_DIR }}/{{ .BINARY_DIR }}/{{ .PROJECT_NAME }}-src.tgz' SOURCE_FILES: CMakeLists.txt Taskfile.yaml @@ -155,7 +173,7 @@ tasks: cmds: #tar up the source - - tar -czf "{{.TARGET_SOURCE}}" {{ .SOURCE_FILES | join " " }} + - tar -czf "{{ .TARGET_SOURCE }}" {{ .SOURCE_FILES | join " " }} ################################# # @@ -170,7 +188,7 @@ tasks: cmds: - task: compile vars: { BUILD_CONFIG: 'Debug' } - - cmd: gdb '{{.CMAKE_BUILD_DIR}}/{{.TEST_EXE_NAME}}' + - cmd: gdb '{{ .CMAKE_BUILD_DIR }}/{{ .TEST_EXE_NAME }}' dev-update-deps: desc: "Updates vendored projects files (headers mostly) from their source repositories to the latest version" @@ -188,13 +206,13 @@ tasks: MC_DIR: 'vendor/monocypher' TMP_DIR: '.update/mc' cmds: - - cmd: powershell mkdir '{{.TMP_DIR}}' -Force + - cmd: powershell mkdir '{{ .TMP_DIR }}' -Force ignore_error: true - - git clone --branch {{.MC_GIT_BRANCH}} {{.MC_GIT_URL}} '{{.TMP_DIR}}' + - git clone --branch {{ .MC_GIT_BRANCH }} {{ .MC_GIT_URL }} '{{ .TMP_DIR }}' - for: [ 'src/monocypher.h', 'src/monocypher.c' ] - cmd: powershell cp '{{.TMP_DIR}}/{{.ITEM}}' '{{.MC_DIR}}' + cmd: powershell cp '{{ .TMP_DIR }}/{{ .ITEM }}' '{{ .MC_DIR }}' dev-update-mbedtls-headers: vars: @@ -203,13 +221,13 @@ tasks: MBEDTLS_DIR: 'vendor/mbedtls' TMP_DIR: '.update/mbedtls' cmds: - - cmd: powershell mkdir '{{.TMP_DIR}}' -Force + - cmd: powershell mkdir '{{ .TMP_DIR }}' -Force ignore_error: true - git clone --branch {{ .MBEDTLS_GIT_BRANCH }} {{ .MBEDTLS_GIT_URL }} '{{ .TMP_DIR }}' - for: [ 'include/mbedtls' ] - cmd: powershell cp -Recurse -Force '{{ .TMP_DIR }}/{{ .ITEM }}' '{{.MBEDTLS_DIR}}/include' + cmd: powershell cp -Recurse -Force '{{ .TMP_DIR }}/{{ .ITEM }}' '{{ .MBEDTLS_DIR }}/include' dev-update-openssl-headers: vars: @@ -218,13 +236,13 @@ tasks: OPENSSL_DIR: 'vendor/openssl' TMP_DIR: '.update/openssl' cmds: - - cmd: powershell mkdir '{{.TMP_DIR}}' -Force + - cmd: powershell mkdir '{{ .TMP_DIR }}' -Force ignore_error: true - git clone --branch {{ .OPENSSL_GIT_BRANCH }} {{ .OPENSSL_GIT_URL }} '{{ .TMP_DIR }}' - for: [ 'include/openssl' ] - cmd: powershell cp -Recurse -Force '{{ .TMP_DIR }}/{{ .ITEM }}' '{{.OPENSSL_DIR}}/include/' + cmd: powershell cp -Recurse -Force '{{ .TMP_DIR }}/{{ .ITEM }}' '{{ .OPENSSL_DIR }}/include/' dev-set-secp256-headers: vars: @@ -233,10 +251,10 @@ tasks: SECP256_DIR: 'vendor/secp256k1' TMP_DIR: '.update/secp256k1' cmds: - - cmd: powershell mkdir '{{.TMP_DIR}}' -Force + - cmd: powershell mkdir '{{ .TMP_DIR }}' -Force ignore_error: true - git clone --branch {{ .SECP256_GIT_BRANCH }} {{ .SECP256_GIT_URL }} '{{ .TMP_DIR }}' - for: [ 'include/*' ] - cmd: powershell cp -Recurse -Force '{{ .TMP_DIR }}/{{ .ITEM }}' '{{.SECP256_DIR}}/include/secp256k1/' \ No newline at end of file + cmd: powershell cp -Recurse -Force '{{ .TMP_DIR }}/{{ .ITEM }}' '{{ .SECP256_DIR }}/include/secp256k1/' \ No newline at end of file -- cgit