diff --git a/.github/workflows/builder.yml b/.github/workflows/builder.yml new file mode 100644 index 0000000..2465e6e --- /dev/null +++ b/.github/workflows/builder.yml @@ -0,0 +1,70 @@ +name: builder + +on: + push: + branches: + - "main" + pull_request: + +env: + OCI_E2E_NAME: libhvee-e2e + CORRELATE: ${{ github.sha }} + +jobs: + save-gh-context: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Correlate builds + shell: bash + env: + GH_CONTEXT: ${{ toJSON(github) }} + run: echo $GH_CONTEXT > gh_context.json + + - name: Upload GH context as an artifact + uses: actions/upload-artifact@v4 + with: + name: gh_context + path: ./gh_context.json + + build-oci-e2e: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Build and archive e2e image + run: | + VERSION=${{ env.CORRELATE}} make build-oci-e2e + podman save -o ${{ env.OCI_E2E_NAME }}.tar quay.io/rhqp/${{ env.OCI_E2E_NAME}}:v${{ env.CORRELATE }} + + - name: Upload e2e flat image as artifact + uses: actions/upload-artifact@v4 + with: + name: libhvee-e2e-v${{ env.CORRELATE }} + path: libhvee-e2e.tar + + build-executables: + runs-on: windows-2022 + strategy: + fail-fast: false + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.18' + + - name: Build libhvee executables + run: make build + + - name: Upload libhvee executables as artifact + uses: actions/upload-artifact@v4 + with: + name: libhvee-v${{ env.CORRELATE }} + path: bin/*.exe \ No newline at end of file diff --git a/Makefile b/Makefile index 4c45600..0189b55 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ export GOOS=windows export GOARCH=amd64 SRC = $(shell find . -type f -name '*.go') +VERSION ?= 0.0.1 +IMG ?= quay.io/rhqp/libhvee-e2e:v${VERSION} +CONTAINER_MANAGER ?= podman .PHONY: default default: build @@ -37,3 +40,7 @@ bin/updatevm.exe: $(SRC) go.mod go.sum clean: rm -rf bin + +.PHONY: build-oci-e2e +build-oci-e2e: + ${CONTAINER_MANAGER} build -t ${IMG} -f oci/e2e/Containerfile --build-arg=OS=${GOOS} --build-arg=ARCH=${GOARCH} . diff --git a/docs/e2e.md b/docs/e2e.md new file mode 100644 index 0000000..4ded85e --- /dev/null +++ b/docs/e2e.md @@ -0,0 +1,29 @@ +# e2e + +TBC + +## Container + +Build container image + +```bash +make build-oci-e2e +``` + +Sample for running the container with e2e on remote target + +```bash +podman run --rm -it --name libhvee-e2e \ + -e TARGET_HOST=$(cat host) \ + -e TARGET_HOST_USERNAME=$(cat username) \ + -e TARGET_HOST_KEY_PATH=/data/id_rsa \ + -e TARGET_FOLDER=libhvee-e2e \ + -e TARGET_RESULTS=libhvee-e2e.xml \ + -e OUTPUT_FOLDER=/data \ + -e DEBUG=true \ + -v $PWD:/data:z \ + quay.io/rhqp/libhvee-e2e:v0.0.1 \ + libhvee-e2e/run.ps1 \ + -targetFolder libhvee-e2e \ + -junitResultsFilename libhvee-e2e.xml +``` \ No newline at end of file diff --git a/oci/e2e/Containerfile b/oci/e2e/Containerfile new file mode 100644 index 0000000..fcc5e04 --- /dev/null +++ b/oci/e2e/Containerfile @@ -0,0 +1,23 @@ + +FROM registry.access.redhat.com/ubi9/go-toolset:1.18 as builder + +COPY . . + +ARG OS +ARG ARCH + +RUN GOOS=${OS} GOARCH=${ARCH} go test -v test/e2e/*.go -c -o ./build/libhvee-e2e.exe + +FROM quay.io/rhqp/deliverest:v0.0.3 + +ARG OS +ARG ARCH + +ENV ASSETS_FOLDER=/opt/libhvee-e2e \ + OS=${OS} \ + ARCH=${ARCH} + +# LABEL org.opencontainpoders.image.authors="Adrian Riobo" + +COPY --from=builder /opt/app-root/src/build/libhvee-e2e.exe ${ASSETS_FOLDER}/ +COPY oci/e2e/run.ps1 ${ASSETS_FOLDER}/ diff --git a/oci/e2e/run.ps1 b/oci/e2e/run.ps1 new file mode 100755 index 0000000..732979f --- /dev/null +++ b/oci/e2e/run.ps1 @@ -0,0 +1,10 @@ +param( + [Parameter(Mandatory,HelpMessage='folder on target host where assets are copied')] + $targetFolder, + [Parameter(Mandatory,HelpMessage='junit results filename')] + $junitResultsFilename +) + +# Run e2e +$env:PATH="$env:PATH;$env:HOME\$targetFolder;" +libhvee-e2e.exe --ginkgo.vv --ginkgo.junit-report="$targetFolder/$junitResultsFilename"