diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b4d18db..769ea76 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,6 +7,7 @@ on: jobs: coverage: + if: false name: Code coverage runs-on: ubuntu-latest concurrency: diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 693e42f..b2998d3 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -6,6 +6,7 @@ on: release: types: - published + pull_request: workflow_dispatch: jobs: @@ -17,25 +18,32 @@ jobs: contents: read packages: write steps: - - uses: docker/setup-qemu-action@v3 - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 with: username: ${{ vars.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - uses: actions/checkout@v4 - uses: docker/metadata-action@v5 id: meta with: - images: uatuko/ruek + images: | + ${{ github.repository }} + ghcr.io/${{ github.repository }} tags: | - type=raw,value=latest,enable={{is_default_branch}} + type=raw,value=latest type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} - name: Build and publish uses: docker/build-push-action@v6 with: + annotations: ${{ steps.meta.outputs.annotations }} context: . file: Containerfile platforms: | @@ -43,3 +51,9 @@ jobs: linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} + - uses: actions/delete-package-versions@v5 + with: + package-name: ruek + package-type: container + min-versions-to-keep: 2 + delete-only-untagged-versions: true diff --git a/Containerfile b/Containerfile index 7427b96..e428c4a 100644 --- a/Containerfile +++ b/Containerfile @@ -1,19 +1,32 @@ -FROM debian:12-slim as builder +FROM --platform=$BUILDPLATFORM debian:12-slim as builder + +ARG TARGETARCH + +COPY . /tmp/source +WORKDIR /tmp RUN apt-get update \ + && \ + ruek_march=$(./source/bin/march.sh) \ + && \ + if [ "$ruek_march" = "x86_64" ]; then ruek_march=x86-64; fi \ && \ apt-get install -y --no-install-recommends \ + binutils-${ruek_march}-linux-gnu \ cmake ninja-build \ - clang libclang-rt-dev \ + g++ \ protobuf-compiler libprotobuf-dev libprotoc-dev \ libpq-dev COPY . /tmp/source WORKDIR /tmp -RUN cmake -B build -G Ninja -S source/ \ - -DCMAKE_BUILD_TYPE=Release \ - -DRUEK_BUILD_TESTING=OFF +RUN ruek_march=$(./source/bin/march.sh) \ + && \ + cmake -B build -G Ninja -S source/ \ + -DCMAKE_CXX_COMPILER_TARGET=${ruek_march}-linux-gnu \ + -DCMAKE_BUILD_TYPE=Release \ + -DRUEK_BUILD_TESTING=OFF RUN cmake --build build/ --config Release diff --git a/bin/march.sh b/bin/march.sh new file mode 100755 index 0000000..5e69362 --- /dev/null +++ b/bin/march.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env sh + +: ${ruek_march=unknown} + +if [ -z ${TARGETARCH} ]; then + TARGETARCH=$(uname -m) +fi + +case ${TARGETARCH} in + amd64 | x86_64) + ruek_march=x86_64 + ;; + aarch64 | arm64) + ruek_march=aarch64 + ;; +esac + +echo ${ruek_march} diff --git a/src/svc/authz.h b/src/svc/authz.h index d32da85..fd53d90 100644 --- a/src/svc/authz.h +++ b/src/svc/authz.h @@ -17,16 +17,6 @@ class Impl { return {grpcxx::status::code_t::unimplemented, std::nullopt}; } - template <> - rpcCheck::result_type call(grpcxx::context &ctx, const rpcCheck::request_type &req); - - template <> - rpcGrant::result_type call(grpcxx::context &ctx, const rpcGrant::request_type &req); - - template <> - rpcRevoke::result_type call( - grpcxx::context &ctx, const rpcRevoke::request_type &req); - google::rpc::Status exception() noexcept; private: @@ -35,5 +25,15 @@ class Impl { db::Tuple map(const grpcxx::context &ctx, const rpcGrant::request_type &from) const noexcept; rpcGrant::response_type map(const db::Tuple &from) const noexcept; }; + +template <> +rpcCheck::result_type Impl::call(grpcxx::context &ctx, const rpcCheck::request_type &req); + +template <> +rpcGrant::result_type Impl::call(grpcxx::context &ctx, const rpcGrant::request_type &req); + +template <> +rpcRevoke::result_type Impl::call( + grpcxx::context &ctx, const rpcRevoke::request_type &req); } // namespace authz } // namespace svc diff --git a/src/svc/entities.h b/src/svc/entities.h index 6a62392..a118bed 100644 --- a/src/svc/entities.h +++ b/src/svc/entities.h @@ -18,23 +18,23 @@ class Impl { return {grpcxx::status::code_t::unimplemented, std::nullopt}; } - template <> - rpcList::result_type call(grpcxx::context &ctx, const rpcList::request_type &req); - - template <> - rpcListPrincipals::result_type call( - grpcxx::context &ctx, const rpcListPrincipals::request_type &req); - google::rpc::Status exception() noexcept; private: template T map(const F &) const noexcept; +}; - template <> rpcList::response_type map(const db::Tuples &from) const noexcept; - template <> rpcListPrincipals::response_type map(const db::Tuples &from) const noexcept; +template <> +rpcList::result_type Impl::call(grpcxx::context &ctx, const rpcList::request_type &req); - template <> ruek::api::v1::EntitiesEntity map(const db::Tuple &from) const noexcept; - template <> ruek::api::v1::EntitiesPrincipal map(const db::Tuple &from) const noexcept; -}; +template <> +rpcListPrincipals::result_type Impl::call( + grpcxx::context &ctx, const rpcListPrincipals::request_type &req); + +template <> rpcList::response_type Impl::map(const db::Tuples &from) const noexcept; +template <> rpcListPrincipals::response_type Impl::map(const db::Tuples &from) const noexcept; + +template <> ruek::api::v1::EntitiesEntity Impl::map(const db::Tuple &from) const noexcept; +template <> ruek::api::v1::EntitiesPrincipal Impl::map(const db::Tuple &from) const noexcept; } // namespace entities } // namespace svc diff --git a/src/svc/principals.h b/src/svc/principals.h index a443493..5edd5e1 100644 --- a/src/svc/principals.h +++ b/src/svc/principals.h @@ -18,25 +18,6 @@ class Impl { return {grpcxx::status::code_t::unimplemented, std::nullopt}; } - template <> - rpcCreate::result_type call( - grpcxx::context &ctx, const rpcCreate::request_type &req); - - template <> - rpcDelete::result_type call( - grpcxx::context &ctx, const rpcDelete::request_type &req); - - template <> - rpcList::result_type call(grpcxx::context &ctx, const rpcList::request_type &req); - - template <> - rpcRetrieve::result_type call( - grpcxx::context &ctx, const rpcRetrieve::request_type &req); - - template <> - rpcUpdate::result_type call( - grpcxx::context &ctx, const rpcUpdate::request_type &req); - google::rpc::Status exception() noexcept; private: @@ -46,5 +27,24 @@ class Impl { rpcCreate::response_type map(const db::Principal &from) const noexcept; rpcList::response_type map(const db::Principals &from) const noexcept; }; + +template <> +rpcCreate::result_type Impl::call( + grpcxx::context &ctx, const rpcCreate::request_type &req); + +template <> +rpcDelete::result_type Impl::call( + grpcxx::context &ctx, const rpcDelete::request_type &req); + +template <> +rpcList::result_type Impl::call(grpcxx::context &ctx, const rpcList::request_type &req); + +template <> +rpcRetrieve::result_type Impl::call( + grpcxx::context &ctx, const rpcRetrieve::request_type &req); + +template <> +rpcUpdate::result_type Impl::call( + grpcxx::context &ctx, const rpcUpdate::request_type &req); } // namespace principals } // namespace svc diff --git a/src/svc/relations.h b/src/svc/relations.h index ebb3db5..bf8bde0 100644 --- a/src/svc/relations.h +++ b/src/svc/relations.h @@ -21,25 +21,6 @@ class Impl { return {grpcxx::status::code_t::unimplemented, std::nullopt}; } - template <> - rpcCheck::result_type call(grpcxx::context &ctx, const rpcCheck::request_type &req); - - template <> - rpcCreate::result_type call( - grpcxx::context &ctx, const rpcCreate::request_type &req); - - template <> - rpcDelete::result_type call( - grpcxx::context &ctx, const rpcDelete::request_type &req); - - template <> - rpcListLeft::result_type call( - grpcxx::context &ctx, const rpcListLeft::request_type &req); - - template <> - rpcListRight::result_type call( - grpcxx::context &ctx, const rpcListRight::request_type &req); - google::rpc::Status exception() noexcept; private: @@ -71,5 +52,24 @@ class Impl { std::string_view spaceId, db::Tuple::Entity left, std::string_view relation, db::Tuple::Entity right, std::uint16_t limit) const; }; + +template <> +rpcCheck::result_type Impl::call(grpcxx::context &ctx, const rpcCheck::request_type &req); + +template <> +rpcCreate::result_type Impl::call( + grpcxx::context &ctx, const rpcCreate::request_type &req); + +template <> +rpcDelete::result_type Impl::call( + grpcxx::context &ctx, const rpcDelete::request_type &req); + +template <> +rpcListLeft::result_type Impl::call( + grpcxx::context &ctx, const rpcListLeft::request_type &req); + +template <> +rpcListRight::result_type Impl::call( + grpcxx::context &ctx, const rpcListRight::request_type &req); } // namespace relations } // namespace svc