mirror of
https://github.com/ohwgiles/laminar.git
synced 2026-10-12 22:20:47 +00:00
Compare commits
3 Commits
master
...
tmp-better
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ed63abd0d | ||
|
|
9db4211091 | ||
|
|
b38cbe5827 |
@@ -1,5 +1,5 @@
|
||||
###
|
||||
### Copyright 2015-2026 Oliver Giles
|
||||
### Copyright 2015-2021 Oliver Giles
|
||||
###
|
||||
### This file is part of Laminar
|
||||
###
|
||||
@@ -16,48 +16,11 @@
|
||||
### You should have received a copy of the GNU General Public License
|
||||
### along with Laminar. If not, see <http://www.gnu.org/licenses/>
|
||||
###
|
||||
cmake_minimum_required(VERSION 3.18)
|
||||
project(laminar)
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||
# ld.lld is a default option on FreeBSD
|
||||
set(LLVM_LINKER_IS_LLD ON)
|
||||
endif()
|
||||
|
||||
# ld.lld specific options. There is no sane way in cmake
|
||||
# to detect if toolchain is actually using ld.lld
|
||||
if (LLVM_LINKER_IS_LLD)
|
||||
if (NOT DEFINED LINKER_EMULATION_FLAGS)
|
||||
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
|
||||
set(LINKER_EMULATION_FLAGS "-melf_x86_64")
|
||||
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
|
||||
set(LINKER_EMULATION_FLAGS "-melf_x86_64")
|
||||
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
|
||||
set(LINKER_EMULATION_FLAGS "-maarch64elf")
|
||||
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "powerpc64le")
|
||||
set(LINKER_EMULATION_FLAGS "-melf64lppc")
|
||||
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "powerpc64")
|
||||
set(LINKER_EMULATION_FLAGS "-melf64ppc")
|
||||
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "riscv64")
|
||||
# llvm17 & riscv64 requires extra step, it is necessary to
|
||||
# patch 'Elf64.e_flags' (48-th byte) in binary-blob object files
|
||||
# with value 0x5 - to change soft_float ABI to hard_float ABI
|
||||
# so they can link with rest of the object files.
|
||||
set(LINKER_EMULATION_FLAGS "-melf64lriscv")
|
||||
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm")
|
||||
set(LINKER_EMULATION_FLAGS "-marmelf")
|
||||
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7")
|
||||
set(LINKER_EMULATION_FLAGS "-marmelf")
|
||||
else()
|
||||
message(FATAL_ERROR
|
||||
"Unsupported '${CMAKE_SYSTEM_PROCESSOR}' translation to emulation flag. "
|
||||
"Please set it explicitly 'cmake -DLINKER_EMULATION_FLAGS=\"-melf_your_arch\" ...'")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Werror -DDEBUG")
|
||||
@@ -93,7 +56,7 @@ macro(generate_compressed_bins BASEDIR)
|
||||
DEPENDS ${BASEDIR}/${FILE}
|
||||
)
|
||||
add_custom_command(OUTPUT ${OUTPUT_FILE}
|
||||
COMMAND ${CMAKE_LINKER} ${LINKER_EMULATION_FLAGS} -r -b binary -o ${OUTPUT_FILE} ${COMPRESSED_FILE}
|
||||
COMMAND ${CMAKE_LINKER} -r -b binary -o ${OUTPUT_FILE} ${COMPRESSED_FILE}
|
||||
COMMAND ${CMAKE_OBJCOPY}
|
||||
--rename-section .data=.rodata.alloc,load,readonly,data,contents
|
||||
--add-section .note.GNU-stack=/dev/null
|
||||
@@ -121,11 +84,11 @@ add_custom_command(OUTPUT index_html_size.h
|
||||
|
||||
# Download 3rd-party frontend JS libs...
|
||||
file(DOWNLOAD https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.12/vue.min.js
|
||||
${CMAKE_BINARY_DIR}/js/vue.min.js EXPECTED_MD5 fb192338844efe86ec759a40152fcb8e)
|
||||
file(DOWNLOAD https://raw.githubusercontent.com/drudru/ansi_up/v5.2.1/ansi_up.js
|
||||
${CMAKE_BINARY_DIR}/js/ansi_up.js EXPECTED_MD5 77202f7815d9d7f7764793d93598ba88)
|
||||
js/vue.min.js EXPECTED_MD5 fb192338844efe86ec759a40152fcb8e)
|
||||
file(DOWNLOAD https://raw.githubusercontent.com/drudru/ansi_up/v4.0.4/ansi_up.js
|
||||
js/ansi_up.js EXPECTED_MD5 b31968e1a8fed0fa82305e978161f7f5)
|
||||
file(DOWNLOAD https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.9.1/chart.min.js
|
||||
${CMAKE_BINARY_DIR}/js/Chart.min.js EXPECTED_MD5 7dd5ea7d2cf22a1c42b43c40093d2669)
|
||||
js/Chart.min.js EXPECTED_MD5 7dd5ea7d2cf22a1c42b43c40093d2669)
|
||||
# ...and compile them
|
||||
generate_compressed_bins(${CMAKE_BINARY_DIR} js/vue.min.js
|
||||
js/ansi_up.js js/Chart.min.js)
|
||||
@@ -146,35 +109,13 @@ set(LAMINARD_CORE_SOURCES
|
||||
index_html_size.h
|
||||
)
|
||||
|
||||
find_package(CapnProto REQUIRED)
|
||||
include_directories(${CAPNP_INCLUDE_DIRS})
|
||||
|
||||
find_package(SQLite3 REQUIRED)
|
||||
include_directories(${SQLite3_INCLUDE_DIRS})
|
||||
|
||||
if(NOT TARGET SQLite3::SQLite3) # CMake < 4.3
|
||||
add_library(SQLite3::SQLite3 ALIAS SQLite::SQLite3)
|
||||
endif()
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
include_directories(${Threads_INCLUDE_DIRS})
|
||||
|
||||
## Server
|
||||
add_executable(laminard ${LAMINARD_CORE_SOURCES} src/main.cpp ${COMPRESSED_BINS})
|
||||
target_link_libraries(laminard CapnProto::capnp-rpc CapnProto::capnp CapnProto::kj-http CapnProto::kj-async
|
||||
CapnProto::kj Threads::Threads SQLite3::SQLite3 ZLIB::ZLIB)
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||
pkg_check_modules(INOTIFY REQUIRED libinotify)
|
||||
target_link_libraries(laminard ${INOTIFY_LINK_LIBRARIES})
|
||||
endif()
|
||||
target_link_libraries(laminard capnp-rpc capnp kj-http kj-async kj pthread sqlite3 z)
|
||||
|
||||
## Client
|
||||
add_executable(laminarc src/client.cpp src/version.cpp laminar.capnp.c++)
|
||||
target_link_libraries(laminarc CapnProto::capnp-rpc CapnProto::capnp CapnProto::kj-async CapnProto::kj Threads::Threads)
|
||||
target_link_libraries(laminarc capnp-rpc capnp kj-async kj pthread)
|
||||
|
||||
## Manpages
|
||||
macro(gzip SOURCE)
|
||||
@@ -195,10 +136,10 @@ if(BUILD_TESTS)
|
||||
find_package(GTest REQUIRED)
|
||||
include_directories(${GTEST_INCLUDE_DIRS} src)
|
||||
add_executable(laminar-tests ${LAMINARD_CORE_SOURCES} ${COMPRESSED_BINS} test/main.cpp test/laminar-functional.cpp test/unit-conf.cpp test/unit-database.cpp)
|
||||
target_link_libraries(laminar-tests ${GTEST_LIBRARIES} CapnProto::capnp-rpc CapnProto::capnp CapnProto::kj-http CapnProto::kj-async CapnProto::kj
|
||||
Threads::Threads SQLite3::SQLite3 ZLIB::ZLIB)
|
||||
target_link_libraries(laminar-tests ${GTEST_LIBRARIES} capnp-rpc capnp kj-http kj-async kj pthread sqlite3 z)
|
||||
endif()
|
||||
|
||||
set(SYSTEMD_UNITDIR /lib/systemd/system CACHE PATH "Path to systemd unit files")
|
||||
set(BASH_COMPLETIONS_DIR /usr/share/bash-completion/completions CACHE PATH "Path to bash completions directory")
|
||||
set(ZSH_COMPLETIONS_DIR /usr/share/zsh/site-functions CACHE PATH "Path to zsh completions directory")
|
||||
install(TARGETS laminard RUNTIME DESTINATION sbin)
|
||||
@@ -207,8 +148,5 @@ install(FILES etc/laminar.conf DESTINATION /etc)
|
||||
install(FILES etc/laminarc-completion.bash DESTINATION ${BASH_COMPLETIONS_DIR} RENAME laminarc)
|
||||
install(FILES etc/laminarc-completion.zsh DESTINATION ${ZSH_COMPLETIONS_DIR} RENAME _laminarc)
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
set(SYSTEMD_UNITDIR /lib/systemd/system CACHE PATH "Path to systemd unit files")
|
||||
configure_file(etc/laminar.service.in laminar.service @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/laminar.service DESTINATION ${SYSTEMD_UNITDIR})
|
||||
endif()
|
||||
configure_file(etc/laminar.service.in laminar.service @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/laminar.service DESTINATION ${SYSTEMD_UNITDIR})
|
||||
|
||||
@@ -12,11 +12,11 @@ See [the website](https://laminar.ohwg.net) and the [documentation](https://lami
|
||||
|
||||
First install development packages for `capnproto (version 0.7.0 or newer)`, `rapidjson`, `sqlite` and `boost` (for the header-only `multi_index_container` library) from your distribution's repository or other source.
|
||||
|
||||
On Debian 13 (Trixie), this can be done with:
|
||||
On Debian Bullseye, this can be done with:
|
||||
|
||||
```bash
|
||||
sudo apt install capnproto cmake g++ libboost-dev libcapnp-dev libsqlite3-dev \
|
||||
make rapidjson-dev zlib1g-dev pkg-config
|
||||
sudo apt install \
|
||||
capnproto cmake g++ libboost-dev libcapnp-dev libsqlite3-dev rapidjson-dev zlib1g-dev
|
||||
```
|
||||
|
||||
Then compile and install laminar with:
|
||||
|
||||
141
UserManual.md
141
UserManual.md
@@ -17,28 +17,29 @@ Throughout this document, the fixed base path `/var/lib/laminar` is used. This i
|
||||
|
||||
# Installing Laminar
|
||||
|
||||
Pre-built upstream packages are available for Debian on x86_64 and armhf, and for Rocky/CentOS/RHEL on x86_64.
|
||||
Please see the [GitHub releases page](https://github.com/ohwgiles/laminar/releases) for the latest versions.
|
||||
Since Debian Bullseye, Laminar is available in [the official repositories](https://packages.debian.org/search?searchon=sourcenames&keywords=laminar).
|
||||
|
||||
Also, Laminar may be built from source for any Linux distribution.
|
||||
Alternatively, pre-built upstream packages are available for Debian 10 (Buster) on x86_64 and armhf, and for Rocky/CentOS/RHEL 7 and 8 on x86_64.
|
||||
|
||||
Finally, Laminar may be built from source for any Linux distribution.
|
||||
|
||||
## Installation from upstream packages
|
||||
|
||||
Under Debian:
|
||||
|
||||
```bash
|
||||
wget https://github.com/ohwgiles/laminar/releases/download/1.3/laminar_1.3-1.upstream-debian11_amd64.deb
|
||||
sudo apt install ./laminar_1.3-1.upstream-debian11_amd64.deb
|
||||
wget https://github.com/ohwgiles/laminar/releases/download/1.1/laminar_1.1-1.upstream-debian10_amd64.deb
|
||||
sudo apt install ./laminar_1.1-1.upstream-debian10_amd64.deb
|
||||
```
|
||||
|
||||
Under Rocky/CentOS/RHEL:
|
||||
|
||||
```bash
|
||||
wget https://github.com/ohwgiles/laminar/releases/download/1.3/laminar-1.3.upstream_rocky8-1.x86_64.rpm
|
||||
sudo dnf install ./laminar-1.3.upstream_rocky8-1.x86_64.rpm
|
||||
wget https://github.com/ohwgiles/laminar/releases/download/1.1/laminar-1.1.upstream_rocky8-1.x86_64.rpm
|
||||
sudo dnf install ./laminar-1.1.upstream_rocky8-1.x86_64.rpm
|
||||
```
|
||||
|
||||
Both install packages will create a new `laminar` system user and install (but not activate) a systemd service for launching the laminar daemon.
|
||||
Both install packages will create a new `laminar` user and install (but not activate) a systemd service for launching the laminar daemon.
|
||||
|
||||
## Building from source
|
||||
|
||||
@@ -118,17 +119,8 @@ tar xzf hello-2.10.tar.gz
|
||||
cd hello-2.10
|
||||
./configure
|
||||
make
|
||||
|
||||
# save permanently to the job's run archive directory
|
||||
mv ./hello "$ARCHIVE/"
|
||||
```
|
||||
|
||||
If everything went well, the path to the freshly compiled `hello` binary is `$LAMINAR_HOME/archive/hello/latest/hello`, which prints
|
||||
```
|
||||
Hello, world!
|
||||
```
|
||||
upon execution.
|
||||
|
||||
Laminar uses your script's exit code to determine whether to mark the run as successful or failed. If your script is written in bash, the [`-e` option](http://tldp.org/LDP/abs/html/options.html) is helpful for this. See also [Exit and Exit Status](http://tldp.org/LDP/abs/html/exit-status.html).
|
||||
|
||||
Don't forget to mark the script executable:
|
||||
@@ -175,13 +167,6 @@ Also note that all the above commands can simultaneously trigger multiple differ
|
||||
laminarc queue test-host test-target
|
||||
```
|
||||
|
||||
A human-readable reason for the trigger can be set using the environment variable `LAMINAR_REASON`, which will be stored in the database and displayed in the web UI:
|
||||
|
||||
```bash
|
||||
LAMINAR_REASON="Smoke detected" laminarc run activate-sprinklers
|
||||
```
|
||||
|
||||
|
||||
## Isn't there a "Build Now" button I can click?
|
||||
|
||||
This is against the design principles of Laminar and was deliberately excluded. Laminar's web UI is strictly read-only, making it simple to deploy in mixed-permission or public environments without an authentication layer. Furthermore, Laminar tries to encourage ideal continuous integration, where manual triggering is an anti-pattern. Want to make a release? Push a git tag and implement a post-receive hook. Want to re-run a build due to sporadic failure/flaky tests? Fix the tests locally and push a patch. Experience shows that a manual trigger such as a "Build Now" button is often used as a crutch to avoid doing the correct thing, negatively impacting traceability and quality.
|
||||
@@ -204,6 +189,7 @@ This is what `cron` is for. To trigger a build of `hello` every day at 0300, add
|
||||
|
||||
to `laminar`'s crontab. For more information about `cron`, see `man crontab`.
|
||||
|
||||
`LAMINAR_REASON` is an optional human-readable string that will be displayed in the web UI as the cause of the build.
|
||||
|
||||
## Triggering on a git commit
|
||||
|
||||
@@ -242,7 +228,7 @@ If you need more flexibility, consider running the communication channel as a re
|
||||
LAMINAR_BIND_RPC=unix:/var/run/laminar.sock
|
||||
```
|
||||
|
||||
or similar path in `/etc/laminar.conf` will result in a socket with group read/write permissions (`660`), so any user in the `laminar` system group can queue a job.
|
||||
or similar path in `/etc/laminar.conf` will result in a socket with group read/write permissions (`660`), so any user in the `laminar` group can queue a job.
|
||||
|
||||
This can be securely and flexibly combined with remote triggering using `ssh`. There is no need to allow the client full shell access to the server machine, the ssh server can restrict certain users to certain commands (in this case `laminarc`). See [the authorized_keys section of the sshd man page](https://man.openbsd.org/sshd#AUTHORIZED_KEYS_FILE_FORMAT) for further information.
|
||||
|
||||
@@ -252,9 +238,9 @@ Consider using [webhook](https://github.com/adnanh/webhook) or a similar applica
|
||||
|
||||
## Viewing job logs
|
||||
|
||||
A job's console output can be viewed on the Web UI at http://localhost:8080/jobs/$JOB/$RUN.
|
||||
A job's console output can be viewed on the Web UI at http://localhost:8080/jobs/$NAME/$NUMBER.
|
||||
|
||||
Additionally, the raw log output may be fetched over a plain HTTP request to http://localhost:8080/log/$JOB/$RUN. The response will be chunked, allowing this mechanism to also be used for in-progress jobs. Furthermore, the special endpoint http://localhost:8080/log/$JOB/latest will redirect to the most recent log output. Be aware that the use of this endpoint may be subject to races when new jobs start.
|
||||
Additionally, the raw log output may be fetched over a plain HTTP request to http://localhost:8080/log/$NAME/$NUMBER. The response will be chunked, allowing this mechanism to also be used for in-progress jobs. Furthermore, the special endpoint http://localhost:8080/log/$NAME/latest will redirect to the most recent log output. Be aware that the use of this endpoint may be subject to races when new jobs start.
|
||||
|
||||
---
|
||||
|
||||
@@ -281,7 +267,7 @@ else
|
||||
laminarc run example-downstream-regular
|
||||
fi
|
||||
|
||||
laminarc run "example-test-$TARGET_PLATFORM"
|
||||
laminarc run example-test-$TARGET_PLATFORM
|
||||
```
|
||||
|
||||
`laminarc` reads the `$JOB` and `$RUN` variables set by `laminard` and passes them as part of the queue/start/run request so the dependency chain can always be traced back.
|
||||
@@ -290,7 +276,7 @@ laminarc run "example-test-$TARGET_PLATFORM"
|
||||
|
||||
# Parameterized runs
|
||||
|
||||
Any argument passed to `laminarc` of the form `KEY=VALUE` will be exposed as an environment variable in the corresponding build scripts. For example:
|
||||
Any argument passed to `laminarc` of the form `var=value` will be exposed as an environment variable in the corresponding build scripts. For example:
|
||||
|
||||
```bash
|
||||
laminarc queue example foo=bar
|
||||
@@ -342,20 +328,20 @@ Then in `example.run`
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
echo "$foo" # prints "bar"
|
||||
echo $foo # prints "bar"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Archiving artefacts
|
||||
|
||||
Laminar's default behaviour is to remove the run directory `/var/lib/laminar/run/$JOB/$RUN` after its completion. This prevents the typical CI disk usage explosion and encourages the user to judiciously select artefacts for archive.
|
||||
Laminar's default behaviour is to remove the run directory `/var/lib/laminar/run/JOB/RUN` after its completion. This prevents the typical CI disk usage explosion and encourages the user to judiciously select artefacts for archive.
|
||||
|
||||
Laminar provides an archive directory `/var/lib/laminar/archive/$JOB/$RUN` and exposes its path in `$ARCHIVE`. `example-build.after` might look like this:
|
||||
Laminar provides an archive directory `/var/lib/laminar/archive/JOB/RUN` and exposes its path in `$ARCHIVE`. `example-build.after` might look like this:
|
||||
|
||||
```bash
|
||||
#!/bin/bash -xe
|
||||
cp example.out "$ARCHIVE/"
|
||||
cp example.out $ARCHIVE/
|
||||
```
|
||||
|
||||
This folder structure has been chosen to make it easy for system administrators to host the archive on a separate partition or network drive.
|
||||
@@ -386,13 +372,13 @@ fi
|
||||
|
||||
Of course, you can make this as pretty as you like. A [helper script](#Helper-scripts) can be a good choice here.
|
||||
|
||||
If you want to send to different addresses depending on the job, replace `engineering@company.com` above with a variable, e.g. `$RECIPIENTS`, and set `RECIPIENTS=nora@company.com,joe@company.com` in `/var/lib/laminar/cfg/jobs/$JOB.env`. See [Environment variables](#Environment-variables).
|
||||
If you want to send to different addresses depending on the job, replace `engineering@company.com` above with a variable, e.g. `$RECIPIENTS`, and set `RECIPIENTS=nora@company.com,joe@company.com` in `/var/lib/laminar/cfg/jobs/JOB.env`. See [Environment variables](#Environment-variables).
|
||||
|
||||
You could also update the `$RECIPIENTS` variable dynamically based on the build itself. For example, if your run script accepts a parameter `$rev` which is a git commit id, as part of your job's `.after` script you could do the following:
|
||||
|
||||
```bash
|
||||
author_email=$(git show -s --format='%ae' "$rev")
|
||||
laminarc set RECIPIENTS "$author_email"
|
||||
author_email=$(git show -s --format='%ae' $rev)
|
||||
laminarc set RECIPIENTS $author_email
|
||||
```
|
||||
|
||||
See [examples/notify-email-pretty](https://github.com/ohwgiles/laminar/blob/master/examples/notify-email-pretty) and [examples/notify-email-text-log](https://github.com/ohwgiles/laminar/blob/master/examples/notify-email-text-log).
|
||||
@@ -431,25 +417,25 @@ For example, the following script creates a tarball containing both compiled out
|
||||
git clone /path/to/sources .
|
||||
make
|
||||
# Use a hardlink so the arguments to tar will be relative to the CWD
|
||||
ln "$WORKSPACE/StaticAsset.bin" ./
|
||||
ln $WORKSPACE/StaticAsset.bin ./
|
||||
tar zc a.out StaticAsset.bin > MyProject.tar.gz
|
||||
# Archive the artefact (consider moving this to the .after script)
|
||||
mv MyProject.tar.gz "$ARCHIVE/"
|
||||
mv MyProject.tar.gz $ARCHIVE/
|
||||
```
|
||||
|
||||
For a project with a large git history, it can be more efficient to store the sources in the workspace:
|
||||
|
||||
```bash
|
||||
#!/bin/bash -ex
|
||||
cd "$WORKSPACE/myproject"
|
||||
cd $WORKSPACE/myproject
|
||||
git pull
|
||||
cd -
|
||||
|
||||
cmake "$WORKSPACE/myproject"
|
||||
cmake $WORKSPACE/myproject
|
||||
make -j4
|
||||
```
|
||||
|
||||
Laminar will automatically create the workspace for a job if it doesn't exist when a job is executed. In this case, the `/var/lib/laminar/cfg/jobs/$JOB.init` will be executed if it exists. This is an excellent place to prepare the workspace to a state where subsequent builds can rely on its content:
|
||||
Laminar will automatically create the workspace for a job if it doesn't exist when a job is executed. In this case, the `/var/lib/laminar/cfg/jobs/JOBNAME.init` will be executed if it exists. This is an excellent place to prepare the workspace to a state where subsequent builds can rely on its content:
|
||||
|
||||
```bash
|
||||
#!/bin/bash -e
|
||||
@@ -475,16 +461,16 @@ The following example uses [flock](https://linux.die.net/man/1/flock) to efficie
|
||||
# Locked subshell for modifying the workspace
|
||||
(
|
||||
flock 200
|
||||
cd "$WORKSPACE"
|
||||
cd $WORKSPACE
|
||||
# Download all the latest commits
|
||||
git fetch
|
||||
git checkout "$rev"
|
||||
git checkout $rev
|
||||
cd -
|
||||
# Fast copy (hard-link) the source from the specific checkout
|
||||
# to the build dir. This relies on the fact that git unlinks
|
||||
# during checkout, effectively implementing copy-on-write.
|
||||
cp -al "$WORKSPACE/src" src
|
||||
) 200>"$WORKSPACE"
|
||||
cp -al $WORKSPACE/src src
|
||||
) 200>$WORKSPACE
|
||||
|
||||
# run the (much longer) regular build process
|
||||
make -C src
|
||||
@@ -496,7 +482,7 @@ make -C src
|
||||
|
||||
## After a timeout
|
||||
|
||||
To configure a maximum execution time in seconds for a job, add a line to `/var/lib/laminar/cfg/jobs/$JOB.conf`:
|
||||
To configure a maximum execution time in seconds for a job, add a line to `/var/lib/laminar/cfg/jobs/JOBNAME.conf`:
|
||||
|
||||
```
|
||||
TIMEOUT=120
|
||||
@@ -504,7 +490,7 @@ TIMEOUT=120
|
||||
|
||||
## Manually
|
||||
|
||||
`laminarc abort $JOB $RUN`
|
||||
`laminarc abort $JOBNAME $NUMBER`
|
||||
|
||||
---
|
||||
|
||||
@@ -526,7 +512,7 @@ EXECUTORS=1
|
||||
|
||||
## Associating a job with a context
|
||||
|
||||
When trying to start a job, laminar will wait until the job can be matched to a context which has at least one free executor. There are two ways to associate jobs and contexts. You can specify a comma-separated list of patterns `JOBS` in the context configuration file `/var/lib/laminar/cfg/contexts/$CONTEXT.conf`:
|
||||
When trying to start a job, laminar will wait until the job can be matched to a context which has at least one free executor. There are two ways to associate jobs and contexts. You can specify a comma-separated list of patterns `JOBS` in the context configuration file `/var/lib/laminar/cfg/contexts/CONTEXT.conf`:
|
||||
|
||||
```
|
||||
JOBS=amd64-target-*,usage-monitor
|
||||
@@ -540,15 +526,15 @@ Alternatively, you can set
|
||||
CONTEXTS=my-env-*,special_context
|
||||
```
|
||||
|
||||
in `/var/lib/laminar/cfg/jobs/$JOB.conf`. This approach is often preferred when you have a small number of jobs that require exclusive access to an environment and you can supply alternative environments (e.g. target devices), because new contexts can be added without modifying the job configuration.
|
||||
in `/var/lib/laminar/cfg/jobs/JOB.conf`. This approach is often preferred when you have a small number of jobs that require exclusive access to an environment and you can supply alternative environments (e.g. target devices), because new contexts can be added without modifying the job configuration.
|
||||
|
||||
In both cases, Laminar will iterate over the known contexts and associate the run with the first matching context with free executors. Patterns are [glob expressions](http://man7.org/linux/man-pages/man7/glob.7.html).
|
||||
|
||||
If `CONTEXTS` is empty or absent (or if `$JOB.conf` doesn't exist), laminar will behave as if `CONTEXTS=default` were defined.
|
||||
If `CONTEXTS` is empty or absent (or if `JOB.conf` doesn't exist), laminar will behave as if `CONTEXTS=default` were defined.
|
||||
|
||||
## Adding environment to a context
|
||||
|
||||
Append desired environment variables to `/var/lib/laminar/cfg/contexts/$CONTEXT.env`:
|
||||
Append desired environment variables to `/var/lib/laminar/cfg/contexts/CONTEXT_NAME.conf`:
|
||||
|
||||
```
|
||||
DUT_IP=192.168.3.2
|
||||
@@ -584,11 +570,11 @@ This means the job script `/var/lib/laminar/cfg/jobs/myproject-test.run` can be
|
||||
```bash
|
||||
#!/bin/bash -e
|
||||
|
||||
ssh "root@$TARGET_IP" /bin/bash -xe <<"EOF"
|
||||
ssh root@$TARGET_IP /bin/bash -xe <<"EOF"
|
||||
uname -a
|
||||
...
|
||||
EOF
|
||||
scp "root@$TARGET_IP:result.xml" "$ARCHIVE/"
|
||||
scp root@$TARGET_IP:result.xml "$ARCHIVE/"
|
||||
```
|
||||
|
||||
Don't forget to add the `laminar` user's public ssh key to the remote's `authorized_keys`.
|
||||
@@ -642,7 +628,7 @@ Changes to this file are detected immediately and will be visible on next page r
|
||||
|
||||
## Adding a description to a job
|
||||
|
||||
Edit `/var/lib/laminar/cfg/jobs/$JOB.conf`:
|
||||
Edit `/var/lib/laminar/cfg/jobs/$JOBNAME.conf`:
|
||||
|
||||
```
|
||||
DESCRIPTION=Anything here will appear on the job page in the frontend <em>unescaped</em>.
|
||||
@@ -662,7 +648,7 @@ An example customization can be found at [cweagans/semantic-laminar-theme](https
|
||||
|
||||
# Badges
|
||||
|
||||
Laminar will serve a job's current status as a pretty badge at the url `/badge/$JOB.svg`. This can be used as a link to your server instance from your Github README.md file or cat blog:
|
||||
Laminar will serve a job's current status as a pretty badge at the url `/badge/JOBNAME.svg`. This can be used as a link to your server instance from your Github README.md file or cat blog:
|
||||
|
||||
```
|
||||
<a href="https://my-example-laminar-server.com/jobs/my-project">
|
||||
@@ -674,45 +660,6 @@ Laminar will serve a job's current status as a pretty badge at the url `/badge/$
|
||||
|
||||
# Reference
|
||||
|
||||
## LAMINAR_HOME directory scheme
|
||||
|
||||
```
|
||||
$LAMINAR_HOME/
|
||||
├── cfg/
|
||||
│ ├── before
|
||||
│ ├── jobs/
|
||||
│ │ ├── $JOB.init
|
||||
│ │ ├── $JOB.env
|
||||
│ │ ├── $JOB.before
|
||||
│ │ ├── $JOB.run
|
||||
│ │ ├── $JOB.after
|
||||
│ │ └── $JOB.conf
|
||||
│ ├── after
|
||||
│ │ scripts/
|
||||
│ │ ├── foo
|
||||
│ │ └── bar
|
||||
│ ├── env
|
||||
│ ├── contexts/
|
||||
│ │ ├── $CONTEXT.env
|
||||
│ │ └── $CONTEXT.conf
|
||||
│ └── groups.conf
|
||||
├── archive/
|
||||
│ └── $JOB/
|
||||
│ └── $RUN/ # $ARCHIVE
|
||||
├── run/
|
||||
│ └── $JOB/
|
||||
│ └── $RUN/ # run directory (ephemeral)
|
||||
│ └── workspace/ # $WORKSPACE
|
||||
├── custom/
|
||||
│ └── index.html
|
||||
└── laminar.sqlite
|
||||
```
|
||||
|
||||
The user running `laminard` (by default the system user `laminar`)
|
||||
- must have read/write access to `laminar.sqlite`,
|
||||
- read/execute access to the contents of `cfg` and `custom` and
|
||||
- write access to `archive` and `run` if the running jobs are to have the ability to archive artefacts or utilize the workspace, respectively.
|
||||
|
||||
## Service configuration file
|
||||
|
||||
`laminard` reads the following variables from the environment, which are expected to be sourced by `systemd` from `/etc/laminar.conf`:
|
||||
@@ -767,14 +714,12 @@ Finally, variables supplied on the command-line call to `laminarc queue`, `lamin
|
||||
- `start [JOB [PARAMS...]]...` starts one or more jobs with optional parameters, returning when the jobs begin execution.
|
||||
- `run [JOB [PARAMS...]]...` triggers one or more jobs with optional parameters and waits for the completion of all jobs.
|
||||
- `--next` may be passed before `JOB` in order to place the job at the front of the queue instead of at the end.
|
||||
- `set [KEY=VALUE]...` sets one or more variables to be exported in subsequent scripts for the run identified by the `JOB` and `RUN` environment variables
|
||||
- `set [VARIABLE=VALUE]...` sets one or more variables to be exported in subsequent scripts for the run identified by the `$JOB` and `$RUN` environment variables
|
||||
- `show-jobs` shows the known jobs on the server (`$LAMINAR_HOME/cfg/jobs/*.run`).
|
||||
- `show-running` shows the currently running jobs with their numbers.
|
||||
- `show-queued` shows the names of the jobs waiting in the queue.
|
||||
- `abort JOB RUN` manually aborts a currently running job by name and number.
|
||||
- `abort JOB NUMBER` manually aborts a currently running job by name and number.
|
||||
|
||||
`laminarc` connects to `laminard` using the address supplied by the `LAMINAR_HOST` environment variable. If it is not set, `laminarc` will first attempt to use `LAMINAR_BIND_RPC`, which will be available if `laminarc` is executed from a script within `laminard`. If neither `LAMINAR_HOST` nor `LAMINAR_BIND_RPC` is set, `laminarc` will assume a default host of `unix-abstract:laminar`.
|
||||
|
||||
`laminarc` reads the environment variable `LAMINAR_REASON` for a human-readable reason. See [Triggering a run](#Triggering-a-run).
|
||||
|
||||
All commands return zero on success or a non-zero code if the command could not be executed. `laminarc run` will return a non-zero exit status if any executed job failed.
|
||||
|
||||
@@ -7,7 +7,7 @@ Documentation=https://laminar.ohwg.net/docs.html
|
||||
[Service]
|
||||
User=laminar
|
||||
EnvironmentFile=-/etc/laminar.conf
|
||||
ExecStart=@CMAKE_INSTALL_PREFIX@/sbin/laminard -v
|
||||
ExecStart=@CMAKE_INSTALL_PREFIX@/sbin/laminard
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
@@ -9,7 +9,7 @@ set -x
|
||||
|
||||
# Simple way of getting the docker build tag:
|
||||
tag=$(docker build -q - <<\EOF
|
||||
FROM debian:bookworm
|
||||
FROM debian:bullseye
|
||||
RUN apt-get update && apt-get install -y build-essential
|
||||
EOF
|
||||
)
|
||||
@@ -19,7 +19,7 @@ EOF
|
||||
|
||||
exec {pfd}<><(:) # get a new pipe
|
||||
docker build - <<\EOF |
|
||||
FROM debian:bookworm
|
||||
FROM debian:bullseye
|
||||
RUN apt-get update && apt-get install -y build-essential
|
||||
EOF
|
||||
tee >(awk '/Successfully built/{print $3}' >&$pfd) # parse output to pipe
|
||||
|
||||
@@ -4,32 +4,40 @@ OUTPUT_DIR=$PWD
|
||||
|
||||
SOURCE_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]})/..)
|
||||
|
||||
VERSION=$(cd "$SOURCE_DIR" && git describe --tags --abbrev=8 --dirty | tr - .)~upstream_rocky10
|
||||
VERSION=$(cd "$SOURCE_DIR" && git describe --tags --abbrev=8 --dirty | tr - .)~upstream_centos7
|
||||
|
||||
DOCKER_TAG=$(docker build -q - <<EOS
|
||||
FROM rockylinux/rockylinux:10
|
||||
RUN dnf -y update && dnf -y install rpm-build cmake make gcc-c++ wget sqlite-devel boost-devel zlib-devel systemd-units
|
||||
RUN mkdir /rapidjson && pushd /rapidjson && \
|
||||
wget -O rapidjson.tar.gz https://github.com/miloyip/rapidjson/archive/v1.1.0.tar.gz && \
|
||||
echo "badd12c511e081fec6c89c43a7027bce rapidjson.tar.gz" | md5sum -c && \
|
||||
tar xzf rapidjson.tar.gz && \
|
||||
cd rapidjson-1.1.0 && \
|
||||
cmake -DRAPIDJSON_BUILD_EXAMPLES=off . && \
|
||||
make install && \
|
||||
popd && rm -rf /rapidjson
|
||||
RUN mkdir /capnproto && pushd /capnproto && \
|
||||
wget -O capnproto.tar.gz https://github.com/capnproto/capnproto/archive/v1.5.0.tar.gz && \
|
||||
echo "cd64102577a89714b9d58494a7e34cee capnproto.tar.gz" | md5sum -c && \
|
||||
tar xzf capnproto.tar.gz && \
|
||||
cd capnproto-1.5.0/c++ && \
|
||||
cmake -DCMAKE_CXX_FLAGS=-fPIE -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=off . && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
popd && rm -rf /capnproto
|
||||
FROM centos:7
|
||||
RUN yum -y install epel-release centos-release-scl && yum-config-manager --enable rhel-server-rhscl-7-rpms && yum -y install rpm-build cmake3 make devtoolset-7-gcc-c++ wget sqlite-devel boost-devel zlib-devel
|
||||
EOS
|
||||
)
|
||||
|
||||
docker run --rm -i -v $SOURCE_DIR:/root/rpmbuild/SOURCES/laminar-$VERSION:ro -v $OUTPUT_DIR:/output $DOCKER_TAG bash -xe <<EOS
|
||||
# for new gcc
|
||||
export PATH=/opt/rh/devtoolset-7/root/usr/bin:\$PATH
|
||||
|
||||
mkdir /build
|
||||
cd /build
|
||||
|
||||
wget -O capnproto.tar.gz https://github.com/capnproto/capnproto/archive/v0.7.0.tar.gz
|
||||
wget -O rapidjson.tar.gz https://github.com/miloyip/rapidjson/archive/v1.1.0.tar.gz
|
||||
md5sum -c <<EOF
|
||||
a9de5f042f4cf05515c2d7dfc7f5df21 capnproto.tar.gz
|
||||
badd12c511e081fec6c89c43a7027bce rapidjson.tar.gz
|
||||
EOF
|
||||
|
||||
tar xzf capnproto.tar.gz
|
||||
tar xzf rapidjson.tar.gz
|
||||
|
||||
cd /build/capnproto-0.7.0/c++/
|
||||
cmake3 -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=off .
|
||||
make -j4
|
||||
make install
|
||||
|
||||
cd /build/rapidjson-1.1.0/
|
||||
cmake3 -DRAPIDJSON_BUILD_EXAMPLES=off .
|
||||
make install
|
||||
|
||||
cd
|
||||
cat <<EOF > laminar.spec
|
||||
Summary: Lightweight Continuous Integration Service
|
||||
@@ -38,7 +46,7 @@ Version: $VERSION
|
||||
Release: 1
|
||||
License: GPL
|
||||
BuildRequires: systemd-units
|
||||
Requires: sqlite-libs zlib
|
||||
Requires: sqlite zlib
|
||||
|
||||
%description
|
||||
Lightweight Continuous Integration Service
|
||||
@@ -46,7 +54,7 @@ Lightweight Continuous Integration Service
|
||||
%prep
|
||||
|
||||
%build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DLAMINAR_VERSION=$VERSION -DSYSTEMD_UNITDIR=%{_unitdir} %{_sourcedir}/laminar-$VERSION
|
||||
cmake3 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DLAMINAR_VERSION=$VERSION -DSYSTEMD_UNITDIR=%{_unitdir} %{_sourcedir}/laminar-$VERSION
|
||||
pwd
|
||||
make
|
||||
|
||||
@@ -4,11 +4,11 @@ OUTPUT_DIR=$PWD
|
||||
|
||||
SOURCE_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]})/..)
|
||||
|
||||
VERSION=$(cd "$SOURCE_DIR" && git describe --tags --abbrev=8 --dirty)-1~upstream-debian13
|
||||
VERSION=$(cd "$SOURCE_DIR" && git describe --tags --abbrev=8 --dirty)-1~upstream-debian11
|
||||
|
||||
DOCKER_TAG=$(docker build -q - <<EOS
|
||||
FROM debian:13-slim
|
||||
RUN apt-get update && apt-get install -y wget cmake g++ capnproto libcapnp-dev rapidjson-dev libsqlite3-dev libboost-dev zlib1g-dev pkg-config
|
||||
FROM debian:11-slim
|
||||
RUN apt-get update && apt-get install -y wget cmake g++ capnproto libcapnp-dev rapidjson-dev libsqlite3-dev libboost-dev zlib1g-dev
|
||||
EOS
|
||||
)
|
||||
|
||||
@@ -30,7 +30,7 @@ Section:
|
||||
Priority: optional
|
||||
Architecture: amd64
|
||||
Maintainer: Oliver Giles <web ohwg net>
|
||||
Depends: libcapnp-1.0.1, libsqlite3-0, zlib1g
|
||||
Depends: libcapnp-0.7.0, libsqlite3-0, zlib1g
|
||||
Description: Lightweight Continuous Integration Service
|
||||
EOF
|
||||
echo /etc/laminar.conf > laminar/DEBIAN/conffiles
|
||||
@@ -4,11 +4,11 @@ OUTPUT_DIR=$PWD
|
||||
|
||||
SOURCE_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]})/..)
|
||||
|
||||
VERSION=$(cd "$SOURCE_DIR" && git describe --tags --abbrev=8 --dirty)-1~upstream-debian13
|
||||
VERSION=$(cd "$SOURCE_DIR" && git describe --tags --abbrev=8 --dirty)-1~upstream-debian11
|
||||
|
||||
DOCKER_TAG=$(docker build -q - <<EOS
|
||||
FROM debian:13-slim
|
||||
RUN dpkg --add-architecture armhf && apt-get update && apt-get install -y wget cmake pkg-config crossbuild-essential-armhf capnproto libcapnp-dev:armhf rapidjson-dev:armhf libsqlite3-dev:armhf libboost-dev:armhf zlib1g-dev:armhf
|
||||
FROM debian:11-slim
|
||||
RUN dpkg --add-architecture armhf && apt-get update && apt-get install -y wget cmake crossbuild-essential-armhf capnproto libcapnp-dev:armhf rapidjson-dev libsqlite3-dev:armhf libboost-dev:armhf zlib1g-dev:armhf
|
||||
EOS
|
||||
)
|
||||
|
||||
@@ -17,19 +17,18 @@ docker run --rm -i -v $SOURCE_DIR:/laminar:ro -v $OUTPUT_DIR:/output $DOCKER_TAG
|
||||
mkdir /build
|
||||
cd /build
|
||||
|
||||
cat > toolchain.cmake <<\EOF
|
||||
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
|
||||
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
|
||||
set(CMAKE_PREFIX_PATH /usr/lib/arm-linux-gnueabihf)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(ENV{PKG_CONFIG_PATH} "/usr/lib/arm-linux-gnueabihf/pkgconfig")
|
||||
cat > toolchain.cmake <<EOF
|
||||
SET(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
|
||||
SET(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
|
||||
set(CMAKE_LIBRARY_ARCHITECTURE arm-linux-gnueabihf)
|
||||
EOF
|
||||
|
||||
cd /build
|
||||
cmake \
|
||||
-DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
|
||||
-DCMAKE_LINKER=/usr/bin/arm-linux-gnueabihf-ld \
|
||||
-DCMAKE_OBJCOPY=/usr/bin/arm-linux-gnueabihf-objcopy \
|
||||
-DCMAKE_STRIP=/usr/bin/arm-linux-gnueabihf-strip \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DLAMINAR_VERSION=$VERSION \
|
||||
@@ -47,7 +46,7 @@ Section:
|
||||
Priority: optional
|
||||
Architecture: armhf
|
||||
Maintainer: Oliver Giles <web ohwg net>
|
||||
Depends: libcapnp-1.0.1, libsqlite3-0, zlib1g
|
||||
Depends: libcapnp-0.7.0, libsqlite3-0, zlib1g
|
||||
Description: Lightweight Continuous Integration Service
|
||||
EOF
|
||||
echo /etc/laminar.conf > laminar/DEBIAN/conffiles
|
||||
@@ -1,48 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
OUTPUT_DIR=$PWD
|
||||
|
||||
SOURCE_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]})/..)
|
||||
|
||||
VERSION=$(cd "$SOURCE_DIR" && git describe --tags --abbrev=8 --dirty)-1~upstream-debian14
|
||||
|
||||
DOCKER_TAG=$(docker build -q - <<EOS
|
||||
FROM debian:forky-slim
|
||||
RUN apt-get update && apt-get install -y wget cmake g++ capnproto libcapnp-dev rapidjson-dev libsqlite3-dev libboost-dev zlib1g-dev pkg-config
|
||||
EOS
|
||||
)
|
||||
|
||||
docker run --rm -i -v $SOURCE_DIR:/laminar:ro -v $OUTPUT_DIR:/output $DOCKER_TAG bash -xe <<EOS
|
||||
|
||||
mkdir /build
|
||||
cd /build
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DLAMINAR_VERSION=$VERSION -DZSH_COMPLETIONS_DIR=/usr/share/zsh/functions/Completion/Unix /laminar
|
||||
make -j4
|
||||
mkdir laminar
|
||||
make DESTDIR=laminar install/strip
|
||||
|
||||
mkdir laminar/DEBIAN
|
||||
cat <<EOF > laminar/DEBIAN/control
|
||||
Package: laminar
|
||||
Version: $VERSION
|
||||
Section:
|
||||
Priority: optional
|
||||
Architecture: amd64
|
||||
Maintainer: Oliver Giles <web ohwg net>
|
||||
Depends: libcapnp-1.1.0, libsqlite3-0, zlib1g
|
||||
Description: Lightweight Continuous Integration Service
|
||||
EOF
|
||||
echo /etc/laminar.conf > laminar/DEBIAN/conffiles
|
||||
cat <<EOF > laminar/DEBIAN/postinst
|
||||
#!/bin/bash
|
||||
echo Creating laminar user with home in /var/lib/laminar
|
||||
useradd -r -d /var/lib/laminar -s /usr/sbin/nologin laminar
|
||||
mkdir -p /var/lib/laminar/cfg/{jobs,contexts,scripts}
|
||||
chown -R laminar: /var/lib/laminar
|
||||
EOF
|
||||
chmod +x laminar/DEBIAN/postinst
|
||||
|
||||
dpkg-deb --build laminar
|
||||
mv laminar.deb /output/laminar_${VERSION}_amd64.deb
|
||||
EOS
|
||||
@@ -1,65 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
OUTPUT_DIR=$PWD
|
||||
|
||||
SOURCE_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]})/..)
|
||||
|
||||
VERSION=$(cd "$SOURCE_DIR" && git describe --tags --abbrev=8 --dirty)-1~upstream-debian14
|
||||
|
||||
DOCKER_TAG=$(docker build -q - <<EOS
|
||||
FROM debian:forky-slim
|
||||
RUN dpkg --add-architecture armhf && apt-get update && apt-get install -y wget cmake pkg-config crossbuild-essential-armhf capnproto libcapnp-dev:armhf rapidjson-dev:armhf libsqlite3-dev:armhf libboost-dev:armhf zlib1g-dev:armhf
|
||||
EOS
|
||||
)
|
||||
|
||||
docker run --rm -i -v $SOURCE_DIR:/laminar:ro -v $OUTPUT_DIR:/output $DOCKER_TAG bash -xe <<EOS
|
||||
|
||||
mkdir /build
|
||||
cd /build
|
||||
|
||||
cat > toolchain.cmake <<\EOF
|
||||
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
|
||||
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
|
||||
set(CMAKE_PREFIX_PATH /usr/lib/arm-linux-gnueabihf)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(ENV{PKG_CONFIG_PATH} "/usr/lib/arm-linux-gnueabihf/pkgconfig")
|
||||
EOF
|
||||
|
||||
cd /build
|
||||
cmake \
|
||||
-DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DLAMINAR_VERSION=$VERSION \
|
||||
-DZSH_COMPLETIONS_DIR=/usr/share/zsh/functions/Completion/Unix \
|
||||
/laminar
|
||||
make -j4
|
||||
mkdir laminar
|
||||
make DESTDIR=laminar install/strip
|
||||
|
||||
mkdir laminar/DEBIAN
|
||||
cat <<EOF > laminar/DEBIAN/control
|
||||
Package: laminar
|
||||
Version: $VERSION
|
||||
Section:
|
||||
Priority: optional
|
||||
Architecture: armhf
|
||||
Maintainer: Oliver Giles <web ohwg net>
|
||||
Depends: libcapnp-1.1.0, libsqlite3-0, zlib1g
|
||||
Description: Lightweight Continuous Integration Service
|
||||
EOF
|
||||
echo /etc/laminar.conf > laminar/DEBIAN/conffiles
|
||||
cat <<EOF > laminar/DEBIAN/postinst
|
||||
#!/bin/bash
|
||||
echo Creating laminar user with home in /var/lib/laminar
|
||||
useradd -r -d /var/lib/laminar -s /usr/sbin/nologin laminar
|
||||
mkdir -p /var/lib/laminar/cfg/{jobs,contexts,scripts}
|
||||
chown -R laminar: /var/lib/laminar
|
||||
EOF
|
||||
chmod +x laminar/DEBIAN/postinst
|
||||
|
||||
dpkg-deb --build laminar
|
||||
mv laminar.deb /output/laminar_${VERSION}_armhf.deb
|
||||
EOS
|
||||
@@ -1,62 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
OUTPUT_DIR=$PWD
|
||||
|
||||
SOURCE_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]})/..)
|
||||
|
||||
VERSION=$(cd "$SOURCE_DIR" && git describe --tags --abbrev=8 --dirty | tr - .)~upstream_opensuse16
|
||||
|
||||
DOCKER_TAG=$(docker build -q - <<EOS
|
||||
FROM opensuse/leap:16
|
||||
RUN zypper --non-interactive refresh && zypper --non-interactive update && zypper --non-interactive install -y rpm-build cmake make gcc-c++ wget sqlite3-devel boost-devel zlib-devel capnproto libcapnp-devel rapidjson-devel
|
||||
EOS
|
||||
)
|
||||
|
||||
# use /usr/sr/packages for opensuse instead of /root/rpmbuild
|
||||
docker run --rm -i -v $SOURCE_DIR:/usr/src/packages/SOURCES/laminar-$VERSION:ro -v $OUTPUT_DIR:/output $DOCKER_TAG bash -xe <<EOS
|
||||
mkdir /build
|
||||
cd /build
|
||||
|
||||
cat <<EOF > laminar.spec
|
||||
Summary: Lightweight Continuous Integration Service
|
||||
Name: laminar
|
||||
Version: $VERSION
|
||||
Release: 1
|
||||
License: GPL
|
||||
URL: https://laminar.ohwg.net/
|
||||
BuildArch: x86_64
|
||||
BuildRequires: cmake make gcc-c++ sqlite3-devel boost-devel zlib-devel capnproto libcapnp-devel rapidjson-devel
|
||||
|
||||
%description
|
||||
Lightweight Continuous Integration Service
|
||||
|
||||
%prep
|
||||
|
||||
%build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DLAMINAR_VERSION=$VERSION -DSYSTEMD_UNITDIR=%{_unitdir} %{_sourcedir}/laminar-$VERSION
|
||||
pwd
|
||||
make %{?_smp_mflags}
|
||||
|
||||
%install
|
||||
%make_install
|
||||
|
||||
%files
|
||||
%{_bindir}/laminarc
|
||||
%{_sbindir}/laminard
|
||||
%{_unitdir}/laminar.service
|
||||
%config(noreplace) %{_sysconfdir}/laminar.conf
|
||||
%{_datarootdir}/bash-completion/completions/laminarc
|
||||
%{_datarootdir}/zsh/site-functions/_laminarc
|
||||
%{_mandir}/man8/laminard.8.gz
|
||||
%{_mandir}/man1/laminarc.1.gz
|
||||
|
||||
%post
|
||||
echo Creating laminar user with home in %{_sharedstatedir}/laminar
|
||||
useradd -r -d %{_sharedstatedir}/laminar -s %{_sbindir}/nologin laminar
|
||||
mkdir -p %{_sharedstatedir}/laminar/cfg/{jobs,contexts,scripts}
|
||||
chown -R laminar: %{_sharedstatedir}/laminar
|
||||
EOF
|
||||
|
||||
rpmbuild -ba laminar.spec
|
||||
mv /usr/src/packages/RPMS/x86_64/laminar-$VERSION-1.x86_64.rpm /output/
|
||||
EOS
|
||||
@@ -4,32 +4,37 @@ OUTPUT_DIR=$PWD
|
||||
|
||||
SOURCE_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]})/..)
|
||||
|
||||
VERSION=$(cd "$SOURCE_DIR" && git describe --tags --abbrev=8 --dirty | tr - .)~upstream_rocky9
|
||||
VERSION=$(cd "$SOURCE_DIR" && git describe --tags --abbrev=8 --dirty | tr - .)~upstream_rocky8
|
||||
|
||||
DOCKER_TAG=$(docker build -q - <<EOS
|
||||
FROM rockylinux/rockylinux:9
|
||||
RUN dnf -y update && dnf -y install rpm-build cmake make gcc-c++ wget sqlite-devel boost-devel zlib-devel systemd-units
|
||||
RUN mkdir /rapidjson && pushd /rapidjson && \
|
||||
wget -O rapidjson.tar.gz https://github.com/miloyip/rapidjson/archive/v1.1.0.tar.gz && \
|
||||
echo "badd12c511e081fec6c89c43a7027bce rapidjson.tar.gz" | md5sum -c && \
|
||||
tar xzf rapidjson.tar.gz && \
|
||||
cd rapidjson-1.1.0 && \
|
||||
cmake -DRAPIDJSON_BUILD_EXAMPLES=off . && \
|
||||
make install && \
|
||||
popd && rm -rf /rapidjson
|
||||
RUN mkdir /capnproto && pushd /capnproto && \
|
||||
wget -O capnproto.tar.gz https://github.com/capnproto/capnproto/archive/v1.5.0.tar.gz && \
|
||||
echo "cd64102577a89714b9d58494a7e34cee capnproto.tar.gz" | md5sum -c && \
|
||||
tar xzf capnproto.tar.gz && \
|
||||
cd capnproto-1.5.0/c++ && \
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=off . && \
|
||||
make -j4 && \
|
||||
make install && \
|
||||
popd && rm -rf /capnproto
|
||||
FROM rockylinux/rockylinux:8
|
||||
RUN dnf -y update && dnf -y install rpm-build cmake make gcc-c++ wget sqlite-devel boost-devel zlib-devel
|
||||
EOS
|
||||
)
|
||||
|
||||
docker run --rm -i -v $SOURCE_DIR:/root/rpmbuild/SOURCES/laminar-$VERSION:ro -v $OUTPUT_DIR:/output $DOCKER_TAG bash -xe <<EOS
|
||||
mkdir /build
|
||||
cd /build
|
||||
|
||||
wget -O capnproto.tar.gz https://github.com/capnproto/capnproto/archive/v0.7.0.tar.gz
|
||||
wget -O rapidjson.tar.gz https://github.com/miloyip/rapidjson/archive/v1.1.0.tar.gz
|
||||
md5sum -c <<EOF
|
||||
a9de5f042f4cf05515c2d7dfc7f5df21 capnproto.tar.gz
|
||||
badd12c511e081fec6c89c43a7027bce rapidjson.tar.gz
|
||||
EOF
|
||||
|
||||
tar xzf capnproto.tar.gz
|
||||
tar xzf rapidjson.tar.gz
|
||||
|
||||
cd /build/capnproto-0.7.0/c++/
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=off .
|
||||
make -j4
|
||||
make install
|
||||
|
||||
cd /build/rapidjson-1.1.0/
|
||||
cmake -DRAPIDJSON_BUILD_EXAMPLES=off .
|
||||
make install
|
||||
|
||||
cd
|
||||
cat <<EOF > laminar.spec
|
||||
Summary: Lightweight Continuous Integration Service
|
||||
@@ -1,49 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
OUTPUT_DIR=$PWD
|
||||
|
||||
SOURCE_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]})/..)
|
||||
|
||||
VERSION=$(cd "$SOURCE_DIR" && git describe --tags --abbrev=8 --dirty)-1~upstream-ubuntu2204
|
||||
|
||||
DOCKER_TAG=$(docker build -q - <<EOS
|
||||
FROM ubuntu:22.04
|
||||
RUN apt-get update && apt-get install -y wget cmake g++ capnproto libcapnp-dev rapidjson-dev libsqlite3-dev libboost-dev zlib1g-dev pkg-config
|
||||
EOS
|
||||
)
|
||||
|
||||
docker run --rm -i -v $SOURCE_DIR:/laminar:ro -v $OUTPUT_DIR:/output $DOCKER_TAG bash -xe <<EOS
|
||||
|
||||
mkdir /build
|
||||
cd /build
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DLAMINAR_VERSION=$VERSION -DZSH_COMPLETIONS_DIR=/usr/share/zsh/functions/Completion/Unix /laminar
|
||||
make -j4
|
||||
mkdir laminar
|
||||
make DESTDIR=laminar install/strip
|
||||
|
||||
mkdir laminar/DEBIAN
|
||||
cat <<EOF > laminar/DEBIAN/control
|
||||
Package: laminar
|
||||
Version: $VERSION
|
||||
Section:
|
||||
Priority: optional
|
||||
Architecture: amd64
|
||||
Maintainer: Oliver Giles <web ohwg net>
|
||||
Depends: libcapnp-0.8.0, libsqlite3-0, zlib1g
|
||||
Description: Lightweight Continuous Integration Service
|
||||
EOF
|
||||
echo /etc/laminar.conf > laminar/DEBIAN/conffiles
|
||||
cat <<EOF > laminar/DEBIAN/postinst
|
||||
#!/bin/bash
|
||||
echo Creating laminar user with home in /var/lib/laminar
|
||||
useradd -r -d /var/lib/laminar -s /usr/sbin/nologin laminar
|
||||
mkdir -p /var/lib/laminar/cfg/{jobs,contexts,scripts}
|
||||
chown -R laminar: /var/lib/laminar
|
||||
EOF
|
||||
chmod +x laminar/DEBIAN/postinst
|
||||
|
||||
dpkg-deb --build laminar
|
||||
mv laminar.deb /output/laminar_${VERSION}_amd64.deb
|
||||
EOS
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
OUTPUT_DIR=$PWD
|
||||
|
||||
SOURCE_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]})/..)
|
||||
|
||||
VERSION=$(cd "$SOURCE_DIR" && git describe --tags --abbrev=8 --dirty)-1~upstream-ubuntu2404
|
||||
|
||||
DOCKER_TAG=$(docker build -q - <<EOS
|
||||
FROM ubuntu:24.04
|
||||
RUN apt-get update && apt-get install -y wget cmake g++ capnproto libcapnp-dev rapidjson-dev libsqlite3-dev libboost-dev zlib1g-dev pkg-config
|
||||
EOS
|
||||
)
|
||||
|
||||
docker run --rm -i -v $SOURCE_DIR:/laminar:ro -v $OUTPUT_DIR:/output $DOCKER_TAG bash -xe <<EOS
|
||||
|
||||
mkdir /build
|
||||
cd /build
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DLAMINAR_VERSION=$VERSION -DZSH_COMPLETIONS_DIR=/usr/share/zsh/functions/Completion/Unix /laminar
|
||||
make -j4
|
||||
mkdir laminar
|
||||
make DESTDIR=laminar install/strip
|
||||
|
||||
mkdir laminar/DEBIAN
|
||||
cat <<EOF > laminar/DEBIAN/control
|
||||
Package: laminar
|
||||
Version: $VERSION
|
||||
Section:
|
||||
Priority: optional
|
||||
Architecture: amd64
|
||||
Maintainer: Oliver Giles <web ohwg net>
|
||||
Depends: libcapnp-1.0.1, libsqlite3-0, zlib1g
|
||||
Description: Lightweight Continuous Integration Service
|
||||
EOF
|
||||
echo /etc/laminar.conf > laminar/DEBIAN/conffiles
|
||||
cat <<EOF > laminar/DEBIAN/postinst
|
||||
#!/bin/bash
|
||||
echo Creating laminar user with home in /var/lib/laminar
|
||||
useradd -r -d /var/lib/laminar -s /usr/sbin/nologin laminar
|
||||
mkdir -p /var/lib/laminar/cfg/{jobs,contexts,scripts}
|
||||
chown -R laminar: /var/lib/laminar
|
||||
EOF
|
||||
chmod +x laminar/DEBIAN/postinst
|
||||
|
||||
dpkg-deb --build laminar
|
||||
mv laminar.deb /output/laminar_${VERSION}_amd64.deb
|
||||
EOS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright 2015-2026 Oliver Giles
|
||||
/// Copyright 2015 Oliver Giles
|
||||
///
|
||||
/// This file is part of Laminar
|
||||
///
|
||||
@@ -16,7 +16,8 @@
|
||||
/// You should have received a copy of the GNU General Public License
|
||||
/// along with Laminar. If not, see <http://www.gnu.org/licenses/>
|
||||
///
|
||||
#pragma once
|
||||
#ifndef LAMINAR_CONF_H_
|
||||
#define LAMINAR_CONF_H_
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
@@ -40,3 +41,5 @@ int StringMap::convert(std::string e);
|
||||
// beginning with '#'
|
||||
StringMap parseConfFile(const char* path);
|
||||
|
||||
|
||||
#endif // LAMINAR_CONF_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright 2015-2026 Oliver Giles
|
||||
/// Copyright 2015-2020 Oliver Giles
|
||||
///
|
||||
/// This file is part of Laminar
|
||||
///
|
||||
@@ -16,7 +16,8 @@
|
||||
/// You should have received a copy of the GNU General Public License
|
||||
/// along with Laminar. If not, see <http://www.gnu.org/licenses/>
|
||||
///
|
||||
#pragma once
|
||||
#ifndef LAMINAR_CONTEXT_H_
|
||||
#define LAMINAR_CONTEXT_H_
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
@@ -35,3 +36,5 @@ public:
|
||||
std::set<std::string> jobPatterns;
|
||||
};
|
||||
|
||||
|
||||
#endif // LAMINAR_CONTEXT_H_
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <sqlite3.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <cstdint>
|
||||
|
||||
struct StdevCtx {
|
||||
double mean;
|
||||
@@ -94,10 +93,6 @@ void Database::Statement::bindValue(int i, ulong e) {
|
||||
sqlite3_bind_int64(stmt, i, static_cast<int64_t>(e));
|
||||
}
|
||||
|
||||
void Database::Statement::bindValue(int i, long long e) {
|
||||
sqlite3_bind_int64(stmt, i, static_cast<int64_t>(e));
|
||||
}
|
||||
|
||||
void Database::Statement::bindValue(int i, const char* e) {
|
||||
sqlite3_bind_text(stmt, i, e, -1, nullptr);
|
||||
}
|
||||
@@ -134,10 +129,6 @@ template<> ulong Database::Statement::fetchColumn(int col) {
|
||||
return static_cast<ulong>(sqlite3_column_int64(stmt, col));
|
||||
}
|
||||
|
||||
template<> long long Database::Statement::fetchColumn(int col) {
|
||||
return sqlite3_column_int64(stmt, col);
|
||||
}
|
||||
|
||||
template<> double Database::Statement::fetchColumn(int col) {
|
||||
return sqlite3_column_double(stmt, col);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright 2015-2026 Oliver Giles
|
||||
/// Copyright 2015-2018 Oliver Giles
|
||||
///
|
||||
/// This file is part of Laminar
|
||||
///
|
||||
@@ -16,7 +16,8 @@
|
||||
/// You should have received a copy of the GNU General Public License
|
||||
/// along with Laminar. If not, see <http://www.gnu.org/licenses/>
|
||||
///
|
||||
#pragma once
|
||||
#ifndef LAMINAR_DATABASE_H_
|
||||
#define LAMINAR_DATABASE_H_
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
@@ -125,7 +126,6 @@ private:
|
||||
void bindValue(int i, uint e);
|
||||
void bindValue(int i, long e);
|
||||
void bindValue(int i, unsigned long e);
|
||||
void bindValue(int i, long long e);
|
||||
void bindValue(int i, const char* e);
|
||||
void bindValue(int i, const std::string& e);
|
||||
|
||||
@@ -157,3 +157,4 @@ template<> long Database::Statement::fetchColumn(int col);
|
||||
template<> ulong Database::Statement::fetchColumn(int col);
|
||||
template<> double Database::Statement::fetchColumn(int col);
|
||||
|
||||
#endif // LAMINAR_DATABASE_H_
|
||||
|
||||
13
src/http.cpp
13
src/http.cpp
@@ -131,16 +131,9 @@ kj::Promise<void> Http::cleanupPeers(kj::Timer& timer)
|
||||
{
|
||||
return timer.afterDelay(15 * kj::SECONDS).then([&]{
|
||||
for(EventPeer* p : eventPeers) {
|
||||
// Even single threaded, if load causes this timeout to be serviced
|
||||
// before writeEvents has created a fulfiller, or if an exception
|
||||
// caused the destruction of the promise but attach(peer) hasn't yet
|
||||
// removed it from the eventPeers list, we will see a null fulfiller
|
||||
// here
|
||||
if(p->fulfiller) {
|
||||
// an empty SSE message is a colon followed by two newlines
|
||||
p->pendingOutput.push_back(":\n\n");
|
||||
p->fulfiller->fulfill();
|
||||
}
|
||||
// an empty SSE message is a colon followed by two newlines
|
||||
p->pendingOutput.push_back(":\n\n");
|
||||
p->fulfiller->fulfill();
|
||||
}
|
||||
return cleanupPeers(timer);
|
||||
}).eagerlyEvaluate(nullptr);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright 2019-2026 Oliver Giles
|
||||
/// Copyright 2019-2020 Oliver Giles
|
||||
///
|
||||
/// This file is part of Laminar
|
||||
///
|
||||
@@ -16,7 +16,8 @@
|
||||
/// You should have received a copy of the GNU General Public License
|
||||
/// along with Laminar. If not, see <http://www.gnu.org/licenses/>
|
||||
///
|
||||
#pragma once
|
||||
#ifndef LAMINAR_HTTP_H_
|
||||
#define LAMINAR_HTTP_H_
|
||||
|
||||
#include <kj/memory.h>
|
||||
#include <kj/compat/http.h>
|
||||
@@ -65,3 +66,4 @@ private:
|
||||
kj::HttpHeaderId ACCEPT;
|
||||
};
|
||||
|
||||
#endif //LAMINAR_HTTP_H_
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <fnmatch.h>
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
#include <zlib.h>
|
||||
|
||||
#define COMPRESS_LOG_MIN_SIZE 1024
|
||||
@@ -96,31 +95,11 @@ Laminar::Laminar(Server &server, Settings settings) :
|
||||
db = new Database((homePath/"laminar.sqlite").toString(true).cStr());
|
||||
// Prepare database for first use
|
||||
// TODO: error handling
|
||||
const char *create_table_stmt =
|
||||
"CREATE TABLE IF NOT EXISTS builds("
|
||||
"name TEXT, number INT UNSIGNED, node TEXT, queuedAt INT, "
|
||||
"startedAt INT, completedAt INT, result INT, output TEXT, "
|
||||
"outputLen INT, parentJob TEXT, parentBuild INT, reason TEXT, "
|
||||
"PRIMARY KEY (name, number DESC))";
|
||||
db->exec(create_table_stmt);
|
||||
|
||||
// Migrate from (name, number) primary key to (name, number DESC).
|
||||
// SQLite does not allow to alter primary key of existing table, so
|
||||
// we have to create a new table.
|
||||
db->stmt("SELECT sql LIKE '%, PRIMARY KEY (name, number))' "
|
||||
"FROM sqlite_master WHERE type = 'table' AND name = 'builds'")
|
||||
.fetch<int>([&](int has_old_index) {
|
||||
if (has_old_index) {
|
||||
LLOG(INFO, "Migrating table to the new primary key");
|
||||
db->exec("BEGIN TRANSACTION");
|
||||
db->exec("ALTER TABLE builds RENAME TO builds_old");
|
||||
db->exec(create_table_stmt);
|
||||
db->exec("INSERT INTO builds SELECT * FROM builds_old");
|
||||
db->exec("DROP TABLE builds_old");
|
||||
db->exec("COMMIT");
|
||||
}
|
||||
});
|
||||
|
||||
db->exec("CREATE TABLE IF NOT EXISTS builds("
|
||||
"name TEXT, number INT UNSIGNED, node TEXT, queuedAt INT, "
|
||||
"startedAt INT, completedAt INT, result INT, output TEXT, "
|
||||
"outputLen INT, parentJob TEXT, parentBuild INT, reason TEXT, "
|
||||
"PRIMARY KEY (name, number))");
|
||||
db->exec("CREATE INDEX IF NOT EXISTS idx_completion_time ON builds("
|
||||
"completedAt DESC)");
|
||||
|
||||
@@ -359,8 +338,9 @@ std::string Laminar::getStatus(MonitorScope scope) {
|
||||
j.set("description", desc == jobDescriptions.end() ? "" : desc->second);
|
||||
} else if(scope.type == MonitorScope::ALL) {
|
||||
j.startArray("jobs");
|
||||
db->stmt("SELECT name, number, startedAt, completedAt, result, reason "
|
||||
"FROM builds GROUP BY name HAVING number = MAX(number)")
|
||||
db->stmt("SELECT name,number,startedAt,completedAt,result,reason FROM builds b "
|
||||
"JOIN (SELECT name n,MAX(number) latest FROM builds WHERE result IS NOT NULL GROUP BY n) q "
|
||||
"ON b.name = q.n AND b.number = latest")
|
||||
.fetch<str,uint,time_t,time_t,int,str>([&](str name,uint number, time_t started, time_t completed, int result, str reason){
|
||||
j.StartObject();
|
||||
j.set("name", name);
|
||||
@@ -873,7 +853,6 @@ R"x(
|
||||
return false;
|
||||
|
||||
badge = svg;
|
||||
std::free(svg);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright 2015-2026 Oliver Giles
|
||||
/// Copyright 2015-2022 Oliver Giles
|
||||
///
|
||||
/// This file is part of Laminar
|
||||
///
|
||||
@@ -16,14 +16,14 @@
|
||||
/// You should have received a copy of the GNU General Public License
|
||||
/// along with Laminar. If not, see <http://www.gnu.org/licenses/>
|
||||
///
|
||||
#pragma once
|
||||
#ifndef LAMINAR_LAMINAR_H_
|
||||
#define LAMINAR_LAMINAR_H_
|
||||
|
||||
#include "run.h"
|
||||
#include "monitorscope.h"
|
||||
#include "context.h"
|
||||
#include "database.h"
|
||||
|
||||
#include <list>
|
||||
#include <unordered_map>
|
||||
#include <kj/filesystem.h>
|
||||
#include <kj/async-io.h>
|
||||
@@ -134,3 +134,4 @@ private:
|
||||
kj::Own<Rpc> rpc;
|
||||
};
|
||||
|
||||
#endif // LAMINAR_LAMINAR_H_
|
||||
|
||||
@@ -21,11 +21,7 @@
|
||||
#include <unistd.h>
|
||||
#include <queue>
|
||||
#include <dirent.h>
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/procctl.h>
|
||||
#else
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <kj/async-io.h>
|
||||
@@ -34,8 +30,6 @@
|
||||
|
||||
#include "run.h"
|
||||
|
||||
const int SET_ENV_BUF_SIZE = 1024;
|
||||
|
||||
// short syntax helper for kj::Path
|
||||
template<typename T>
|
||||
inline kj::Path operator/(const kj::Path& p, const T& ext) {
|
||||
@@ -133,7 +127,7 @@ Leader::Leader(kj::AsyncIoContext &ioContext, kj::Filesystem &fs, const char *jo
|
||||
|
||||
LSYSCALL(pipe(setEnvPipe));
|
||||
auto event = ioContext.lowLevelProvider->wrapInputFd(setEnvPipe[0], kj::LowLevelAsyncIoProvider::TAKE_OWNERSHIP);
|
||||
auto buffer = kj::heapArrayBuilder<char>(SET_ENV_BUF_SIZE);
|
||||
auto buffer = kj::heapArrayBuilder<char>(1024);
|
||||
tasks.add(readEnvPipe(event, buffer.asPtr().begin()).attach(kj::mv(event), kj::mv(buffer)));
|
||||
}
|
||||
|
||||
@@ -297,7 +291,7 @@ kj::Promise<void> Leader::reapChildProcesses()
|
||||
}
|
||||
|
||||
kj::Promise<void> Leader::readEnvPipe(kj::AsyncInputStream *stream, char *buffer) {
|
||||
return stream->tryRead(buffer, 1, SET_ENV_BUF_SIZE - 1).then([this,stream,buffer](size_t sz) {
|
||||
return stream->tryRead(buffer, 1, 1024).then([this,stream,buffer](size_t sz) {
|
||||
if(sz > 0) {
|
||||
buffer[sz] = '\0';
|
||||
if(char* eq = strchr(buffer, '=')) {
|
||||
@@ -323,11 +317,7 @@ int leader_main(void) {
|
||||
// will be reparented to this one instead of init (or higher layer subreaper).
|
||||
// We do this so that the run will wait until all descedents exit before executing
|
||||
// the next step.
|
||||
#if defined(__FreeBSD__)
|
||||
procctl(P_PID, 0, PROC_REAP_ACQUIRE, NULL);
|
||||
#else
|
||||
prctl(PR_SET_CHILD_SUBREAPER, 1, NULL, NULL, NULL);
|
||||
#endif
|
||||
|
||||
// Become the leader of a new process group. This is so that all child processes
|
||||
// will also get a kill signal when the run is aborted
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright 2019-2026 Oliver Giles
|
||||
/// Copyright 2019 Oliver Giles
|
||||
///
|
||||
/// This file is part of Laminar
|
||||
///
|
||||
@@ -16,7 +16,8 @@
|
||||
/// You should have received a copy of the GNU General Public License
|
||||
/// along with Laminar. If not, see <http://www.gnu.org/licenses/>
|
||||
///
|
||||
#pragma once
|
||||
#ifndef LAMINAR_LEADER_H_
|
||||
#define LAMINAR_LEADER_H_
|
||||
|
||||
// Main function for the leader process which is responsible for
|
||||
// executing all the scripts which make up a Run. Separating this
|
||||
@@ -32,3 +33,4 @@
|
||||
|
||||
int leader_main(void);
|
||||
|
||||
#endif // LAMINAR_LEADER_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright 2015-2026 Oliver Giles
|
||||
/// Copyright 2015-2020 Oliver Giles
|
||||
///
|
||||
/// This file is part of Laminar
|
||||
///
|
||||
@@ -16,7 +16,8 @@
|
||||
/// You should have received a copy of the GNU General Public License
|
||||
/// along with Laminar. If not, see <http://www.gnu.org/licenses/>
|
||||
///
|
||||
#pragma once
|
||||
#ifndef LAMINAR_LOG_H_
|
||||
#define LAMINAR_LOG_H_
|
||||
|
||||
#include <kj/debug.h>
|
||||
#include <utility>
|
||||
@@ -68,3 +69,5 @@ namespace _ {
|
||||
|
||||
const char* laminar_version();
|
||||
|
||||
#endif // LAMINAR_LOG_H_
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright 2015-2026 Oliver Giles
|
||||
/// Copyright 2015-2019 Oliver Giles
|
||||
///
|
||||
/// This file is part of Laminar
|
||||
///
|
||||
@@ -16,7 +16,8 @@
|
||||
/// You should have received a copy of the GNU General Public License
|
||||
/// along with Laminar. If not, see <http://www.gnu.org/licenses/>
|
||||
///
|
||||
#pragma once
|
||||
#ifndef LAMINAR_MONITORSCOPE_H_
|
||||
#define LAMINAR_MONITORSCOPE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -58,3 +59,5 @@ struct MonitorScope {
|
||||
bool order_desc;
|
||||
};
|
||||
|
||||
#endif // LAMINAR_MONITORSCOPE_H_
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright 2015-2026 Oliver Giles
|
||||
/// Copyright 2015-2019 Oliver Giles
|
||||
///
|
||||
/// This file is part of Laminar
|
||||
///
|
||||
@@ -16,7 +16,8 @@
|
||||
/// You should have received a copy of the GNU General Public License
|
||||
/// along with Laminar. If not, see <http://www.gnu.org/licenses/>
|
||||
///
|
||||
#pragma once
|
||||
#ifndef LAMINAR_RESOURCES_H_
|
||||
#define LAMINAR_RESOURCES_H_
|
||||
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
@@ -46,3 +47,4 @@ private:
|
||||
std::string index_html;
|
||||
};
|
||||
|
||||
#endif // LAMINAR_RESOURCES_H_
|
||||
|
||||
@@ -158,7 +158,7 @@
|
||||
<template id="run"><div style="display: grid; grid-template-rows: auto 1fr">
|
||||
<div style="padding: 15px">
|
||||
<div style="display: grid; grid-template-columns: auto 25px auto auto 1fr 400px; gap: 5px; align-items: center">
|
||||
<h2 style="white-space: nowrap"><span v-html="runIcon(job.result)"></span> <router-link :to="'jobs/'+route.params.name">{{route.params.name}}</router-link> #{{route.params.number}}</h2>
|
||||
<h2 style="white-space: nowrap"><span v-html="runIcon(job.result)"></span> {{route.params.name}} #{{route.params.number}}</h2>
|
||||
<span></span>
|
||||
<router-link :disabled="route.params.number == 1" :to="'jobs/'+route.params.name+'/'+(route.params.number-1)" tag="button">«</router-link>
|
||||
<router-link :disabled="route.params.number == latestNum" :to="'jobs/'+route.params.name+'/'+(parseInt(route.params.number)+1)" tag="button">»</router-link>
|
||||
|
||||
@@ -669,23 +669,6 @@ const Run = templateId => {
|
||||
latestNum: null,
|
||||
logComplete: false,
|
||||
};
|
||||
// if the page is scrolled to the bottom, the scroll position "sticks"
|
||||
// there and follows new log output as it is rendered, like tail -f.
|
||||
// Any upward scroll disengages this, scrolling back to the bottom
|
||||
// re-engages it. This must be tracked with event listeners rather than
|
||||
// sampled when rendering, because scrolling is handled outside the main
|
||||
// thread: while the main thread is busy rendering a large log chunk,
|
||||
// window.scrollY may still report the old (bottom) position, which
|
||||
// would wrongly yank the page back down and swallow the user's scroll.
|
||||
let stickToBottom = true;
|
||||
window.addEventListener('wheel', evt => {
|
||||
if (evt.deltaY < 0)
|
||||
stickToBottom = false;
|
||||
});
|
||||
window.addEventListener('scroll', () => {
|
||||
stickToBottom = window.innerHeight + window.scrollY >=
|
||||
document.documentElement.scrollHeight - 1;
|
||||
});
|
||||
const logFetcher = (vm, name, num) => {
|
||||
const abort = new AbortController();
|
||||
fetch('log/'+name+'/'+num, {signal:abort.signal}).then(res => {
|
||||
@@ -722,9 +705,6 @@ const Run = templateId => {
|
||||
state.logComplete = true;
|
||||
}
|
||||
|
||||
if (stickToBottom)
|
||||
window.scrollTo(0, document.documentElement.scrollHeight);
|
||||
|
||||
lastUiUpdate = Date.now();
|
||||
tid = null;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ a.active:hover { text-decoration: none; }
|
||||
/* run console ansi colors (based on base16-default-dark and base16-bright) */
|
||||
:root {
|
||||
--ansi-black: #181818;
|
||||
--ansi-red: #ab4642;
|
||||
--ansi-red: #f8f8f8;
|
||||
--ansi-green: #a1b56c;
|
||||
--ansi-yellow: #f7ca88;
|
||||
--ansi-blue: #7cafc2;
|
||||
@@ -158,7 +158,7 @@ a.active:hover { text-decoration: none; }
|
||||
/* run console */
|
||||
.console-log { padding: 15px; background-color: var(--ansi-black); }
|
||||
.console-log code { white-space: pre-wrap; color: var(--ansi-white); }
|
||||
.console-log a { color: var(--ansi-brightwhite); text-decoration: underline dotted; }
|
||||
.console-log a { color: var(--ansi-brightwhite); }
|
||||
|
||||
/* text input (job filtering) */
|
||||
input { padding: 5px 8px; }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright 2019-2026 Oliver Giles
|
||||
/// Copyright 2019-2020 Oliver Giles
|
||||
///
|
||||
/// This file is part of Laminar
|
||||
///
|
||||
@@ -16,7 +16,8 @@
|
||||
/// You should have received a copy of the GNU General Public License
|
||||
/// along with Laminar. If not, see <http://www.gnu.org/licenses/>
|
||||
///
|
||||
#pragma once
|
||||
#ifndef LAMINAR_RPC_H_
|
||||
#define LAMINAR_RPC_H_
|
||||
|
||||
#include <capnp/ez-rpc.h>
|
||||
#include <capnp/rpc-twoparty.h>
|
||||
@@ -32,3 +33,4 @@ public:
|
||||
capnp::Capability::Client rpcInterface;
|
||||
};
|
||||
|
||||
#endif //LAMINAR_RPC_H_
|
||||
|
||||
19
src/run.cpp
19
src/run.cpp
@@ -21,16 +21,10 @@
|
||||
#include "conf.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <sys/wait.h>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/limits.h>
|
||||
#endif
|
||||
|
||||
// short syntax helper for kj::Path
|
||||
template<typename T>
|
||||
inline kj::Path operator/(const kj::Path& p, const T& ext) {
|
||||
@@ -159,20 +153,7 @@ kj::Promise<RunState> Run::start(RunState lastResult, std::shared_ptr<Context> c
|
||||
// main() by calling leader_main()
|
||||
char* procName;
|
||||
if(asprintf(&procName, "{laminar} %s:%d", name.data(), build) > 0)
|
||||
#if defined(__FreeBSD__)
|
||||
{
|
||||
int sysctl_rq[] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
|
||||
size_t self_exe_len = PATH_MAX;
|
||||
char self_exe[PATH_MAX];
|
||||
|
||||
if (sysctl(sysctl_rq, 4, self_exe, &self_exe_len, NULL, 0))
|
||||
_exit(EXIT_FAILURE);
|
||||
|
||||
execl(self_exe, procName, NULL); // does not return
|
||||
}
|
||||
#else
|
||||
execl("/proc/self/exe", procName, NULL); // does not return
|
||||
#endif
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
15
src/run.h
15
src/run.h
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright 2015-2026 Oliver Giles
|
||||
/// Copyright 2015-2018 Oliver Giles
|
||||
///
|
||||
/// This file is part of Laminar
|
||||
///
|
||||
@@ -16,10 +16,14 @@
|
||||
/// You should have received a copy of the GNU General Public License
|
||||
/// along with Laminar. If not, see <http://www.gnu.org/licenses/>
|
||||
///
|
||||
#pragma once
|
||||
#ifndef LAMINAR_RUN_H_
|
||||
#define LAMINAR_RUN_H_
|
||||
|
||||
#include <string>
|
||||
#include <queue>
|
||||
#include <list>
|
||||
#include <functional>
|
||||
#include <ostream>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include <kj/async.h>
|
||||
@@ -105,7 +109,6 @@ private:
|
||||
// be executing thousands of builds at the same time
|
||||
#include <boost/multi_index_container.hpp>
|
||||
#include <boost/multi_index/hashed_index.hpp>
|
||||
#include <boost/multi_index/indexed_by.hpp>
|
||||
#include <boost/multi_index/member.hpp>
|
||||
#include <boost/multi_index/composite_key.hpp>
|
||||
#include <boost/multi_index/global_fun.hpp>
|
||||
@@ -122,7 +125,7 @@ struct _run_same {
|
||||
};
|
||||
|
||||
// A single Run can be fetched by...
|
||||
typedef bmi::indexed_by<
|
||||
struct _run_index : bmi::indexed_by<
|
||||
bmi::hashed_unique<bmi::composite_key<
|
||||
std::shared_ptr<Run>,
|
||||
// a combination of their job name and build number
|
||||
@@ -135,7 +138,8 @@ typedef bmi::indexed_by<
|
||||
bmi::ordered_non_unique<bmi::member<Run, time_t, &Run::startedAt>>,
|
||||
// or by their job name
|
||||
bmi::ordered_non_unique<bmi::member<Run, std::string, &Run::name>>
|
||||
> _run_index;
|
||||
>
|
||||
{};
|
||||
|
||||
struct RunSet: public boost::multi_index_container<
|
||||
std::shared_ptr<Run>,
|
||||
@@ -154,3 +158,4 @@ struct RunSet: public boost::multi_index_container<
|
||||
typename bmi::nth_index<RunSet, 3>::type const& byJobName() const { return get<3>(); }
|
||||
};
|
||||
|
||||
#endif // LAMINAR_RUN_H_
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright 2015-2026 Oliver Giles
|
||||
/// Copyright 2015-2021 Oliver Giles
|
||||
///
|
||||
/// This file is part of Laminar
|
||||
///
|
||||
@@ -26,9 +26,11 @@
|
||||
#include <kj/async-unix.h>
|
||||
#include <kj/threadlocal.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <sys/eventfd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/inotify.h>
|
||||
#include <sys/signalfd.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
// Size of buffer used to read from file descriptors. Should be
|
||||
// a multiple of sizeof(struct signalfd_siginfo) == 128
|
||||
@@ -148,10 +150,11 @@ void Server::listenHttp(Http &http, kj::StringPtr httpBindAddress)
|
||||
|
||||
kj::Promise<void> Server::acceptRpcClient(Rpc& rpc, kj::Own<kj::ConnectionReceiver>&& listener) {
|
||||
kj::ConnectionReceiver& cr = *listener.get();
|
||||
return cr.accept().then([this, &rpc, l = kj::mv(listener)](kj::Own<kj::AsyncIoStream>&& connection) mutable {
|
||||
return cr.accept().then(kj::mvCapture(kj::mv(listener),
|
||||
[this, &rpc](kj::Own<kj::ConnectionReceiver>&& listener, kj::Own<kj::AsyncIoStream>&& connection) {
|
||||
addTask(rpc.accept(kj::mv(connection)));
|
||||
return acceptRpcClient(rpc, kj::mv(l));
|
||||
});
|
||||
return acceptRpcClient(rpc, kj::mv(listener));
|
||||
}));
|
||||
}
|
||||
|
||||
// returns a promise which will read a chunk of data from the file descriptor
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright 2015-2026 Oliver Giles
|
||||
/// Copyright 2015-2020 Oliver Giles
|
||||
///
|
||||
/// This file is part of Laminar
|
||||
///
|
||||
@@ -16,7 +16,8 @@
|
||||
/// You should have received a copy of the GNU General Public License
|
||||
/// along with Laminar. If not, see <http://www.gnu.org/licenses/>
|
||||
///
|
||||
#pragma once
|
||||
#ifndef LAMINAR_SERVER_H_
|
||||
#define LAMINAR_SERVER_H_
|
||||
|
||||
#include <kj/async-io.h>
|
||||
#include <kj/compat/http.h>
|
||||
@@ -71,3 +72,4 @@ private:
|
||||
kj::Maybe<kj::Promise<void>> reapWatch;
|
||||
};
|
||||
|
||||
#endif // LAMINAR_SERVER_H_
|
||||
|
||||
@@ -52,7 +52,7 @@ private:
|
||||
std::vector<rapidjson::Document> receivedMessages;
|
||||
|
||||
kj::Promise<void> waitForMessages(kj::AsyncInputStream* stream, ulong offset) {
|
||||
return stream->read(buffer.asPtr().begin() + offset, 1, BUFFER_SIZE).then([=, this](size_t s) {
|
||||
return stream->read(buffer.asPtr().begin() + offset, 1, BUFFER_SIZE).then([=](size_t s) {
|
||||
ulong end = offset + s;
|
||||
buffer.asPtr().begin()[end] = '\0';
|
||||
if(strcmp(&buffer.asPtr().begin()[end - 2], "\n\n") == 0) {
|
||||
|
||||
Reference in New Issue
Block a user