aboutsummaryrefslogtreecommitdiff
path: root/Taskfile.yaml
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-11-13 22:25:32 -0500
committerLibravatar vnugent <public@vaughnnugent.com>2024-11-13 22:25:32 -0500
commit5cf1addc4a7b70aafda5ad8953f114a206df93cc (patch)
treed478524ea1ed7676f530f2eb26af644024d6aeca /Taskfile.yaml
parent0baa4afd4716ad4d6d2f37b9d4af4fc839d16d7c (diff)
integrate mbedtls testing and remove mbedtls fetch
Diffstat (limited to 'Taskfile.yaml')
-rw-r--r--Taskfile.yaml405
1 files changed, 298 insertions, 107 deletions
diff --git a/Taskfile.yaml b/Taskfile.yaml
index be5ea48..98eb1db 100644
--- a/Taskfile.yaml
+++ b/Taskfile.yaml
@@ -27,8 +27,11 @@ tasks:
build-debug:
desc: "Build libraries and test executable in debug mode"
+ summary: |
+ Runs the CMake configure and compile steps to build the library
+ and test executable in debug mode.
cmds:
- - task: build-internal
+ - task: cmake-build
vars: { CMAKE_TEST_STATUS: 'ON', BUILD_CONFIG: 'Debug' }
#available to users and vnbuild runner
@@ -36,71 +39,25 @@ 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
-
- dev:
- watch: true
- sources:
- - include/*
- - src/*
- - src/*/*
- - tests/*
- - CMakelists.txt
- - vendor/*
- cmds:
- - task: test-dev
-
- test-mbedtls:
- desc: "Builds and runs tests for noscrypt using the mbedtls crypto library for the current platform"
- cmds:
- - task: build-internal
- 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
-
- 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
- - task: memcheck
-
- build-internal:
- internal: true
- cmds:
- - 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"
- silent: true
-
- compile:
- internal: true
- cmds:
- - cmd: cmake
- --build {{ .CMAKE_BUILD_DIR }}
- --config {{ .BUILD_CONFIG }}
+
+ - task: cmake-test
+ vars: { CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}' }
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 }}
+ - task: cmake-install
#Test executable and library must be built for tests to run
memcheck:
desc: 'Runs Valgrind memcheck in debug mode against the nctest executable (Linux only)'
+ summary: |
+ Runs Valgrind memcheck in debug mode against the nctest executable.
+ This task is only available on Linux platforms with Valgrind and the
+ Memcheck tool is installed. You must build the test executable in debug
+ mode before running this task.
platforms:
- linux
preconditions:
@@ -116,76 +73,233 @@ tasks:
--track-origins=yes
{{ .CMAKE_BUILD_DIR }}/{{ .TEST_EXE_NAME }}
-#CI ONLY!!
-
- #called by build pipeline to build module
- build:
- cmds:
- - echo "building project {{ .PROJECT_NAME }}"
- - cmd: powershell -Command "mkdir bin/ -Force"
- ignore_error: true
-
- #build windows x64
- - task: build_win_x64
-
- #pack source
- - task: pack_source
-
clean:
- desc: "Cleans the artifact directory"
+ desc: "Cleans the build and artifact directories"
ignore_error: true
cmds:
- for: [ bin/, build/ ]
task: clean-internal
vars: { FILE: '{{ .ITEM }}'}
-
+#################################
+#
+# INTERNAL TASKS
+#
+#################################
+
clean-internal:
internal: true
ignore_error: true
+ requires: { FILE }
cmds:
- cmd: rm -rf '{{ .FILE }}'
platforms: [linux, darwin]
- cmd: powershell rm -Recurse -Force '{{ .FILE }}'
platforms: [windows]
+
+ #build-internal:
+ cmake-configue:
+ internal: true
+ requires: { CMAKE_BUILD_DIR, BUILD_CONFIG, CMAKE_TEST_STATUS }
+ cmds:
+ - cmd: cmake
+ -S .
+ -B{{ .CMAKE_BUILD_DIR }}
+ -DCMAKE_BUILD_TYPE={{ .BUILD_CONFIG }}
+ -DNC_BUILD_TESTS={{ .CMAKE_TEST_STATUS }}
+ {{ .CLI_ARGS }}
+ {{ .CMAKE_CONFIG_ARGS }}
+
- build_win_x64:
+ #perfoms CMake compile step
+ cmake-compile:
internal: true
- platforms: [ windows ]
- vars:
- TARGET: '{{ .PROJECT_DIR }}/{{ .BINARY_DIR }}/msvc-x64-{{ .CI_BUILD_CONFIG }}-{{ .PROJECT_NAME }}.tgz'
- BUILD_DIR: 'build/win-x64'
+ requires: { CMAKE_BUILD_DIR, BUILD_CONFIG }
+ cmds:
+ - cmd: cmake --build {{ .CMAKE_BUILD_DIR }} --config {{ .BUILD_CONFIG }}
+
+ #runs the configure and compile cmake steps
+ cmake-build:
+ internal: true
+ requires: { CMAKE_BUILD_DIR, BUILD_CONFIG, CMAKE_TEST_STATUS }
+ cmds:
+ - task: cmake-configue
+ vars:
+ CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}'
+ BUILD_CONFIG: '{{ .BUILD_CONFIG }}'
+ CMAKE_TEST_STATUS: '{{ .CMAKE_TEST_STATUS }}'
+ CMAKE_CONFIG_ARGS: '{{ .CMAKE_CONFIG_ARGS }}'
+
+ - task: cmake-compile
+ vars:
+ CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}'
+ BUILD_CONFIG: '{{ .BUILD_CONFIG }}'
- TAR_FILES: "
- {{ .PROJECT_NAME }}.dll
- {{ .PROJECT_NAME }}.lib
- {{ .PROJECT_NAME }}_static.lib
- license.txt"
-
+ #runs the cmake install step
+ cmake-install:
+ internal: true
+ requires: { CMAKE_BUILD_DIR }
cmds:
- #remove deps dir to avoid conflicts with vnbuild
- - defer: powershell rm -Recurse -Force "{{ .BUILD_DIR }}/_deps"
+ - cmd: cmake --install {{ .CMAKE_BUILD_DIR }} {{ .CLI_ARGS }}
+
+ cmake-test:
+ internal: true
+ requires: { CMAKE_BUILD_DIR }
+ cmds:
+ - cmd: cd {{ .CMAKE_BUILD_DIR }} && ctest -C Debug --verbose --output-on-failure
+
+ mbedtls-download:
+ internal: true
+ vars:
+ MBEDTLS_VERSION: '3.6.2'
+ MBEDTLS_DOWNLOAD_URL: 'https://github.com/Mbed-TLS/mbedtls/releases/download/mbedtls-{{ .MBEDTLS_VERSION }}/mbedtls-{{ .MBEDTLS_VERSION }}.tar.bz2'
+ MBEDTLS_DOWNLOAD_DIR: '{{ .CMAKE_BUILD_DIR }}/_deps'
+ MBEDTLS_SHA256: ''
+ MBEDTLS_SRC_DIR: '{{ .CMAKE_BUILD_DIR }}/_deps/mbedtls'
+ cmds:
+ #remove source dirs if they exist
+ - cmd: rm -rf '{{ .MBEDTLS_SRC_DIR }}' && mkdir -p '{{ .MBEDTLS_SRC_DIR }}'
+ platforms: [linux, darwin]
+ - cmd: powershell rm -Recurse -Force '{{ .MBEDTLS_SRC_DIR }}' && mkdir '{{ .MBEDTLS_SRC_DIR }}'
+ platforms: [windows]
+ ignore_error: true
+
+ #download mbedtls archive
+ - cmd: curl{{ exeExt }} -L '{{ .MBEDTLS_DOWNLOAD_URL }}' -o '{{ .MBEDTLS_DOWNLOAD_DIR }}/mbedtls.tar.bz2'
+
+ #extract the archive using bz2 (linux only)
+ - cmd: '{{ if eq OS "windows" }}wsl{{ end }} tar -xjf "{{ .MBEDTLS_DOWNLOAD_DIR }}/mbedtls.tar.bz2" -C "{{ .MBEDTLS_DOWNLOAD_DIR }}"'
+
+ #rename the extracted directory
+ - cmd: 'mv -T "{{ .MBEDTLS_DOWNLOAD_DIR }}/mbedtls-{{ .MBEDTLS_VERSION }}/" "{{ .MBEDTLS_SRC_DIR }}/"'
+ platforms: [linux, darwin]
+ - cmd: powershell Rename-Item -Force -Path "{{ .MBEDTLS_DOWNLOAD_DIR }}/mbedtls-{{ .MBEDTLS_VERSION }}/" -NewName "mbedtls"
+ platforms: [windows]
+
+ mbedtls-configure:
+ internal: true
+ requires: { CMAKE_BUILD_DIR }
+ vars:
+ MBEDTLS_SRC_DIR: '{{ .CMAKE_BUILD_DIR }}/_deps/mbedtls'
+ MBEDTLS_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}/_deps/mbedtls-build'
+ MBEDTLS_CONFIG_FILE: '{{ .USER_WORKING_DIR }}/vendor/mbedtls/mbedtls_noscrypt_config.h'
+ cmds:
+ #clear build dir before re-configuring
+ - cmd: '{{ if eq OS "windows"}}powershell{{ end }} rm -r {{ .MBEDTLS_BUILD_DIR }}'
+ ignore_error: true
- #invoke cmake build
- 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 }}
+ -S '{{ .MBEDTLS_SRC_DIR }}'
+ -B '{{ .MBEDTLS_BUILD_DIR }}'
+ -DCMAKE_BUILD_TYPE=Release
+ -DENABLE_PROGRAMS=OFF
+ -DENABLE_TESTING=OFF
+ -DBUILD_SHARED_LIBS=OFF
+ -DUSE_SHARED_MBEDTLS_LIBRARY=OFF
+ -DUSE_STATIC_MBEDTLS_LIBRARY=ON
+ -DDISABLE_PACKAGE_CONFIG_AND_INSTALL=ON
+ -DMBEDTLS_CONFIG_FILE='{{ .MBEDTLS_CONFIG_FILE }}'
+
+ mbedtls-compile:
+ internal: true
+ requires: { CMAKE_BUILD_DIR }
+ vars:
+ MBEDTLS_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}/_deps/mbedtls-build'
+ cmds:
+ - cmd: cmake --build '{{ .MBEDTLS_BUILD_DIR }}' --config Release
- #copy license to build dir
- - cmd: powershell cp license '{{ .BUILD_DIR }}/Release/license.txt'
+ mbedtls-build:
+ internal: true
+ desc: "Downloads, configures, and compiles mbedtls"
+ requires: { CMAKE_BUILD_DIR }
+ cmds:
+ - task: mbedtls-download
+ vars: { CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}' }
+ - task: mbedtls-configure
+ vars: { CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}' }
+ - task: mbedtls-compile
+ vars: { CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}' }
- #tar up the binaries
- - cmd: cd {{ .BUILD_DIR }}/Release && tar -czf "{{ .TARGET }}" {{ .TAR_FILES }}
+#################################
+#
+# CI TASKS
+#
+#################################
+
+ # runs the cmake setups to configure the mbedtls library build for testing
+ ci-configure-mbedtls:
+ internal: false
+ requires: { CMAKE_BUILD_DIR }
+ cmds:
+ - task: mbedtls-build
+ vars: { CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}' }
+
+ - task: cmake-build
+ vars:
+ CMAKE_TEST_STATUS: 'ON'
+ BUILD_CONFIG: 'Debug'
+ CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}'
+ CMAKE_CONFIG_ARGS: '
+ -DNC_ENABLE_UTILS=ON
+ -DCRYPTO_LIB=mbedtls
+ -DCRYPTO_LIB_DIR={{ .CMAKE_BUILD_DIR }}/_deps/mbedtls-build'
+
+ # runs the cmake setups to configure the default library build for testing
+ ci-configure-default:
+ internal: true
+ requires: { CMAKE_BUILD_DIR }
+ cmds:
+ - task: cmake-build
+ vars:
+ CMAKE_TEST_STATUS: 'ON'
+ BUILD_CONFIG: 'Debug'
+ CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}'
+ CMAKE_CONFIG_ARGS: '-DNC_ENABLE_UTILS=ON'
+ # runs cmake testing and memcheck on the mbedtls build
+ ci-test-mbedtls:
+ internal: false
+ requires: { CMAKE_BUILD_DIR }
+ cmds:
+ - task: cmake-test
+ vars: { CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}' }
+
+ #runs memcheck if the platform supports it
+ - task: memcheck
+ vars: { CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}' }
- pack_source:
+ # runs cmake testing and memcheck on the default build
+ ci-test-default:
+ internal: true
+ requires: { CMAKE_BUILD_DIR }
+ cmds:
+ - task: cmake-test
+ vars: { CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}' }
+
+ #runs memcheck if the platform supports it
+ - task: memcheck
+ vars: { CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}' }
+
+ # called by Module.taskfile to run tests
+ ci-test:
+ vars:
+ CMAKE_CONFIG_ARGS: '-DNC_ENABLE_UTILS'
+ MBEDTLS_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}/mbedtls'
+ DEFAULT_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}/default'
+ deps:
+ - task: ci-configure-default
+ vars: { CMAKE_BUILD_DIR: '{{ .DEFAULT_BUILD_DIR }}' }
+ - task: ci-configure-mbedtls
+ vars: { CMAKE_BUILD_DIR: '{{ .MBEDTLS_BUILD_DIR }}' }
+ cmds:
+ - task: ci-test-default
+ vars: { CMAKE_BUILD_DIR: '{{ .DEFAULT_BUILD_DIR }}'}#
+
+ - task: ci-test-mbedtls
+ vars: { CMAKE_BUILD_DIR: '{{ .MBEDTLS_BUILD_DIR }}'}
+
+ ci-pack-source:
internal: true
desc: "Packs up the project source code and creates a tarball in the builds binary directory"
vars:
@@ -203,27 +317,104 @@ tasks:
cmds:
#tar up the source
- - tar -czf "{{ .TARGET_SOURCE }}" {{ .SOURCE_FILES | join " " }}
-
+ - cmd: tar -czf "{{ .TARGET_SOURCE }}" {{ .SOURCE_FILES | join " " }}
+
+ ci-build-win_x64:
+ internal: true
+ platforms: [ windows ]
+ vars:
+ 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"
+
+ #run configure and compile commands
+ - task: cmake-build
+ vars:
+ CMAKE_BUILD_DIR: '{{ .BUILD_DIR }}'
+ BUILD_CONFIG: '{{ .CI_BUILD_CONFIG }}'
+ CMAKE_TEST_STATUS: 'OFF'
+ CMAKE_CONFIG_ARGS: '-G "Visual Studio 17 2022" -A x64 -NC_ENABLE_UTILS'
+
+ #copy license to build dir
+ - cmd: powershell cp license '{{ .BUILD_DIR }}/{{ .CI_BUILD_CONFIG }}/license.txt'
+
+ #tar up the binaries
+ - cmd: cd {{ .BUILD_DIR }}/{{ .CI_BUILD_CONFIG }} && tar -czf "{{ .TARGET }}" {{ .TAR_FILES }}
+
+ #called by build pipeline to build module
+ build:
+ cmds:
+ - cmd: echo "building project {{ .PROJECT_NAME }}"
+ - cmd: powershell "mkdir bin/ -Force"
+ ignore_error: true
+
+ #build windows x64
+ - task: ci-build-win_x64
+
+ #pack source
+ - task: ci-pack-source
+
#################################
#
# DEV TASKS
#
#################################
+ dev-test:
+ desc: "Re-runs compilation phase and test executable"
+ cmds:
+ - task: cmake-compile
+ vars: { BUILD_CONFIG: 'Debug' }
+
+ - task: cmake-test
+ vars: { CMAKE_BUILD_DIR: '{{ .CMAKE_BUILD_DIR }}' }
+
+ - task: memcheck
+
+ dev:
+ desc: "Runs local development tests and watches for changes"
+ summary: |
+ Watches for changes to source and config files, recompiles, and runs tests
+ automatically when changes are detected.
+ watch: true
+ sources:
+ - include/*
+ - src/*
+ - src/*/*
+ - tests/*
+ - CMakelists.txt
+ - vendor/*
+ cmds:
+ - task: dev-test
+
dev-gdb-test:
platforms: [ linux ]
desc: "Starts a new gdb session on the test executable"
+ summary: |
+ (Linux only) Starts a new gdb session on the test executable.
+ Use the 'run' command to start the test executable.
interactive: true
cmds:
- - task: compile
+ - task: cmake-compile
vars: { BUILD_CONFIG: 'Debug' }
+
- 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"
+ desc: "Updates vendored projects files (headers mostly) from their source repositories to the configured version"
cmds:
- defer: powershell rm -Recurse '.update/' -Force
+
+ #must run serially since git does not support mutliple instances
- task: dev-update-monocypher
- task: dev-update-mbedtls-headers
- task: dev-update-openssl-headers
@@ -257,7 +448,7 @@ tasks:
- 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 }}'
dev-update-openssl-headers:
vars:
@@ -272,7 +463,7 @@ tasks:
- 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 }}'
dev-set-secp256-headers:
vars:
@@ -287,4 +478,4 @@ tasks:
- 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 }}' \ No newline at end of file