aboutsummaryrefslogtreecommitdiff
path: root/Module.Taskfile.yaml
blob: 99ea9b21a2a7aa07fdaa4f453cb9f617724103a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# https://taskfile.dev

#Called by the vnbuild system to produce builds for my website
#https://www.vaughnnugent.com/resources/software

#This taskfile performs the build operations for a module, it handles
#git code updates, msbuild on solutions, and sleet NuGet feed pushes.

#this file must be in the same directory as the solution file

version: '3'

vars:  
  MS_ARGS: '/p:RunAnalyzersDuringBuild=false /p:UseCommonOutputDirectory=true /p:BuildInParallel=true /p:MultiProcessorCompilation=true /p:ErrorOnDuplicatePublishOutputFiles=false'
  PACK_OUT: '{{ .OUTPUT_DIR }}/{{ .HEAD_SHA }}/pkg'

tasks:

  default:
    desc: 'Builds the managed libraries in this module for development'
    cmds:
      - dotnet build -c debug {{ .MS_ARGS }}
 

#called by build pipeline to sync repo
  update:
    cmds:
     - git reset --hard  #clean up any local changes
     - git remote update
     - git pull origin {{ .BRANCH_NAME }} --verify-signatures 
     #re-write semver after hard reset
     - dotnet-gitversion.exe /updateprojectfiles

#called by build pipeline to build module
  build:
    desc: "Used by vnbuild to build the entire module at CI time"
    vars:
      INT_DIR: '{{ .SCRATCH_DIR }}/obj/{{ .MODULE_NAME }}/'
      MS_ARGS: '{{ .MS_ARGS }} /p:IntermediateOutputPath="{{ .INT_DIR }}"'
    cmds:
     - cmd: echo "building module {{ .MODULE_NAME }}" 
       silent: true

     #build debug mode first
     - task: build_debug
       vars: { MS_ARGS: '{{ .MS_ARGS }}'}
     - task: build_release
       vars: { MS_ARGS: '{{ .MS_ARGS }}'}

  publish:
    desc: "Used by vnbuild to prepare the packages for build servers"      
    cmds:
     #git archive in the module directory
     - git archive --format {{ .ARCHIVE_FILE_FORMAT }} --output {{ .ARCHIVE_FILE_NAME }} HEAD
     #push packages to the sleet feed (feed path is vnbuild global)
     - sleet push "{{ .PACK_OUT }}/debug/" --source debug --config "{{ .SLEET_CONFIG_PATH }}" --force
     - sleet push "{{ .PACK_OUT }}/release/" --source release --config "{{ .SLEET_CONFIG_PATH }}" --force

  test:
    desc: "Runs managed tests against the entire solution and all loaded test projects"
    vars:
      RPMALLOC_LIB_PATH: '{{ .USER_WORKING_DIR }}/lib/Utils.Memory/vnlib_rpmalloc/build/Debug/vnlib_rpmalloc'
      MIMALLOC_LIB_PATH: '{{ .USER_WORKING_DIR }}/lib/Utils.Memory/vnlib_mimalloc/build/Debug/vnlib_mimalloc'
    cmds:
     - cmd: echo "Ensure you have run 'task dev-init' before running tests to build native libraries"
       silent: true
     - cmd: dotnet test
        {{ .CLI_ARGS }}
        --verbosity normal
        --framework {{ .FRAMEWORK | default "net8.0" }}
        --environment VNLIB_SHARED_HEAP_DIAGNOSTICS="1"
        --environment TEST_RPMALLOC_LIB_PATH="{{ .RPMALLOC_LIB_PATH }}"
        --environment TEST_MIMALLOC_LIB_PATH="{{ .MIMALLOC_LIB_PATH }}"
  

#called by build pipeline to clean module
  clean:
    ignore_error: true
    cmds:
    #clean solution
     - dotnet clean /p:BuildInParallel=true /p:MultiProcessorCompilation=true
     - cmd: powershell -Command "rm {{ .ARCHIVE_FILE_NAME }} --Force" 

  dev-init:
    desc: 'Configures the module for local development'
    cmds:
    #build native libs for development
     - cd lib/Utils.Memory/vnlib_rpmalloc && task dev-init
     - cd lib/Utils.Memory/vnlib_mimalloc && task dev-init
     - cd lib/Utils.Cryptography/monocypher && task build
     - cd lib/Utils.Cryptography/argon2 && task build
     - cd lib/Net.Compression/vnlib_compress && task build 
     - cmd: echo "dev init complete"
       silent: true
    

#Internal tasks
  build_debug:
    internal: true
    cmds:
     - dotnet publish -c debug {{ .MS_ARGS }}
     - dotnet pack -c debug {{ .MS_ARGS }} -o "{{ .PACK_OUT }}/debug/" -p:PackageVersion={{ .BUILD_VERSION }}
     
  build_release:
    internal: true
    cmds:
     - dotnet publish -c release {{ .MS_ARGS }}
     - dotnet pack -c release {{ .MS_ARGS }} -o "{{ .PACK_OUT }}/release/" -p:PackageVersion={{ .BUILD_VERSION }}