From f2a4955431847f916f1daed131cf1edd3178b700 Mon Sep 17 00:00:00 2001 From: "Everton H. Taques" <97463920+etaques@users.noreply.github.com> Date: Tue, 11 Apr 2023 11:22:51 -0300 Subject: [PATCH 1/9] remove useless files --- docker/Dockerfile.pktvisor-cli | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 docker/Dockerfile.pktvisor-cli diff --git a/docker/Dockerfile.pktvisor-cli b/docker/Dockerfile.pktvisor-cli deleted file mode 100644 index d612ada13..000000000 --- a/docker/Dockerfile.pktvisor-cli +++ /dev/null @@ -1,32 +0,0 @@ -FROM debian:bullseye-slim AS cppbuild - -ENV BUILD_DEPS "g++ cmake make git pkgconf jq python3-pip python3-setuptools ca-certificates" - -RUN \ - apt-get update && \ - apt-get upgrade --yes --force-yes && \ - apt-get install --yes --force-yes --no-install-recommends ${BUILD_DEPS} && \ - pip3 install conan - -# need git for current hash for VERSION -COPY ./.git/ /pktvisor-src/.git/ -COPY ./golang/ /pktvisor-src/golang/ -COPY ./CMakeLists.txt /pktvisor-src/ - -WORKDIR /tmp/build - -# ONLY run cmake configure to get version need for go build (no c++ build) -RUN VERSION_ONLY=1 cmake /pktvisor-src - -FROM golang:latest AS gobuild -COPY golang/ /src/ -WORKDIR /src/ -COPY --from=cppbuild /pktvisor-src/golang/pkg/client/version.go /src/pkg/client/version.go -RUN CGO_ENABLED=0 go build -o pktvisor-cli cmd/pktvisor-cli/main.go - -FROM alpine:latest AS runtime - -COPY --from=gobuild /src/pktvisor-cli /pktvisor-cli -COPY docker/entry-cli.sh / - -ENTRYPOINT [ "/entry-cli.sh" ] From 9723b9edf8c76de95790939f80bfc94c612b109c Mon Sep 17 00:00:00 2001 From: "Everton H. Taques" <97463920+etaques@users.noreply.github.com> Date: Tue, 11 Apr 2023 11:23:39 -0300 Subject: [PATCH 2/9] remove useless files --- docker/entry-cli.sh | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100755 docker/entry-cli.sh diff --git a/docker/entry-cli.sh b/docker/entry-cli.sh deleted file mode 100755 index 14b6cd666..000000000 --- a/docker/entry-cli.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# this is the entry point to the docker container, and is only used there -set -e -export PATH=$PATH:/usr/local/bin/:/usr/local/sbin/ - -# Add sleep to allow tty to be ready for Docker when using -it -echo "starting pktvisor-cli..." -sleep 1 - -exec /pktvisor-cli From a49da42f1836b952061b4786532767cce046b301 Mon Sep 17 00:00:00 2001 From: "Everton H. Taques" <97463920+etaques@users.noreply.github.com> Date: Tue, 11 Apr 2023 12:41:56 -0300 Subject: [PATCH 3/9] add architecture --- .github/actions/build-go/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build-go/entrypoint.sh b/.github/actions/build-go/entrypoint.sh index f40cc59d1..3039b2131 100644 --- a/.github/actions/build-go/entrypoint.sh +++ b/.github/actions/build-go/entrypoint.sh @@ -6,7 +6,7 @@ function build() { # Copying this from previous build (cpp) cp -rf ./version.go /src/pkg/client/version.go cd /src - GOOS=$INPUT_GOOS go build -o pktvisor-cli cmd/pktvisor-cli/main.go + GOOS=$INPUT_GOOS GOARCH=$INPUT_GOARCH go build -o pktvisor-cli cmd/pktvisor-cli/main.go } function copy() { From aadc2a3b7cac358fa7cbb950800894d471db4e96 Mon Sep 17 00:00:00 2001 From: "Everton H. Taques" <97463920+etaques@users.noreply.github.com> Date: Tue, 11 Apr 2023 12:45:03 -0300 Subject: [PATCH 4/9] test --- .github/workflows/build_cross.yml | 39 ++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build_cross.yml b/.github/workflows/build_cross.yml index 6fa2c8a0b..b715b63cd 100644 --- a/.github/workflows/build_cross.yml +++ b/.github/workflows/build_cross.yml @@ -185,21 +185,32 @@ jobs: - name: Configure run: | VERSION_ONLY=1 cmake src - - - name: Build - run: | - if [ "${{matrix.os}}" = macos ]; then - export GOOS=darwin - fi - if [ "${{matrix.arch}}" = armv7lh ]; then - export GOARCH=arm - elif [ "${{matrix.arch}}" = aarch64 ]; then - export GOARCH=arm64 - fi - - cd src/golang - go build -o ${{github.workspace}}/pktvisor-cli ./cmd/pktvisor-cli + - name: Build pktvisor-cli macos + if: ${{matrix.os}} == macos + uses: ./.github/actions/build-go + with: + context: "." + file: "./Dockerfile" + goos: "darwin" + + - name: Build pktvisor-cli linux armv7lh + if: ${{matrix.arch}} == armv7lh + uses: ./.github/actions/build-go + with: + context: "." + file: "./Dockerfile" + goos: "linux" + goarch: "arm" + + - name: Build pktvisor-cli linux aarch64 + if: ${{matrix.arch}} == aarch64 + uses: ./.github/actions/build-go + with: + context: "." + file: "./Dockerfile" + goos: "linux" + goarch: "arm64" - name: Upload pktvisor-cli uses: actions/upload-artifact@v2 From 52c3dbd864bf6f1c3f7e4fe0504151d7631863bf Mon Sep 17 00:00:00 2001 From: "Everton H. Taques" <97463920+etaques@users.noreply.github.com> Date: Tue, 11 Apr 2023 12:47:05 -0300 Subject: [PATCH 5/9] Update action.yml --- .github/actions/build-go/action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/actions/build-go/action.yml b/.github/actions/build-go/action.yml index d952eee56..bd55a35c0 100644 --- a/.github/actions/build-go/action.yml +++ b/.github/actions/build-go/action.yml @@ -17,6 +17,11 @@ inputs: description: "OS for cross-build" required: false default: "linux" + + goarch: + description: "ARCH for cross-build" + required: false + default: "amd64" runs: using: 'docker' From 5cbc16d89ae10b50931ed6428a651885a6b42b94 Mon Sep 17 00:00:00 2001 From: "Everton H. Taques" <97463920+etaques@users.noreply.github.com> Date: Tue, 11 Apr 2023 12:49:49 -0300 Subject: [PATCH 6/9] test --- .github/workflows/build_cross.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_cross.yml b/.github/workflows/build_cross.yml index b715b63cd..88a8d3699 100644 --- a/.github/workflows/build_cross.yml +++ b/.github/workflows/build_cross.yml @@ -177,14 +177,13 @@ jobs: uses: actions/setup-go@v2 with: go-version: 1.17 + - name: Checkout sources uses: actions/checkout@v3 - with: - path: src - name: Configure run: | - VERSION_ONLY=1 cmake src + VERSION_ONLY=1 cmake . - name: Build pktvisor-cli macos if: ${{matrix.os}} == macos From 255fc81b64ddb11cd17d09ec43599bde478ad5b1 Mon Sep 17 00:00:00 2001 From: "Everton H. Taques" <97463920+etaques@users.noreply.github.com> Date: Tue, 11 Apr 2023 12:56:23 -0300 Subject: [PATCH 7/9] test --- .github/workflows/build_cross.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_cross.yml b/.github/workflows/build_cross.yml index 88a8d3699..f6f4a0837 100644 --- a/.github/workflows/build_cross.yml +++ b/.github/workflows/build_cross.yml @@ -173,17 +173,13 @@ jobs: - os: macos arch: armv7lh steps: - - name: Setup Go - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - name: Checkout sources uses: actions/checkout@v3 - - name: Configure - run: | - VERSION_ONLY=1 cmake . + - name: Configure CMake to generate VERSION + shell: bash + working-directory: ${{github.workspace}}/build + run: VERSION_ONLY=1 cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release - name: Build pktvisor-cli macos if: ${{matrix.os}} == macos From 49c556dfe93a17bca1346362c49fcca626b31f08 Mon Sep 17 00:00:00 2001 From: "Everton H. Taques" <97463920+etaques@users.noreply.github.com> Date: Tue, 11 Apr 2023 13:00:04 -0300 Subject: [PATCH 8/9] test --- .github/workflows/build_cross.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_cross.yml b/.github/workflows/build_cross.yml index f6f4a0837..d7e19af0f 100644 --- a/.github/workflows/build_cross.yml +++ b/.github/workflows/build_cross.yml @@ -178,8 +178,14 @@ jobs: - name: Configure CMake to generate VERSION shell: bash - working-directory: ${{github.workspace}}/build run: VERSION_ONLY=1 cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release + + - name: Debug artifacts + shell: bash + run: | + ls -lha + mv src pktvisor-src + cp -rpf golang/pkg/client/version.go . - name: Build pktvisor-cli macos if: ${{matrix.os}} == macos From 17bfad5ec03ae65c4fb60e3fa466dfc6767d7da8 Mon Sep 17 00:00:00 2001 From: "Everton H. Taques" <97463920+etaques@users.noreply.github.com> Date: Tue, 11 Apr 2023 13:06:22 -0300 Subject: [PATCH 9/9] fix --- .github/workflows/build_cross.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_cross.yml b/.github/workflows/build_cross.yml index d7e19af0f..195a2454f 100644 --- a/.github/workflows/build_cross.yml +++ b/.github/workflows/build_cross.yml @@ -11,7 +11,6 @@ on: branches: - develop - jobs: pkvisor: name: pktvisor @@ -178,12 +177,11 @@ jobs: - name: Configure CMake to generate VERSION shell: bash - run: VERSION_ONLY=1 cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release + run: VERSION_ONLY=1 cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Release - - name: Debug artifacts + - name: Rename folder and copy version shell: bash run: | - ls -lha mv src pktvisor-src cp -rpf golang/pkg/client/version.go .