Skip to content

Commit

Permalink
Merge pull request #75 from Cray-HPE/CASMHMS-5424
Browse files Browse the repository at this point in the history
Convert hms-smd to github actions
  • Loading branch information
alvarez3-hpe authored May 10, 2022
2 parents 34be5e1 + 59480b8 commit 6b1ba58
Show file tree
Hide file tree
Showing 44 changed files with 1,051 additions and 2,034 deletions.
50 changes: 50 additions & 0 deletions .github/build-image-comment-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!-- This file is templated with https://pkg.go.dev/html/template -->
👋 Hey! Here is the image we built for you ([Artifactory Link](https://artifactory.algol60.net/ui/repos/tree/General/csm-docker%2F{{ .stableString }}%2F{{ .imageName }}%2F{{ .imageTag }})):

```bash
{{ .image }}
```

Use podman or docker to pull it down and inspect locally:

```bash
podman pull {{ .image }}
```

Or, use this script to pull the image from the build server to a dev system:

<details>
<summary>Dev System Pull Script</summary>
<br />

> **Note** the following script only applies to systems running CSM 1.2 or later.
```bash
#!/usr/bin/env bash
export REMOTE_IMAGE={{ .image }}
export LOCAL_IMAGE={{ .imageName }}:{{ .imageTag }}

skopeo copy --dest-tls-verify=false docker://${REMOTE_IMAGE} docker://registry.local/csm-docker/stable/${LOCAL_IMAGE}
```
</details>

<details>
<summary>Snyk Report</summary>
<br />

_Coming soon_

</details>

<details>
<summary>Software Bill of Materials</summary>
<br />

```bash
cosign download sbom {{ .image }} > container_image.spdx
```

If you don't have cosign, then you can get it [here](https://github.com/sigstore/cosign#installation).
</details>

*Note*: this SHA is the merge of {{ .PRHeadSha }} and the PR base branch. Good luck and make rocket go now! 🌮 🚀
20 changes: 20 additions & 0 deletions .github/workflows/build_and_release_ct_image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build and Publish CT Docker Images
on:
- push # Perform a build of the contents from the branch
- pull_request # Perform a build after merging with the target branch
- workflow_dispatch
jobs:
build_and_release:
uses: Cray-HPE/hms-build-image-workflows/.github/workflows/build_and_release_image.yaml@v1
with:
image-name: cray-smd-test
docker-build-file: test/ct/Dockerfile #the test/ct/Dockerfile is what we want!
docker-build-context: test/ct
enable-pr-comment: true
secrets:
artifactory-username: ${{ secrets.ARTIFACTORY_ALGOL60_USERNAME }}
artifactory-token: ${{ secrets.ARTIFACTORY_ALGOL60_TOKEN }}
snyk-token: ${{ secrets.SNYK_TOKEN }}
cosign-gcp-project-id: ${{ secrets.COSIGN_GCP_PROJECT_ID }}
cosign-gcp-sa-key: ${{ secrets.COSIGN_GCP_SA_KEY }}
cosign-key: ${{ secrets.COSIGN_KEY }}
18 changes: 18 additions & 0 deletions .github/workflows/build_and_release_image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build and Publish Service Docker Images
on:
- push # Perform a build of the contents from the branch
- pull_request # Perform a build after merging with the target branch
- workflow_dispatch
jobs:
build_and_release:
uses: Cray-HPE/hms-build-image-workflows/.github/workflows/build_and_release_image.yaml@v1
with:
image-name: cray-smd
enable-pr-comment: true
secrets:
artifactory-username: ${{ secrets.ARTIFACTORY_ALGOL60_USERNAME }}
artifactory-token: ${{ secrets.ARTIFACTORY_ALGOL60_TOKEN }}
snyk-token: ${{ secrets.SNYK_TOKEN }}
cosign-gcp-project-id: ${{ secrets.COSIGN_GCP_PROJECT_ID }}
cosign-gcp-sa-key: ${{ secrets.COSIGN_GCP_SA_KEY }}
cosign-key: ${{ secrets.COSIGN_KEY }}
7 changes: 7 additions & 0 deletions .github/workflows/run_ct_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Run CT Tests
on: [push, pull_request, workflow_dispatch]
jobs:
run_ct_test:
uses: Cray-HPE/hms-build-image-workflows/.github/workflows/run_ct_test.yaml@v1
with:
runs-on: ubuntu-latest
7 changes: 7 additions & 0 deletions .github/workflows/run_unit_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Run Unit Tests
on: [push, pull_request, workflow_dispatch]
jobs:
run_unit_test:
uses: Cray-HPE/hms-build-image-workflows/.github/workflows/run_unit_test.yaml@v1
with:
runs-on: ubuntu-latest
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.50.0
1.51.0
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.51.0] - 2022-05-10

### Changed

- Converted image builds to be via github actions, updated the image links to be in artifactory.algol60.net
- Added a runCT.sh script that can run the tavern tests and smoke tests in a docker-compose environment.
- Refactored CT tests and their directory structure.
- Renamed dockerfiles.

## [1.50.0] - 2022-05-03

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.smd → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

### Build Base Stage ###
# Build base just has the packages installed we need.
FROM arti.dev.cray.com/baseos-docker-master-local/golang:1.16-alpine3.13 AS build-base
FROM artifactory.algol60.net/docker.io/library/golang:1.16-alpine AS build-base

RUN set -ex \
&& apk -U upgrade \
Expand Down Expand Up @@ -56,7 +56,7 @@ RUN set -ex \


### Final Stage ###
FROM arti.dev.cray.com/baseos-docker-master-local/alpine:3.13
FROM artifactory.algol60.net/docker.io/alpine:3.15
LABEL maintainer="Hewlett Packard Enterprise"
EXPOSE 27779
STOPSIGNAL SIGTERM
Expand Down
7 changes: 3 additions & 4 deletions Dockerfile.testing → Dockerfile.testing.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


### Build Base Stage ###
FROM arti.dev.cray.com/baseos-docker-master-local/golang:1.16-alpine3.13 AS build-base
FROM artifactory.algol60.net/docker.io/library/golang:1.16-alpine AS build-base

RUN set -ex \
&& apk -U upgrade \
Expand All @@ -45,7 +45,6 @@ COPY vendor $GOPATH/src/github.com/Cray-HPE/hms-smd/vendor
### Final Stage ###
FROM base
# Run unit tests...
RUN set -ex && \
go test -cover -v -tags musl github.com/Cray-HPE/hms-smd/cmd/smd && \
CMD ["sh", "-c", "go test -cover -v -tags musl github.com/Cray-HPE/hms-smd/cmd/smd && \
go test -cover -v -tags musl github.com/Cray-HPE/hms-smd/internal/./... && \
go test -cover -v -tags musl github.com/Cray-HPE/hms-smd/pkg/./...
go test -cover -v -tags musl github.com/Cray-HPE/hms-smd/pkg/./..."]
57 changes: 0 additions & 57 deletions Jenkinsfile.github

This file was deleted.

38 changes: 9 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand All @@ -24,39 +24,19 @@
NAME ?= cray-smd
VERSION ?= $(shell cat .version)

# Common RPM variable
BUILD_METADATA ?= "1~development~$(shell git rev-parse --short HEAD)"

# CT Test RPM
TEST_SPEC_NAME ?= hms-smd-ct-test
TEST_RPM_VERSION ?= $(shell cat .version)
TEST_SPEC_FILE ?= ${TEST_SPEC_NAME}.spec
TEST_SOURCE_NAME ?= ${TEST_SPEC_NAME}-${TEST_RPM_VERSION}
TEST_BUILD_DIR ?= $(PWD)/dist/smd-ct-test-rpmbuild
TEST_SOURCE_PATH := ${TEST_BUILD_DIR}/SOURCES/${TEST_SOURCE_NAME}.tar.bz2

all: image unittest test_rpm
all: image unittest ct snyk ct_image

image:
docker build ${NO_CACHE} --pull ${DOCKER_ARGS} --tag '${NAME}:${VERSION}' -f Dockerfile.smd .
docker build ${NO_CACHE} --pull ${DOCKER_ARGS} --tag '${NAME}:${VERSION}' -f Dockerfile .

unittest:
./runUnitTest.sh

test_rpm: test_rpm_prepare test_rpm_package_source test_rpm_build_source test_rpm_build

test_rpm_prepare:
rm -rf $(TEST_BUILD_DIR)
mkdir -p $(TEST_BUILD_DIR)/SPECS $(TEST_BUILD_DIR)/SOURCES
cp $(TEST_SPEC_FILE) $(TEST_BUILD_DIR)/SPECS/

test_rpm_package_source:
tar --transform 'flags=r;s,^,/$(TEST_SOURCE_NAME)/,' --exclude .git --exclude dist -cvjf $(TEST_SOURCE_PATH) ./${TEST_SPEC_FILE} ./tests/ct ./LICENSE

test_rpm_build_source:
BUILD_METADATA=$(BUILD_METADATA) rpmbuild -ts $(TEST_SOURCE_PATH) --define "_topdir $(TEST_BUILD_DIR)"

test_rpm_build:
BUILD_METADATA=$(BUILD_METADATA) rpmbuild -ba $(TEST_SPEC_FILE) --define "_topdir $(TEST_BUILD_DIR)" --nodeps
snyk:
./runSnyk.sh

ct:
./runCT.sh

ct_image:
docker build --no-cache -f test/ct/Dockerfile test/ct/ --tag hms-smd-test:${VERSION}
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,8 @@ https://github.com/Cray-HPE/hms-smd/blob/master/api/swagger_v2.yaml (current)

## SMD CT Testing

This repository builds and publishes hms-smd-ct-test RPMs along with the service itself containing tests that verify SMD on the
NCNs of live Shasta systems. The tests require the hms-ct-test-base RPM to also be installed on the NCNs in order to execute.
The version of the test RPM installed on the NCNs should always match the version of SMD deployed on the system.


This repository builds and publishes the cray-smd-test image along with the service itself containing tests that verify SMD on live Shasta systems. The tests are invoked via helm test.
The version of the cray-smd-test image should always match the version of cray-smd image (vX.Y.Z (build metadata not withstanding)).

## smd Features

Expand Down
2 changes: 1 addition & 1 deletion build_tag_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ shift $((OPTIND - 1))
echo "Building $FORCE and pushing to $REGISTRY_HOSTNAME in repo $REPO with tag $TAG"

set -ex
docker build -f Dockerfile.smd ${FORCE} -t cray/${IMAGE_NAME}:${TAG} .
docker build -f Dockerfile ${FORCE} -t cray/${IMAGE_NAME}:${TAG} .
docker tag cray/${IMAGE_NAME}:${TAG} "${REGISTRY_HOSTNAME}/${REPO}/${IMAGE_NAME}:${TAG}"
docker push "${REGISTRY_HOSTNAME}/${REPO}/${IMAGE_NAME}:${TAG}"
17 changes: 17 additions & 0 deletions configs/kafka_brokers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"BrokerAddress": "kafka:9092",
"TopicsToPublish": {
"cray-telemetry-temperature": null,
"cray-telemetry-voltage": null,
"cray-telemetry-power": null,
"cray-telemetry-energy": null,
"cray-telemetry-fan": null,
"cray-telemetry-pressure": null,
"cray-fabric-telemetry": null,
"cray-fabric-perf-telemetry": null,
"cray-fabric-crit-telemetry": null,
"cray-dmtf-resource-event": null
}
}
]
Loading

0 comments on commit 6b1ba58

Please sign in to comment.