Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPCT-226: cmd/report UX enhancements #76

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ jobs:
echo "> Setting run permissions to OPCT:"
chmod u+x ${OPCT}

echo "> Running OPCT report:"
echo "> Running OPCT report (simple):"
${OPCT} report /tmp/result.tar.gz

echo "> Running OPCT report (advanced):"
${OPCT} report /tmp/result.tar.gz \
--log-level=debug \
--save-to=/tmp/results-data \
--skip-server=true \
--skip-baseline-api=true

e2e-cmd_adm-parse-etcd-logs:
name: "e2e-cmd_adm-parse-etcd-logs"
runs-on: ubuntu-latest
Expand Down Expand Up @@ -146,3 +153,36 @@ jobs:
${CUSTOM_BUILD_PATH} adm parse-metrics \
--input ${LOCAL_TEST_DATA} --output /tmp/metrics
tree /tmp/metrics

e2e-cmd_adm-baseline:
name: "e2e-cmd_adm-baseline"
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: opct-linux-amd64
path: /tmp/build/

- name: Preparing testdata
env:
OPCT: /tmp/build/opct-linux-amd64
run: |
echo "> Setting exec permissions to OPCT:"
chmod u+x ${OPCT}

- name: "e2e adm baseline: opct adm baseline (list|get)"
env:
OPCT: /tmp/build/opct-linux-amd64
run: |
echo -e "\n\t#>> List latest baseline results"
${OPCT} adm baseline list

echo -e "\n\t#>> List all baseline results"
${OPCT} adm baseline list --all

echo -e "\n\t#>> Retrieve a baseline result by name"
${OPCT} adm baseline get --name 4.16_None_latest --dump

echo -e "\n\t#>> Retrieve a baseline result by release and platform"
${OPCT} adm baseline get --release 4.15 --platform None
8 changes: 7 additions & 1 deletion .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ jobs:
name: linters
uses: ./.github/workflows/pre_linters.yaml

reviewer:
name: reviewer
uses: ./.github/workflows/pre_reviewer.yaml

go-test:
runs-on: ubuntu-latest
needs: linters
needs:
- linters
- reviewer
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/pre_reviewer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
name: reviewer

on:
workflow_call: {}

# golangci-lint-action requires those permissions to annotate issues in the PR.
permissions:
contents: read
checks: write
issues: read
pull-requests: write

env:
GO_VERSION: 1.22
GOLANGCI_LINT_VERSION: v1.59

jobs:
# reviewdog / misspell: https://github.com/reviewdog/action-misspell
misspell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: reviewdog/action-misspell@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
#level: warning
locale: "US"

# reviewdog / suggester: https://github.com/reviewdog/action-suggester
go_fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: gofmt -w -s .
- uses: reviewdog/action-suggester@v1
with:
tool_name: gofmt

# https://github.com/reviewdog/action-hadolint
# containerfile:
# name: runner / hadolint
# runs-on: ubuntu-latest
# steps:
# - name: Check out code
# uses: actions/checkout@v4
# - name: hadolint
# uses: reviewdog/action-hadolint@v1
# with:
# reporter: github-pr-review
8 changes: 6 additions & 2 deletions .github/workflows/static-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ name: Documentation
on:
# Static pages are build only targeting the main branch
push:
branches: ["main"]
paths: ['mkdocs.yml', 'docs/**', 'hack/docs-requirements.txt']
branches:
- "main"
paths:
- 'mkdocs.yml'
- 'docs/**'
- 'hack/docs-requirements.txt'

workflow_dispatch:

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ kubeconfig

# build files
dist/
build/

# changelog is generated automaticaly by hack/generate-changelog.sh
# available only in the rendered webpage (built by mkdocs).
Expand Down
43 changes: 34 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export GO111MODULE=on
export CGO_ENABLED=0

