aboutsummaryrefslogtreecommitdiff
path: root/plugins/ObjectCacheServer/server/taskfile.yaml
blob: 83b8e7079bd4382768312e997cae93f6c2f8fc97 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# https://taskfile.dev

#Inlcuded taskfile for object cache server that is used to produce
#ci builds for standalone caching servers

version: "3"

vars:
  SCRIPT_DIR: '{{.TASKFILE_DIR}}'
  BINARY_DIR: '{{.PROJECT_DIR}}/bin'        #binary dir is not available for dotnet plugis 

includes:

  container:
    dir: container  #always run from the container directory
    taskfile: container/Taskfile.yaml
    optional: true
    vars:
      BUILDS_URL: '{{.BUILDS_URL}}'
      PACKAGE_FILE_NAME: "vncache-alpine3.19-oci.tgz"  #the name of the output package file

tasks:
# CLIENT-SIDE TASKS
  default:
    desc: "Runs the VNCache server"
    cmds:
    - task: run

  run:
    desc: "Runs the VNCache server"
    silent: true
    env: 
      #server should detect the file extension and load the correct library
      VNLIB_SHARED_HEAP_FILE_PATH: lib/libvn_rpmalloc  

    cmds:   
    - cmd: dotnet webserver/VNLib.WebServer.dll --config config/config.json --input-off {{.CLI_ARGS}}
      #setup sever environment     

  setup-apt:
     desc: "Performs initial setup on Debian/APT x64 based machines"
     silent: true
     cmds:
     - apt update
     - apt install -y dotnet-runtime-8.0 gcc cmake  
     - task: setup
     - echo "Setup complete" 
 
  setup-dnf:
     desc: "Performs initial setup on Fedora using DNF x64 (dnf) based machines"
     silent: true
     cmds:
     - dnf update
     - dnf install -y dotnet-runtime-8.0 gcc cmake
     - task: setup
     - echo "Setup complete"
 
  setup-alpine:
     desc: "Performs initial setup on Alpine using APK x64 based machines"
     silent: true
     cmds:
     - apk update
     - apk add --no-cache dotnet8-runtime gcc cmake
     - task: setup
     - echo "Setup complete"

  setup:
    cmds:
    #build rpmalloc lib
    - task: build-rpmalloc

  build-rpmalloc:
    internal: true
    dir: 'lib/'
    vars:
      RPMALLOC_DIR: 'vnlib_rpmalloc'
    cmds:
      #build rpmalloc library
     - cmd: cd vnlib_rpmalloc/ && task
   
     - cmd: cp vnlib_rpmalloc/build/libvn_rpmalloc.so libvn_rpmalloc.so
       platforms: [ linux ]
    
     - cmd: cp vnlib_rpmalloc/build/libvn_rpmalloc.dylib libvn_rpmalloc.dylib
       platforms: [ darwin ]

     - cmd: powershell -Command "cp vnlib_rpmalloc/build/Release/vnlib_rpmalloc.dll libvn_rpmalloc.dll"
       platforms: [ windows/amd64 ]

# CI BUILD TASKS
  build:
    desc: "CI ONLY! DO NOT RUN"
    cmds:
    - task: install-plugins
    - task: install-webserver
    
    #run container build last
    - task: container:build

  install-webserver:
    internal: true
    cmds:
      #create a server environment for each target os
    - for: [ win-x64, linux-x64, osx-x64, linux-arm64 ]
      task: create-env
      vars: 
        TARGET_OS: '{{.ITEM}}'

  install-plugins:
    internal: true
    vars:
      RPMALLOC_SRC: 'core/lib/Utils.Memory/vnlib_rpmalloc/bin/src.tgz'
    cmds:
    - cmd: powershell -Command "mkdir lib -Force"
      ignore_error: true

    #copy the object-cache plugin output to the local plugins directory
    - cmd: powershell -Command "cp -Recurse -Force {{.PROJECT_DIR}}/bin/Release/net8.0/publish/ plugins/{{.PROJECT_NAME}}"
    
    #copy local rpmalloc library to the local lib directory
    - cmd: powershell mkdir lib/vnlib_rpmalloc -Force
    - cmd: cd '{{.MODULE_DIR}}' && cd .. && powershell cp '{{.RPMALLOC_SRC}}' '{{.TASKFILE_DIR}}/lib/vnlib_rpmalloc/src.tgz'
    - cmd: cd lib/vnlib_rpmalloc && tar -xzf src.tgz
    - for: [ src.tgz, package.json ]
      cmd: cd lib/vnlib_rpmalloc && powershell rm {{.ITEM}}

  postbuild_success:
    desc: "CI ONLY! DO NOT RUN"
    cmds:
    - for: [ win-x64, linux-x64, osx-x64, linux-arm64 ]
      task: pack
      vars: 
        TARGET_OS: '{{.ITEM}}'

    #cleanup unnecessary build files that clog up the pipeline
    - for: [ build, plugins, lib ]
      cmd: powershell -Command "rm -Recurse '{{.ITEM}}'"
      ignore_error: true

    - task: container:postbuild_success
    
  #Creates a new webserver build environment for an operating system configuration
  create-env:
    #internal: true
    vars:
      BUILD_DIR: 'build/{{.TARGET_OS}}'
    cmds:
    #create dir for env
    - cmd: powershell -Command "mkdir {{.BUILD_DIR}} -Force"
      ignore_error: true
    
    #copy build files
    - for: [ plugins, lib, config, taskfile.yaml ]
      cmd: powershell -Command "cp -Recurse -Force {{.ITEM}} {{.BUILD_DIR}}"

    - task: get-webserver
      vars:
        TARGET_OS: '{{.TARGET_OS}}'
        BUILD_DIR: '{{.BUILD_DIR}}'

  #fetches a copy of (the desired os version) VNLib.WebServer project and installs it into the build directory
  get-webserver:
    internal: true
    vars:
      TARGET_DIR: '{{.TASKFILE_DIR}}/{{.BUILD_DIR}}/webserver/'
      TARGET_FILENAME: '{{.TARGET_OS}}-release.tgz'
      CI_WEBSERVER_DIR: 'VNLib.WebServer/src/bin'
    cmds:
    #copy an existing webserver build to the build directory
    - cmd: powershell -Command "mkdir {{.TARGET_DIR}} -Force"
    - cmd: cd '{{.MODULE_DIR}}' && cd .. && powershell cp -Recurse -Force '{{.CI_WEBSERVER_DIR}}/{{.TARGET_FILENAME}}' '{{.TARGET_DIR}}{{.TARGET_FILENAME}}'
    - cmd: cd '{{.TARGET_DIR}}' && tar -xzf {{.TARGET_FILENAME}}
    - cmd: powershell rm '{{.TARGET_DIR}}/{{.TARGET_FILENAME}}'
 
  pack:
    internal: true
    cmds:
    - cd build/{{.TARGET_OS}} && tar -czf '{{ .BINARY_DIR }}/{{ .TARGET_OS }}-release.tgz' .

  clean:
    desc: "CI ONLY! DO NOT RUN"
    ignore_error: true
    cmds:
    - for: [ build/, bin/, plugins/, lib/]
      cmd: powershell -Command "rm -Recurse -Force '{{.ITEM}}'"
    
    - task: container:clean