diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff25db7f..3d51dbb1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -128,113 +128,16 @@ jobs: pip install ruff make format-check - vars: - runs-on: ubuntu-24.04 - outputs: - tag: ${{ steps.vars.outputs.tag }} - stackrox-io-image: ${{ steps.vars.outputs.stackrox-io-image }} - rhacs-eng-image: ${{ steps.vars.outputs.rhacs-eng-image }} - steps: - - uses: actions/checkout@v4 - with: - submodules: true - fetch-depth: 0 - - - id: vars - run: | - cat << EOF >> "$GITHUB_OUTPUT" - tag=$(make tag) - stackrox-io-image=$(make image-name) - rhacs-eng-image=$(FACT_REGISTRY="quay.io/rhacs-eng/fact" make image-name) - EOF - - container: - needs: - - vars - strategy: - fail-fast: false - matrix: - arch: - - amd64 - - arm64 - runs-on: ${{ (matrix.arch == 'arm64' && 'ubuntu-24.04-arm') || 'ubuntu-24.04' }} - env: - FACT_TAG: ${{ needs.vars.outputs.tag }}-${{ matrix.arch }} - FACT_VERSION: ${{ needs.vars.outputs.tag }} - STACKROX_IO_IMAGE: ${{ needs.vars.outputs.stackrox-io-image }}-${{ matrix.arch }} - RHACS_ENG_IMAGE: ${{ needs.vars.outputs.rhacs-eng-image }}-${{ matrix.arch }} - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - - name: Build image - run: DOCKER=podman make image - - - name: Login to quay.io/stackrox-io - uses: docker/login-action@v3 - with: - registry: quay.io - username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }} - password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }} - - - run: podman push "${STACKROX_IO_IMAGE}" - - - name: Login to quay.io/rhacs-eng - uses: docker/login-action@v3 - with: - registry: quay.io - username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }} - password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }} - - - name: Tag and push to rhacs-eng - run: | - podman tag "${STACKROX_IO_IMAGE}" "${RHACS_ENG_IMAGE}" - podman push "${RHACS_ENG_IMAGE}" - - manifest-stackrox-io: - runs-on: ubuntu-24.04 - needs: - - container - - vars - env: - ARCHS: amd64 arm64 - steps: - - uses: redhat-actions/podman-login@v1 - with: - registry: quay.io - username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }} - password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }} - - - name: Create multiarch manifest - run: | - podman manifest create ${{ needs.vars.outputs.stackrox-io-image }} \ - ${{ needs.vars.outputs.stackrox-io-image }}-amd64 \ - ${{ needs.vars.outputs.stackrox-io-image }}-arm64 - podman manifest inspect ${{ needs.vars.outputs.stackrox-io-image }} - podman manifest push ${{ needs.vars.outputs.stackrox-io-image }} - - manifest-rhacs-eng: - runs-on: ubuntu-24.04 - needs: - - container - - vars - env: - ARCHS: amd64 arm64 - steps: - - uses: redhat-actions/podman-login@v1 - with: - registry: quay.io - username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }} - password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }} + container-build: + uses: ./.github/workflows/container-build.yml + secrets: inherit - - name: Create multiarch manifest - run: | - podman manifest create ${{ needs.vars.outputs.rhacs-eng-image }} \ - ${{ needs.vars.outputs.rhacs-eng-image }}-amd64 \ - ${{ needs.vars.outputs.rhacs-eng-image }}-arm64 - podman manifest inspect ${{ needs.vars.outputs.rhacs-eng-image }} - podman manifest push ${{ needs.vars.outputs.rhacs-eng-image }} + container-build-otel: + uses: ./.github/workflows/container-build.yml + secrets: inherit + with: + tag-suffix: '-otel' + make-target: 'image-otel' unit-tests: uses: ./.github/workflows/unit-tests.yml @@ -242,22 +145,30 @@ jobs: integration-tests: needs: - - vars - - manifest-stackrox-io - - manifest-rhacs-eng + - container-build uses: ./.github/workflows/integration-tests.yml with: - tag: ${{ needs.vars.outputs.tag }} + tag: ${{ needs.container-build.outputs.tag }} + vms: '["fedora-coreos", "fcarm", "rhel", "rhel-arm64", "rhcos", "rhcos-arm64"]' + secrets: inherit + + integration-tests-otel: + needs: + - container-build-otel + uses: ./.github/workflows/integration-tests.yml + with: + tag: ${{ needs.container-build-otel.outputs.tag }} + job-tag: otel + vms: '["fedora-coreos"]' + output-type: otlp secrets: inherit performance-tests: if: github.event_name == 'schedule' needs: - - vars - - manifest-stackrox-io - - manifest-rhacs-eng - - integration-tests - uses: ./.github/workflows/performance-tests.yml + - container-build + uses: ./.github/workflows/integration-tests.yml with: - tag: ${{ needs.vars.outputs.tag }} + tag: ${{ needs.container-build.outputs.tag }} + vms: '["fedora-coreos", "fcarm", "rhel", "rhel-arm64", "rhcos", "rhcos-arm64"]' secrets: inherit diff --git a/.github/workflows/container-build.yml b/.github/workflows/container-build.yml new file mode 100644 index 00000000..80d69a94 --- /dev/null +++ b/.github/workflows/container-build.yml @@ -0,0 +1,125 @@ +name: Build container +on: + workflow_call: + inputs: + tag-suffix: + required: false + default: '' + type: string + make-target: + required: false + default: 'image' + type: string + outputs: + tag: + value: ${{ jobs.vars.outputs.tag }} + +jobs: + vars: + runs-on: ubuntu-24.04 + outputs: + tag: ${{ steps.vars.outputs.tag }} + stackrox-io-image: ${{ steps.vars.outputs.stackrox-io-image }} + rhacs-eng-image: ${{ steps.vars.outputs.rhacs-eng-image }} + steps: + - uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + + - id: vars + run: | + cat << EOF >> "$GITHUB_OUTPUT" + tag=$(make tag)${{ inputs.tag-suffix }} + stackrox-io-image=$(make image-name)${{ inputs.tag-suffix }} + rhacs-eng-image=$(FACT_REGISTRY="quay.io/rhacs-eng/fact" make image-name)${{ inputs.tag-suffix }} + EOF + + container: + needs: + - vars + strategy: + fail-fast: false + matrix: + arch: + - amd64 + - arm64 + runs-on: ${{ (matrix.arch == 'arm64' && 'ubuntu-24.04-arm') || 'ubuntu-24.04' }} + env: + FACT_TAG: ${{ needs.vars.outputs.tag }}-${{ matrix.arch }} + FACT_VERSION: ${{ needs.vars.outputs.tag }} + STACKROX_IO_IMAGE: ${{ needs.vars.outputs.stackrox-io-image }}-${{ matrix.arch }} + RHACS_ENG_IMAGE: ${{ needs.vars.outputs.rhacs-eng-image }}-${{ matrix.arch }} + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Build image + run: DOCKER=podman make ${{ inputs.make-target }} + + - name: Login to quay.io/stackrox-io + uses: docker/login-action@v3 + with: + registry: quay.io + username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }} + password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }} + + - run: podman push "${STACKROX_IO_IMAGE}" + + - name: Login to quay.io/rhacs-eng + uses: docker/login-action@v3 + with: + registry: quay.io + username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }} + password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }} + + - name: Tag and push to rhacs-eng + run: | + podman tag "${STACKROX_IO_IMAGE}" "${RHACS_ENG_IMAGE}" + podman push "${RHACS_ENG_IMAGE}" + + manifest-stackrox-io: + runs-on: ubuntu-24.04 + needs: + - container + - vars + env: + ARCHS: amd64 arm64 + steps: + - uses: redhat-actions/podman-login@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }} + password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }} + + - name: Create multiarch manifest + run: | + podman manifest create ${{ needs.vars.outputs.stackrox-io-image }} \ + ${{ needs.vars.outputs.stackrox-io-image }}-amd64 \ + ${{ needs.vars.outputs.stackrox-io-image }}-arm64 + podman manifest inspect ${{ needs.vars.outputs.stackrox-io-image }} + podman manifest push ${{ needs.vars.outputs.stackrox-io-image }} + + manifest-rhacs-eng: + runs-on: ubuntu-24.04 + needs: + - container + - vars + env: + ARCHS: amd64 arm64 + steps: + - uses: redhat-actions/podman-login@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }} + password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }} + + - name: Create multiarch manifest + run: | + podman manifest create ${{ needs.vars.outputs.rhacs-eng-image }} \ + ${{ needs.vars.outputs.rhacs-eng-image }}-amd64 \ + ${{ needs.vars.outputs.rhacs-eng-image }}-arm64 + podman manifest inspect ${{ needs.vars.outputs.rhacs-eng-image }} + podman manifest push ${{ needs.vars.outputs.rhacs-eng-image }} + diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 20002076..56de2a0c 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -16,7 +16,16 @@ on: job-tag: description: Additional tag to prevent collision on GCP VM naming type: string - default: '' + default: 'main' + vms: + description: JSON encoded list of vms to run tests on + type: string + required: true + output-type: + description: The output type to be used in the tests + type: string + required: false + default: grpc jobs: integration-tests: @@ -24,13 +33,7 @@ jobs: strategy: fail-fast: false matrix: - vm: - - fedora-coreos - - fcarm - - rhel - - rhel-arm64 - - rhcos - - rhcos-arm64 + vm: ${{ fromJson(inputs.vms) }} steps: - uses: actions/checkout@v4 @@ -73,6 +76,7 @@ jobs: FACT_VERSION: ${{ inputs.version }} FACT_REGISTRY: ${{ inputs.registry }} FACT_TAG: ${{ inputs.tag }} + OUTPUT_TYPE: ${{ inputs.output-type }} run: | FACT_IMAGE_NAME="$(make -sC "${GITHUB_WORKSPACE}/fact" image-name)" cat << EOF > vars.yml @@ -81,6 +85,7 @@ jobs: fact: image: ${FACT_IMAGE_NAME} version: ${FACT_VERSION} + output_type: ${OUTPUT_TYPE} quay: username: ${{ secrets.QUAY_RHACS_ENG_RO_USERNAME }} password: ${{ secrets.QUAY_RHACS_ENG_RO_PASSWORD }} @@ -147,7 +152,7 @@ jobs: continue-on-error: true uses: actions/upload-artifact@v4 with: - name: ${{ matrix.vm }}-test-logs + name: ${{ matrix.vm }}-${{ inputs.job-tag }}-test-logs path: | /tmp/fact/tests/logs /tmp/fact/tests/*-results.xml diff --git a/.github/workflows/konflux-tests.yml b/.github/workflows/konflux-tests.yml index f3415578..bed02ef0 100644 --- a/.github/workflows/konflux-tests.yml +++ b/.github/workflows/konflux-tests.yml @@ -50,4 +50,5 @@ jobs: registry: quay.io/rhacs-eng/release-fact tag: ${{ needs.init.outputs.fact-tag }} job-tag: konf + vms: '["fedora-coreos", "fcarm", "rhel", "rhel-arm64", "rhcos", "rhcos-arm64"]' secrets: inherit diff --git a/Makefile b/Makefile index 366692c3..ef94eb3d 100644 --- a/Makefile +++ b/Makefile @@ -17,17 +17,12 @@ image: -f Containerfile \ --build-arg FACT_VERSION=$(FACT_VERSION) \ --build-arg RUST_VERSION=$(RUST_VERSION) \ + --build-arg CARGO_ARGS="$(CARGO_ARGS)" \ -t $(FACT_IMAGE_NAME) \ $(CURDIR) -image-otel: - $(DOCKER) build \ - -f Containerfile \ - --build-arg FACT_VERSION=$(FACT_VERSION) \ - --build-arg RUST_VERSION=$(RUST_VERSION) \ - --build-arg CARGO_ARGS="--features otel" \ - -t $(FACT_IMAGE_NAME)-otel \ - $(CURDIR) +image-otel: CARGO_ARGS = --features otel +image-otel: image licenses:THIRD_PARTY_LICENSES.html diff --git a/ansible/run-tests.yml b/ansible/run-tests.yml index 446326f2..9d5ff91f 100644 --- a/ansible/run-tests.yml +++ b/ansible/run-tests.yml @@ -1,8 +1,6 @@ --- - name: Run integration tests hosts: "platform_*:&job_id_{{ job_id }}" - environment: - FACT_IMAGE_NAME: "{{ fact.image | default(None) }}" tasks: - name: Clone the repo @@ -44,6 +42,8 @@ become: true environment: DOCKER_HOST: "{{ runtime_host }}" + FACT_IMAGE_NAME: "{{ fact.image | default(None) }}" + OUTPUT_TYPE: "{{ output_type | default('grpc') }}" ansible.builtin.shell: cmd: | set -euo pipefail @@ -65,7 +65,7 @@ ../third_party/stackrox/proto/internalapi/sensor/sfa_iservice.proto # Run the tests - pytest --image="${FACT_IMAGE_NAME}" --junit-xml=results.xml + pytest --image="${FACT_IMAGE_NAME}" --junit-xml=results.xml --output="${OUTPUT_TYPE}" always: - name: Make logs directories