BUILD_DIR ?= $(PWD)/build
IMG ?= quay.io/ocp-cert/opct
IMG ?= quay.io/opct/opct
VERSION=$(shell git rev-parse --short HEAD)
RELEASE_TAG ?= 0.0.0
BIN_NAME ?= opct
Expand Down Expand Up @@ -57,15 +57,30 @@ build-darwin-arm64: build
linux-amd64-container: build-linux-amd64
podman build -t $(IMG):latest -f hack/Containerfile --build-arg=RELEASE_TAG=$(RELEASE_TAG) .

.PHONY: image-mirror-sonobuoy
image-mirror-sonobuoy:
./hack/image-mirror-sonobuoy/mirror.sh
# Publish devel binaries (non-official). Must be used only for troubleshooting in development/support.
.PHONY: publish-amd64-devel
publish-amd64-devel: build-linux-amd64
aws s3 cp $(BUILD_DIR)/opct-linux-amd64 s3://openshift-provider-certification/bin/opct-linux-amd64-devel

# Utils dev
.PHONY: update-go
update-go:
go get -u
go mod tidy
.PHONY: publish-darwin-arm64-devel
publish-darwin-arm64-devel: build-darwin-arm64
aws s3 cp $(BUILD_DIR)/opct-darwin-arm64 s3://openshift-provider-certification/bin/opct-darwin-arm64-devel

.PHONY: publish-devel
publish-devel: publish-amd64-devel
publish-devel: publish-darwin-arm64-devel

#
# Test
#

.PHONY: test-lint
test-lint:
@echo "Running linting tools"
# Download https://github.com/golangci/golangci-lint/releases/tag/v1.59.1
golangci-lint run --timeout=10m
# yamllint: pip install yamllint
yamllint .github/workflows/*.yaml

.PHONY: test
test:
Expand All @@ -90,3 +105,13 @@ build-changelog:
.PHONY: build-docs
build-docs: build-changelog
mkdocs build --site-dir ./site

.PHONY: image-mirror-sonobuoy
image-mirror-sonobuoy:
./hack/image-mirror-sonobuoy/mirror.sh

# Utils dev
.PHONY: update-go
update-go:
go get -u
go mod tidy
23 changes: 22 additions & 1 deletion cmd/root.go → cmd/opct/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ import (
"os"

log "github.com/sirupsen/logrus"
logwriter "github.com/sirupsen/logrus/hooks/writer"

"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/vmware-tanzu/sonobuoy/cmd/sonobuoy/app"

"github.com/redhat-openshift-ecosystem/provider-certification-tool/pkg/cmd/adm"
"github.com/redhat-openshift-ecosystem/provider-certification-tool/pkg/cmd/get"
"github.com/redhat-openshift-ecosystem/provider-certification-tool/pkg/cmd/report"
"github.com/redhat-openshift-ecosystem/provider-certification-tool/pkg/destroy"
"github.com/redhat-openshift-ecosystem/provider-certification-tool/pkg/report"
"github.com/redhat-openshift-ecosystem/provider-certification-tool/pkg/retrieve"
"github.com/redhat-openshift-ecosystem/provider-certification-tool/pkg/run"
"github.com/redhat-openshift-ecosystem/provider-certification-tool/pkg/status"
"github.com/redhat-openshift-ecosystem/provider-certification-tool/pkg/version"
)

const logFile = "opct.log"

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "opct",
Expand All @@ -40,6 +43,24 @@ var rootCmd = &cobra.Command{
log.SetFormatter(&log.TextFormatter{
FullTimestamp: true,
})

log.SetOutput(os.Stdout)
fdLog, err := os.OpenFile(logFile, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
if err != nil {
log.Errorf("error opening file %s: %v", logFile, err)
} else {
log.AddHook(&logwriter.Hook{ // Send logs with level higher than warning to stderr
Writer: fdLog,
LogLevels: []log.Level{
log.PanicLevel,
log.FatalLevel,
log.ErrorLevel,
log.WarnLevel,
log.InfoLevel,
log.DebugLevel,
},
})
}
},
}

Expand Down
Loading
Loading