From 13ba6890f8a71255c3d81478a0bf1d50c726c8c4 Mon Sep 17 00:00:00 2001 From: Pipo Sanfilippo Date: Wed, 6 Nov 2024 08:22:49 -0300 Subject: [PATCH 1/6] switch rdkafka to cmake-build and add openssl with vendored features this is required to build pathfinder (aarch64) --- Cargo.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4904e78..bfc47ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,9 @@ rand = { version = "0.8.5" } [dependencies] anyhow = "1.0.86" futures-util = "0.3.30" -rdkafka = { version = "0.36.2", features = ["ssl-vendored"] } +openssl = { version = "0.10", features = ["vendored"] } +openssl-sys = { version = "0.9", features = ["vendored"] } +rdkafka = { version = "0.36.2", features = ["cmake-build"] } tokio = { version = "1.39.2", features = ["full"] } tokio-util = { version = "0.7.11", features = ["rt"] } tokio-macros = "2.4.0" From 3a58cfc0757a0ca529b96b25eaef388351a1eb1b Mon Sep 17 00:00:00 2001 From: Pipo Sanfilippo Date: Wed, 6 Nov 2024 08:23:17 -0300 Subject: [PATCH 2/6] add CODEOWNERS file --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..64b15e4 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @jucr-io From 328fe52ed40efc0adbdac2e95d95d42d607342af Mon Sep 17 00:00:00 2001 From: Pipo Sanfilippo Date: Wed, 6 Nov 2024 08:24:41 -0300 Subject: [PATCH 3/6] add Docker workflow for building and pushing images --- .github/workflows/publish-binaries.yaml | 86 +++++++++++++++---------- Dockerfile | 19 ++++++ 2 files changed, 71 insertions(+), 34 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/publish-binaries.yaml b/.github/workflows/publish-binaries.yaml index 8c3ea2c..58976cb 100644 --- a/.github/workflows/publish-binaries.yaml +++ b/.github/workflows/publish-binaries.yaml @@ -1,13 +1,18 @@ -name: publish-binaries - +name: publish pathfinder on: release: types: [released, prereleased] -permissions: write-all +permissions: + contents: write + packages: write + id-token: write + +env: + GH_TOKEN: ${{ github.token }} jobs: - build: + publish-binaries: name: ${{ matrix.platform.target }} runs-on: ${{ matrix.platform.os }} if: ${{ !startsWith(github.ref_name, 'v') }} @@ -35,40 +40,53 @@ jobs: steps: - name: checkout - uses: actions/checkout@v4 + uses: actions/checkout@v4.2.2 - - name: init cache - uses: Swatinem/rust-cache@v2 + - name: Install dependencies for Linux + if: matrix.platform.os == 'ubuntu-latest' + run: sudo apt-get update && sudo apt-get install -y libssl-dev - - name: setup toolchain - run: rustup toolchain install stable --profile minimal + - name: publish rust binaries + uses: ./.github/actions/publish-binaries + continue-on-error: false + with: + os: ${{ matrix.platform.os }} + version: ${{ github.ref_name }} + target: ${{ matrix.platform.target }} + name: ${{ matrix.platform.name }} + bin: ${{ matrix.platform.bin }} - - name: set version - run: cargo install cargo-edit && cargo set-version $VERSION - env: - VERSION: ${{ github.ref_name }} - - name: run build - uses: houseabsolute/actions-rust-cross@v0 - with: - command: "build" - target: ${{ matrix.platform.target }} - toolchain: "stable" - args: "--locked --release" - strip: true + build-and-push-docker-image: + needs: [publish-binaries] + name: ${{ matrix.platform.target }} + runs-on: ${{ matrix.platform.os }} + strategy: + fail-fast: false + matrix: + platform: + - os_name: Linux-x86_64 + os: ubuntu-latest + target: x86_64-unknown-linux-gnu + bin: pathfinder + name: pathfinder-linux-x86_64-gnu.tar.gz + platform: linux/amd64 - - name: package - shell: bash - run: | - cd target/${{ matrix.platform.target }}/release - if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then - 7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} - else - tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} - fi - cd - + - os_name: Linux-aarch64-gnu + os: ubuntu-latest + target: aarch64-unknown-linux-gnu + bin: pathfinder + name: pathfinder-linux-aarch64-gnu.tar.gz + platform: linux/arm64 - - name: upload artifacts - uses: softprops/action-gh-release@v2 + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + with: + fetch-depth: 0 + - name: Build and push Docker image + uses: ./.github/actions/publish-docker-image with: - files: "pathfinder-*" + config-path: 'example-config.yaml' + name: ${{ matrix.platform.name }} + token: ${{ github.token }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..323e5d6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM debian:bullseye-slim AS build + +RUN apt-get update && apt-get install -y unzip curl + +ARG CONFIG=example-config.yaml +COPY $CONFIG /config.yaml +COPY pathfinder . + +RUN cp pathfinder /usr/local/bin/pathfinder + +FROM debian:bullseye-slim + +RUN apt-get update && apt-get install -y libssl-dev ca-certificates && rm -rf /var/lib/apt/lists/* + +COPY --from=build /usr/local/bin/pathfinder /usr/local/bin/pathfinder + +COPY --from=build /config.yaml /etc/pf-config.yaml + +ENTRYPOINT ["/usr/local/bin/pathfinder", "--config-path", "/etc/pf-config.yaml", "listen"] \ No newline at end of file From 04c67b439e0c6be6e3e29cefedaff91ded5cefa6 Mon Sep 17 00:00:00 2001 From: Pipo Sanfilippo Date: Wed, 6 Nov 2024 08:25:30 -0300 Subject: [PATCH 4/6] rename release workflow file --- .github/workflows/{publish-binaries.yaml => release.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{publish-binaries.yaml => release.yaml} (100%) diff --git a/.github/workflows/publish-binaries.yaml b/.github/workflows/release.yaml similarity index 100% rename from .github/workflows/publish-binaries.yaml rename to .github/workflows/release.yaml From 1ab715b33d0370efa011eae4fedeeb94a1b50dc2 Mon Sep 17 00:00:00 2001 From: Pipo Sanfilippo Date: Wed, 6 Nov 2024 08:25:42 -0300 Subject: [PATCH 5/6] add GitHub action for building and publishing Docker images --- .../actions/publish-docker-image/action.yaml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/actions/publish-docker-image/action.yaml diff --git a/.github/actions/publish-docker-image/action.yaml b/.github/actions/publish-docker-image/action.yaml new file mode 100644 index 0000000..74591dc --- /dev/null +++ b/.github/actions/publish-docker-image/action.yaml @@ -0,0 +1,60 @@ +name: docker +description: build and publish docker image +inputs: + config-path: + description: The path to the chart-testing configuration file + default: .ct/ct.yaml + name: + description: pathfinder release name + token: + description: github token + +runs: + using: composite + steps: + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ inputs.token }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3.7.1 + with: + driver-opts: | + image=moby/buildkit:v0.16.0 + + - name: download pathfinder release + id: download_pathfinder + shell: bash + run: | + gh release download -p ${{ inputs.name }} --clobber -O pathfinder.tar.gz + tar -xvf pathfinder.tar.gz + + - name: set docker tags + id: set_tags + shell: bash + run: | + repository_name=${${{ github.repository }}#${{ github.repository_owner }}} + image_name="ghcr.io/${{ github.repository }}" + echo "image_name=$image_name" >> $GITHUB_OUTPUT + echo "repository_name=$repository_name" >> $GITHUB_OUTPUT + + - name: Build and Push Docker Image + uses: docker/build-push-action@v6 + id: docker_build + with: + context: . + github-token: ${{ inputs.token }} + push: true + tags: | + ${{steps.set_tags.outputs.image_name}}:${{ github.sha }} + ${{steps.set_tags.outputs.image_name}}:${{ github.ref_name }} + ${{steps.set_tags.outputs.image_name}}:latest + labels: | + org.opencontainers.image.title=${{ steps.set_tags.outputs.repository_name }} + org.opencontainers.image.source=https://github.com/${{ github.repository }} + platforms: linux/arm64,linux/amd64 + build-args: | + ARG CONFIG=${{ inputs.config-path }} From 84e053a227357224c9348f5da2c6119431a5c4d1 Mon Sep 17 00:00:00 2001 From: Pipo Sanfilippo Date: Wed, 6 Nov 2024 08:25:53 -0300 Subject: [PATCH 6/6] add GitHub action for publishing Rust binaries --- .github/actions/publish-binaries/action.yaml | 49 ++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/actions/publish-binaries/action.yaml diff --git a/.github/actions/publish-binaries/action.yaml b/.github/actions/publish-binaries/action.yaml new file mode 100644 index 0000000..92f319a --- /dev/null +++ b/.github/actions/publish-binaries/action.yaml @@ -0,0 +1,49 @@ +name: publish-binaries +description: publish rust binaries +inputs: + os: + description: github action OS + target: + description: rust target + version: + description: release tag + name: + description: release name + bin: + description: rust bin name + + +runs: + using: composite + steps: + - name: setup toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + target: ${{ inputs.target }} + + - name: set version + shell: bash + run: cargo install cargo-edit && cargo set-version $VERSION + env: + VERSION: ${{ github.ref_name }} + + - name: run build + uses: houseabsolute/actions-rust-cross@v0 + with: + command: "build" + target: ${{ inputs.target }} + toolchain: "stable" + args: "--locked --release" + strip: true + + - name: package + shell: bash + run: | + cd target/${{ inputs.target }}/release + tar czvf ../../../${{ inputs.name }} ${{ inputs.bin }} + cd - + + - name: upload artifacts + uses: softprops/action-gh-release@v2 + with: + files: "pathfinder-*"