Skip to content

Commit

Permalink
Merge pull request #25 from justusranvier/develop
Browse files Browse the repository at this point in the history
setup actions
  • Loading branch information
justusranvier authored Jan 3, 2024
2 parents 19ad824 + ae4e7b9 commit e69cdde
Show file tree
Hide file tree
Showing 12 changed files with 343 additions and 3 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: compile

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
compile:
name: ${{ matrix.toolchain }}-${{ matrix.preset }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain: [gcc, clang]
preset: [default]
include:
- toolchain: gcc
docker: 1.189.0
compiler: gcc
- toolchain: clang
docker: 1.189.0
compiler: clang
steps:
- name: Checkout opentxs
uses: actions/checkout@v3
with:
fetch-depth: '0'
submodules: 'recursive'
- name: Get more disk space
run: |
sudo rm -rf "/usr/local/lib/android"
sudo rm -rf "${JAVA_HOME_8_X64}"
sudo rm -rf "${JAVA_HOME_11_X64}"
shell: bash
continue-on-error: true
- name: Cache Docker images
uses: ScribeMD/[email protected]
with:
key: docker-ci-${{ matrix.docker }}
- name: Setup build environment
run: |
docker pull opentransactions/downstream-ci:${{ matrix.docker }}
- name: Compile
run: |
mkdir -p /tmp/opentxs
docker run --mount type=bind,src=${{ github.workspace }},dst=/usr/src/ --mount type=bind,src=/tmp/opentxs,dst=/home/output -i opentransactions/downstream-ci:${{ matrix.docker }} /usr/src/ ${{ matrix.compiler }} ${{ matrix.preset }}
31 changes: 31 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: format

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
format:
name: clang-format
runs-on: ubuntu-latest
strategy:
fail-fast: false
env:
docker: '1.189.0'
steps:
- name: Checkout opentxs
uses: actions/checkout@v3
with:
fetch-depth: '0'
submodules: 'recursive'
- name: Cache Docker images
uses: ScribeMD/[email protected]
with:
key: docker-ci-${{ matrix.docker }}
- name: Setup build environment
run: |
docker pull opentransactions/downstream-ci:${{ env.docker }}
- name: Check formatting
run: |
mkdir -p /tmp/opentxs
docker run --read-only --mount type=bind,src=${{ github.workspace }},dst=/home/src -i --entrypoint /usr/bin/check-formatting.sh opentransactions/downstream-ci:${{ env.docker }} /home/src
31 changes: 31 additions & 0 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: iwyu

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
includes:
name: include-what-you-use
runs-on: ubuntu-22.04-large64
strategy:
fail-fast: true
env:
docker: '1.189.0'
steps:
- name: Checkout opentxs
uses: actions/checkout@v3
with:
fetch-depth: '0'
submodules: 'recursive'
- name: Cache Docker images
uses: ScribeMD/[email protected]
with:
key: docker-ci-${{ matrix.docker }}
- name: Setup build environment
run: |
docker pull opentransactions/downstream-ci:${{ env.docker }}
- name: Check includes
run: |
mkdir -p /tmp/opentxs
docker run --mount type=bind,src=${{ github.workspace }},dst=/usr/src/ --mount type=bind,src=/tmp/opentxs,dst=/home/output -i --entrypoint /usr/bin/run-iwyu.sh opentransactions/downstream-ci:${{ env.docker }} /usr/src/ iwyu
100 changes: 100 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 26,
"patch": 0
},
"configurePresets": [
{
"name": "mode-debug",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "mode-release",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "default",
"displayName": "Default",
"description": "Default build using Ninja generator",
"generator": "Ninja",
"inherits": "mode-debug",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_UNITY_BUILD": "ON"
}
},
{
"name": "iwyu",
"displayName": "iwyu",
"description": "configure build for include-what-you-use ci check",
"inherits": "default",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"OPENTXS_NOTARY_PEDANTIC_BUILD": "OFF",
"OPENTXS_NOTARY_IWYU": "ON",
"CMAKE_UNITY_BUILD": "OFF"
}
}
],
"buildPresets": [
{
"hidden": true,
"name": "ninja",
"nativeToolOptions": [
"-k 0"
]
},
{
"name": "default",
"configurePreset": "default",
"inherits": [
"ninja"
]
},
{
"name": "iwyu",
"configurePreset": "iwyu",
"inherits": [
"ninja"
]
}
],
"workflowPresets": [
{
"name": "default",
"steps": [
{
"type": "configure",
"name": "default"
},
{
"type": "build",
"name": "default"
}
]
},
{
"name": "iwyu",
"steps": [
{
"type": "configure",
"name": "iwyu"
},
{
"type": "build",
"name": "iwyu"
}
]
}
]
}
6 changes: 3 additions & 3 deletions tools/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ To use a specific version of libopentxs add ```--build-arg "OPENTXS_VERSION=<des

### Running the image

Persistent storage must be mounted at /var/lib/metier inside the image and the ```--user``` argument to ```docker run``` should be set to match the ownership of this directory.
Persistent storage must be mounted at /srv/metier-server inside the image and the ```--user``` argument to ```docker run``` should be set to match the ownership of this directory.

#### Examples

```
docker run \
--read-only \
--mount type=bind,src=/var/lib/metier,dst=/var/lib/metier \
--mount type=bind,src=/srv/metier-server,dst=/srv/metier-server \
--user 1000:1000 \
--ulimit nofile=262144:262144 \
-p 8814:8814/tcp \
Expand All @@ -37,7 +37,7 @@ docker run \
```
docker run \
--read-only \
--mount type=bind,src=/var/lib/metier,dst=/var/lib/metier \
--mount type=bind,src=/srv/metier-server,dst=/srv/metier-server \
--user 1000:1000 \
--ulimit nofile=262144:262144 \
-p 8814:8814/tcp \
Expand Down
18 changes: 18 additions & 0 deletions tools/docker/compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG OPENTXS_SDK
ARG OPENTXS_VERSION
ARG SDK="${OPENTXS_SDK}:${OPENTXS_VERSION}"

FROM ${SDK} AS compile
COPY --from=metier-server-download /usr/src/metier-server /usr/src/metier-server
RUN --mount=type=tmpfs,target=/tmp/metier-server /opt/cmake/bin/cmake \
-S /usr/src/metier-server \
-B /tmp/metier-server \
-GNinja \
-DCMAKE_INSTALL_PREFIX=/opt/metier-server \
-DCMAKE_C_FLAGS="-O2" \
-DCMAKE_CXX_FLAGS="-O2" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_UNITY_BUILD=ON \
-DCMAKE_UNITY_BUILD_BATCH_SIZE=0 \
&& /opt/cmake/bin/cmake --build /tmp/metier-server \
&& /opt/cmake/bin/cmake --install /tmp/metier-server
71 changes: 71 additions & 0 deletions tools/docker/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
variable "tag" { default = "23.3.2" }
variable "opentxs" { default = "1.189.0" }

variable "target_arch" {
default = "amd64"
}
variable "repo" {
default = "https://github.com/Open-Transactions/metier-server"
}

variable "sdk" {
default = "opentransactions/alpine-sdk"
}

variable "runtime" {
default = "opentransactions/alpine-runtime"
}

target "downloader" {
dockerfile = "downloader"
target = "downloader"
tags = [
"temp-metier-server/downloader"
]
}

target "metier-server-download" {
dockerfile = "download"
target = "metier-server-download"
contexts = {
download = "target:downloader"
}
args = {
METIER_SERVER_REPO = "${repo}"
METIER_SERVER_TAG = "${tag}"
}
tags = [
"temp-metier-server/metier-server-download"
]
}

target "compile" {
dockerfile = "compile"
target = "compile"
contexts = {
metier-server-download = "target:metier-server-download"
}
args = {
OPENTXS_SDK = "${sdk}"
OPENTXS_VERSION = "${opentxs}"
}
tags = [
"temp-metier-server/compile"
]
}

target "default" {
dockerfile = "run"
target = "run"
contexts = {
compile = "target:compile"
}
args = {
OPENTXS_RUNTIME = "${runtime}"
OPENTXS_VERSION = "${opentxs}"
}
tags = [
"opentransactions/notary:${tag}-${opentxs}-${target_arch}",
"opentransactions/notary:latest-${target_arch}"
]
}
8 changes: 8 additions & 0 deletions tools/docker/download
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM download AS metier-server-download
ARG METIER_SERVER_REPO
ARG METIER_SERVER_TAG

RUN --mount=type=tmpfs,target=/tmp/download/ cd /tmp/download \
&& wget -O /tmp/download/metier-server.tar.gz "${METIER_SERVER_REPO}/archive/refs/tags/${METIER_SERVER_TAG}.tar.gz" \
&& tar -xf metier-server.tar.gz \
&& mv "metier-server-${METIER_SERVER_TAG}" /usr/src/metier-server
14 changes: 14 additions & 0 deletions tools/docker/downloader
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG DOWNLOAD_UBUNTU_VERSION="22.04"

FROM ubuntu:${DOWNLOAD_UBUNTU_VERSION} AS downloader
RUN mkdir -p /usr/src
RUN --mount=type=tmpfs,target=/var/lib/apt/lists apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -qq install \
bzip2 \
git \
lzop \
p7zip \
rsync \
unzip \
wget \
xz-utils
8 changes: 8 additions & 0 deletions tools/docker/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ARG OPENTXS_RUNTIME
ARG OPENTXS_VERSION
ARG RUNTIME="${OPENTXS_RUNTIME}:${OPENTXS_VERSION}"

FROM ${RUNTIME} AS run
COPY --from=compile /opt/metier-server /usr
ENTRYPOINT [ "/usr/bin/metier-server", "--ot_home=/srv/metier-server" ]
CMD []
1 change: 1 addition & 0 deletions tools/format/exclude
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git
12 changes: 12 additions & 0 deletions tools/iwyu/mapping_file
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{ "include": ["@<boost/program_options/.*>", "private", "<boost/program_options.hpp>", "public"] },
{ "symbol": ["__forced_unwind", "private", "<stdexcept>", "public"] },
{ "symbol": ["int8_t", "private", "<cstdint>", "public"] },
{ "symbol": ["uint8_t", "private", "<cstdint>", "public"] },
{ "symbol": ["int16_t", "private", "<cstdint>", "public"] },
{ "symbol": ["uint16_t", "private", "<cstdint>", "public"] },
{ "symbol": ["int32_t", "private", "<cstdint>", "public"] },
{ "symbol": ["uint32_t", "private", "<cstdint>", "public"] },
{ "symbol": ["int64_t", "private", "<cstdint>", "public"] },
{ "symbol": ["uint64_t", "private", "<cstdint>", "public"] },
]

0 comments on commit e69cdde

Please sign in to comment.