Skip to content

Commit

Permalink
Enable rke2 binary with go coverage option
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Nola <[email protected]>
  • Loading branch information
dereknola committed Apr 4, 2024
1 parent 623c379 commit d24e4f6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: sudo apt-get install -y libarchive-tools
- name: Build RKE2 Binary and Runtime Image
run: |
make build-binary
GOCOVER=true make build-binary
make package-image-runtime
cp ./bin/rke2 ./build/images/rke2-binary
# Can only upload from a single path, so we need to copy the binary to the image directory
Expand All @@ -67,6 +67,8 @@ jobs:
matrix:
itest: [etcdsnapshot]
max-parallel: 3
env:
GOCOVERDIR: /tmp/rke2cov
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -97,4 +99,14 @@ jobs:
- name: Run Integration Tests
run: |
chmod +x ./bin/rke2
mkdir -p $GOCOVERDIR
sudo -E env "PATH=$PATH" go test -v -timeout=45m ./tests/integration/${{ matrix.itest }}/... -run Integration
- name: Generate coverage report
run: go tool covdata textfmt -i $GOCOVERDIR -o ${{ matrix.itest }}.out
- name: Upload Results To Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./${{ matrix.itest }}.out
flags: inttests # optional
verbose: true # optional (default = false)
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN zypper install -y systemd-rpm-macros

# Dapper/Drone/CI environment
FROM build AS dapper
ENV DAPPER_ENV GODEBUG REPO TAG DRONE_TAG PAT_USERNAME PAT_TOKEN KUBERNETES_VERSION DOCKER_BUILDKIT DRONE_BUILD_EVENT IMAGE_NAME AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID ENABLE_REGISTRY
ENV DAPPER_ENV GODEBUG GOCOVER REPO TAG DRONE_TAG PAT_USERNAME PAT_TOKEN KUBERNETES_VERSION DOCKER_BUILDKIT DRONE_BUILD_EVENT IMAGE_NAME AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID ENABLE_REGISTRY
ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH
ENV DAPPER_OUTPUT ./dist ./bin ./build
Expand Down
5 changes: 5 additions & 0 deletions scripts/build-binary
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ else
DEBUG_GO_GCFLAGS='-gcflags=all=-N -l'
fi

if [ -n "${GOCOVER}" ]; then
GO_BUILDTAGS="${GO_BUILDTAGS} cover"
GO_BUILD_FLAGS="${GO_BUILD_FLAGS} -cover"
fi

REVISION=$(git rev-parse HEAD)$(if ! git diff --no-ext-diff --quiet --exit-code; then echo .dirty; fi)
RELEASE=${PROG}.${GOOS}-${GOARCH}

Expand Down

0 comments on commit d24e4f6

Please sign in to comment.