diff --git a/.github/docker/build_package.sh b/.github/docker/build_package.sh index ae58b81f..3ece781a 100644 --- a/.github/docker/build_package.sh +++ b/.github/docker/build_package.sh @@ -4,6 +4,10 @@ function build_packages(){ echo "ENV_DISTRO is not set" return fi + if [ "$VERSION" = "" ]; then + echo "VERSION is not set" + return + fi cd "$GIT_DIR" git submodule update --init --recursive make EVENT_LIB=libuv @@ -11,11 +15,11 @@ function build_packages(){ echo "building package for $BUILD_DISTRO" if [[ $ENV_DISTRO == *"ubuntu"* ]]; then - make deb + make deb VERSION=$VERSION elif [[ $ENV_DISTRO == *"debian"* ]]; then - make deb + make deb VERSION=$VERSION elif [[ $ENV_DISTRO == *"ubi"* ]]; then - make rpm + make rpm VERSION=$VERSION else make tar fi diff --git a/.github/docker/entrypoint.sh b/.github/docker/entrypoint.sh index 11bf2291..75ea2467 100755 --- a/.github/docker/entrypoint.sh +++ b/.github/docker/entrypoint.sh @@ -23,7 +23,7 @@ function build_container() { function execute_build_image() { export BUILD_DISTRO="$1" - docker run -e BUILD_DISTRO -v $(realpath ../dist):/tmp/output asbackup-pkg-builder-"$BUILD_DISTRO"-"$(git rev-parse HEAD | cut -c -8)" + docker run -e BUILD_DISTRO -e VERSION -v $(realpath ../dist):/tmp/output asbackup-pkg-builder-"$BUILD_DISTRO"-"$(git rev-parse HEAD | cut -c -8)" ls -laht ../dist } @@ -33,7 +33,7 @@ BUILD_CONTAINERS=false EXECUTE_BUILD=false BUILD_DISTRO=${BUILD_DISTRO:-"all"} -while getopts "ibced:" opt; do +while getopts "ibced:v:" opt; do case ${opt} in i ) INSTALL=true @@ -48,8 +48,15 @@ while getopts "ibced:" opt; do EXECUTE_BUILD=true ;; d ) - BUILD_DISTRO="$OPTARG" + BUILD_DISTRO=$OPTARG ;; + v ) + export VERSION=$OPTARG + ;; + * ) + echo "Unknown option: $opt" >&2 + exit 1 + ;; esac done @@ -62,6 +69,7 @@ then -b ( build internal ) -c ( build containers ) -e ( execute docker package build ) + -v ( version ) -d [ redhat | ubuntu | debian ]""" 1>&2 exit 1 fi diff --git a/.github/workflows/build-artifacts.yml b/.github/workflows/build-artifacts.yml index ff69fb44..1052d74b 100644 --- a/.github/workflows/build-artifacts.yml +++ b/.github/workflows/build-artifacts.yml @@ -1,64 +1,120 @@ name: build-artifacts.yml + +permissions: + id-token: write + contents: read on: workflow_dispatch: push: - branches: [ main, SERVER-216, SERVER-216-debug-jfrog ] - + branches: [main, SERVER-216, SERVER-216-debug-jfrog] + pull_request: + branches: [main, SERVER-216, SERVER-216-debug-jfrog] jobs: + extract-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + with: + fetch-tags: true + fetch-depth: 0 + - name: Extract Version + id: extract + uses: aerospike/shared-workflows/.github/actions/extract-version-from-tag@main + outputs: + version: ${{ steps.extract.outputs.version }} + git_tag: ${{ steps.extract.outputs.git_tag }} + source: ${{ steps.extract.outputs.source }} build-artifacts: + needs: extract-version strategy: matrix: - distro: [ debian11, debian12, debian13, ubuntu20.04, ubuntu22.04, ubuntu24.04, redhat-el8, redhat-el9, amazon-2023 ] #redhat-el10 disable redhat 10 until c client patches ssl for redhat 10 - host: [ ubuntu-24.04-arm, ubuntu-24.04 ] - uses: aerospike/shared-workflows/.github/workflows/reusable_execute-build.yaml@0da06cb2182165b125dc219ca2fda09732ca0fa4 + distro: + [ + debian11, + debian12, + debian13, + ubuntu20.04, + ubuntu22.04, + ubuntu24.04 + # build script does not work with rpm based distros + # redhat-el8, + # redhat-el9, + # amazon-2023, + ] + host: [ubuntu-24.04-arm, ubuntu-24.04] + uses: aerospike/shared-workflows/.github/workflows/reusable_execute-build.yaml@main with: runs-on: ${{ matrix.host }} project: database build-name: asbench - build-id: ${{ github.run_number }} - build-script: set -x && chmod o+rw dist && cd local && git checkout ${{ github.ref_name }} && git submodule update --init --recursive && .github/docker/entrypoint.sh -c -d ${{ matrix.distro }} && .github/docker/entrypoint.sh -e -d ${{ matrix.distro }} && find ../dist + build-id: ${{ github.run_number }}-buildinfo-${{ matrix.distro }}-${{ matrix.host }} + build-script: | + set -x + chmod o+rw dist + cd local + .github/docker/entrypoint.sh -c -d ${{ matrix.distro }} + .github/docker/entrypoint.sh -e -d ${{ matrix.distro }} -v ${{ needs.extract-version.outputs.version }} + find ../dist artifact-directory: dist artifact-name: unsigned-artifacts-${{ matrix.distro }}-${{ matrix.host }} - retention-days: 7 + retention-days: 1 dry-run: false - artifactory-url: https://aerospike.jfrog.io # default - artifactory-oidc-provider-name: database-gh-aerospike # default - artifactory-oidc-audience: database-gh-aerospike # default + artifactory-oidc-provider-name: database-gh-aerospike + artifactory-oidc-audience: database-gh-aerospike + publish-build-info: true + aggregate-artifacts: + needs: [build-artifacts] + runs-on: ubuntu-latest + steps: + - name: Download All Matrix Artifacts + uses: actions/download-artifact@v4 + with: + path: build-artifacts + merge-multiple: true + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: build-artifacts + path: build-artifacts + overwrite: true + retention-days: 1 sign-artifacts: - strategy: - matrix: - distro: [ debian11, debian12, debian13, ubuntu20.04, ubuntu22.04, ubuntu24.04, redhat-el8, redhat-el9, amazon-2023 ] #redhat-el10 disable redhat 10 until c client patches ssl for redhat 10 - host: [ ubuntu-24.04-arm, ubuntu-24.04 ] - needs: build-artifacts - uses: aerospike/shared-workflows/.github/workflows/reusable_sign-artifacts.yaml@0da06cb2182165b125dc219ca2fda09732ca0fa4 # vn.n.n + needs: aggregate-artifacts + uses: aerospike/shared-workflows/.github/workflows/reusable_sign-artifacts.yaml@main # vn.n.n with: - artifact-name: signed-artifacts-${{ matrix.distro }}-${{ matrix.host }} - unsigned-artifacts: unsigned-artifacts-${{ matrix.distro }}-${{ matrix.host }} - # artifact-name: signed-artifacts # optional, defaults to signed-artifacts - # retention-days: 7 # optional, defaults to 7 - # dry-run: false # optional, for future compatibility + artifact-name: signed-artifacts + unsigned-artifacts: build-artifacts + artifactory-oidc-provider-name: database-gh-aerospike + artifactory-oidc-audience: database-gh-aerospike secrets: gpg-private-key: ${{ secrets.GPG_SECRET_KEY }} gpg-public-key: ${{ secrets.GPG_PUBLIC_KEY }} gpg-key-pass: ${{ secrets.GPG_PASS }} upload-artifacts: - strategy: - matrix: - distro: [ debian11, debian12, debian13, ubuntu20.04, ubuntu22.04, ubuntu24.04, redhat-el8, redhat-el9, amazon-2023 ] #redhat-el10 disable redhat 10 until c client patches ssl for redhat 10 - host: [ ubuntu-24.04-arm, ubuntu-24.04 ] - needs: sign-artifacts - uses: aerospike/shared-workflows/.github/workflows/reusable_deploy-artifacts.yaml@0da06cb2182165b125dc219ca2fda09732ca0fa4 # vn.n.n + needs: [sign-artifacts, extract-version] + uses: aerospike/shared-workflows/.github/workflows/reusable_deploy-artifacts.yaml@main # vn.n.n with: project: database build-name: asbench - version: ${{ github.ref_name }} + build-id: ${{ github.run_number }} + metadata-build-id: ${{ github.run_number }}-buildinfo + version: ${{ needs.extract-version.outputs.version }} artifactory-url: https://aerospike.jfrog.io artifactory-oidc-provider-name: database-gh-aerospike artifactory-oidc-audience: database-gh-aerospike - artifact-name: signed-artifacts-${{ matrix.distro }}-${{ matrix.host }} + artifact-name: ${{ needs.sign-artifacts.outputs.artifact-name }} retention-days: 1 dry-run: false - build-id: ${{ github.run_number }} - metadata-build-id: ${{ github.run_number }}-metadata - + create-release-bundle: + needs: [upload-artifacts, extract-version] + uses: aerospike/shared-workflows/.github/workflows/reusable_create-release-bundle.yaml@main + if: needs.extract-version.outputs.source == 'tag' && startsWith(github.ref, 'refs/tags/v') && github.event_name == 'push' + with: + project: database + build-names: asbench:${{ github.run_number }} + bundle-name: asbench + version: ${{ needs.extract-version.outputs.version }} + artifactory-oidc-provider-name: database-gh-aerospike + artifactory-oidc-audience: database-gh-aerospike + dry-run: false diff --git a/.gitignore b/.gitignore index a26ce860..ec06a283 100644 --- a/.gitignore +++ b/.gitignore @@ -80,3 +80,4 @@ x64 ipch packages packages/repositories.config +.cursorrules diff --git a/.trunk/.gitignore b/.trunk/.gitignore new file mode 100644 index 00000000..15966d08 --- /dev/null +++ b/.trunk/.gitignore @@ -0,0 +1,9 @@ +*out +*logs +*actions +*notifications +*tools +plugins +user_trunk.yaml +user.yaml +tmp diff --git a/.trunk/configs/.isort.cfg b/.trunk/configs/.isort.cfg new file mode 100644 index 00000000..b9fb3f3e --- /dev/null +++ b/.trunk/configs/.isort.cfg @@ -0,0 +1,2 @@ +[settings] +profile=black diff --git a/.trunk/configs/.markdownlint.yaml b/.trunk/configs/.markdownlint.yaml new file mode 100644 index 00000000..b40ee9d7 --- /dev/null +++ b/.trunk/configs/.markdownlint.yaml @@ -0,0 +1,2 @@ +# Prettier friendly markdownlint config (all formatting rules disabled) +extends: markdownlint/style/prettier diff --git a/.trunk/configs/.shellcheckrc b/.trunk/configs/.shellcheckrc new file mode 100644 index 00000000..8c7b1ada --- /dev/null +++ b/.trunk/configs/.shellcheckrc @@ -0,0 +1,7 @@ +enable=all +source-path=SCRIPTDIR +disable=SC2154 + +# If you're having issues with shellcheck following source, disable the errors via: +# disable=SC1090 +# disable=SC1091 diff --git a/.trunk/configs/.yamllint.yaml b/.trunk/configs/.yamllint.yaml new file mode 100644 index 00000000..184e251f --- /dev/null +++ b/.trunk/configs/.yamllint.yaml @@ -0,0 +1,7 @@ +rules: + quoted-strings: + required: only-when-needed + extra-allowed: ["{|}"] + key-duplicates: {} + octal-values: + forbid-implicit-octal: true diff --git a/.trunk/configs/ruff.toml b/.trunk/configs/ruff.toml new file mode 100644 index 00000000..f5a235cf --- /dev/null +++ b/.trunk/configs/ruff.toml @@ -0,0 +1,5 @@ +# Generic, formatter-friendly config. +select = ["B", "D3", "E", "F"] + +# Never enforce `E501` (line length violations). This should be handled by formatters. +ignore = ["E501"] diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml new file mode 100644 index 00000000..7bd45f37 --- /dev/null +++ b/.trunk/trunk.yaml @@ -0,0 +1,41 @@ +# This file controls the behavior of Trunk: https://docs.trunk.io/cli +# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml +version: 0.1 +cli: + version: 1.25.0 +# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins) +plugins: + sources: + - id: trunk + ref: v1.7.2 + uri: https://github.com/trunk-io/plugins +# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes) +runtimes: + enabled: + - go@1.21.0 + - node@22.16.0 + - python@3.10.8 +# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration) +lint: + enabled: + - actionlint@1.7.7 + - bandit@1.8.6 + - black@25.9.0 + - checkov@3.2.473 + - git-diff-check + - isort@6.0.1 + - markdownlint@0.45.0 + - osv-scanner@2.2.2 + - prettier@3.6.2 + - ruff@0.13.2 + - shellcheck@0.11.0 + - shfmt@3.6.0 + - trufflehog@3.90.8 + - yamllint@1.37.1 +actions: + disabled: + - trunk-announce + - trunk-check-pre-push + - trunk-fmt-pre-commit + enabled: + - trunk-upgrade-available diff --git a/pkg/Makefile b/pkg/Makefile index 1f44b5a9..6ad510f2 100644 --- a/pkg/Makefile +++ b/pkg/Makefile @@ -8,7 +8,8 @@ CONFIG_DIR = /etc/aerospike # Package variables NAME = "asbench" -VERSION = $(shell git describe --tags --always | cut -d '-' -f 1-2) +# Running inside container might not have tag history. Enable setting outside. +VERSION ?= $(shell git describe --tags --always | cut -d '-' -f 1-2) MAINTAINER = "Aerospike" DESCRIPTION = "Aerospike Benchmark, a tool for performance testing Aerospike database." LICENSE = "Apache License 2.0"