Skip to content

Commit

Permalink
pull in latest
Browse files Browse the repository at this point in the history
Signed-off-by: Stephanie <[email protected]>
  • Loading branch information
yangcao77 committed Sep 19, 2023
2 parents dd5dfc5 + 61526b7 commit d8f84fe
Show file tree
Hide file tree
Showing 55 changed files with 2,030 additions and 843 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build-cdq-analysis-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build CDQ Analysis Container Image

on:
push:
branches: [ main ]

jobs:
build-image:
runs-on: ubuntu-20.04
steps:
- name: Checkout application-service source code
uses: actions/checkout@v2
- name: Change to the cdq-analysis directory
run: cd cdq-analysis/
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
quay.io/redhat-appstudio/cdq-analysis
tags: |
next
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
registry: quay.io
repository: redhat-appstudio/cdq-analysis
- name: Docker Build & Push - application-service Operator Image
uses: docker/build-push-action@v3
with:
dockerfile: Dockerfile
platforms: linux/amd64,linux/ppc64le
push: true
tags: ${{ steps.meta.outputs.tags }}
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
- name: Run tests
run: make test
- name: Codecov
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/pact_postmerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -53,8 +53,9 @@ jobs:
PACT_BROKER_USERNAME: ${{ secrets.PACT_BROKER_USERNAME }}
PROVIDER_BRANCH: "main"
run: |
wget -qO- https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.92.0/pact-1.92.0-linux-x86_64.tar.gz | tar xz --one-top-level=./pactcli
PATH=${PATH}:$(pwd)/pactcli/pact/bin
go get github.com/pact-foundation/pact-go/[email protected]
go install github.com/pact-foundation/pact-go/[email protected]
sudo /home/runner/go/bin/pact-go -l DEBUG install
echo "Running Pact tests from the \"$(git branch --show-current)\" brach."
# Run Pact tests and publish results. Required variables to be set:
# COMMIT_SHA sets the version
Expand Down
57 changes: 49 additions & 8 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -69,9 +69,9 @@ jobs:
git --no-pager diff
exit 1
fi
- uses: dominikh/staticcheck-action@v1.2.0
- uses: dominikh/staticcheck-action@v1.3.0
with:
version: "2022.1"
version: "2022.1.3"
install-go: false
- name: Check manifests
run: |
Expand All @@ -86,6 +86,12 @@ jobs:
fi
- name: Run Go Tests
run: |
# Temporarily adding a pact-go installation.
# It should be gone once https://issues.redhat.com/browse/HAC-4879 is solved
go get github.com/pact-foundation/pact-go/[email protected]
go install github.com/pact-foundation/pact-go/[email protected]
sudo /home/runner/go/bin/pact-go -l DEBUG install
make test
- name: Check if Manager Kustomize has the right image
run: |
Expand All @@ -101,7 +107,7 @@ jobs:
then
echo "gosec scanner failed to run "
exit 1
fi
fi
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
Expand All @@ -121,10 +127,28 @@ jobs:
fetch-depth: 0
- name: Check if dockerimage build is working
run: docker build -f ./Dockerfile .
build-cdq-analysis-image:
name: Check CDQ Analysis Image Build
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Change to the cdq-analysis directory
run: cd cdq-analysis/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Check if dockerimage build is working
run: docker build -f ./Dockerfile .
pact:
name: Pact tests
runs-on: ubuntu-latest
env:
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
PR_CHECK: true
Expand All @@ -133,7 +157,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -168,7 +192,24 @@ jobs:
if: steps.cache-mod.outputs.cache-hit != 'true'
- name: Test Pact contracts
run: |
wget -qO- https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.92.0/pact-1.92.0-linux-x86_64.tar.gz | tar xz --one-top-level=./pactcli
PATH=${PATH}:$(pwd)/pactcli/pact/bin
go get github.com/pact-foundation/pact-go/[email protected]
go install github.com/pact-foundation/pact-go/[email protected]
sudo /home/runner/go/bin/pact-go -l DEBUG install
COMMIT_SHA=${COMMIT_SHA:0:7}
make pact
kube-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create ./.kube-linter/ for deployment files
shell: bash
run: mkdir -p ./.kube-linter/ && touch .kube-linter/manifests.yaml
- name: Generate manifests for scan
shell: bash
run: kustomize build config/default > ./.kube-linter/manifests.yaml
- name: Scan yaml files with kube-linter
uses: stackrox/kube-linter-action@v1
id: kube-linter-action-scan
with:
# Adjust this directory to the location where your kubernetes resources and helm charts are located.
directory: ./.kube-linter/
33 changes: 33 additions & 0 deletions .tekton/push-cdq-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: pipeline-to-push-cdq-image
annotations:
pipelinesascode.tekton.dev/on-cel-expression: |
event == "push" && target_branch == "main" && "cdq-analysis/***".pathChanged()
pipelinesascode.tekton.dev/max-keep-runs: "2"
spec:
params:
- name: git-url
value: "{{repo_url}}"
- name: revision
value: "{{revision}}"
- name: output-image
value: "quay.io/redhat-appstudio/cdq-analysis:{{revision}}"
- name: path-context
value: "cdq-analysis"
- name: infra-deployment-update-script
value: |
sed -i -e 's|\(https://github.com/redhat-appstudio/application-service/.*?ref=\)\(.*\)|\1{{ revision }}|' -e 's/\(newTag: \).*/\1{{ revision }}/' components/has/cdq-analysis/kustomization.yaml
pipelineRef:
name: docker-build
bundle: quay.io/redhat-appstudio-tekton-catalog/pipeline-core-services-docker-build:latest
workspaces:
- name: workspace
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.18 as builder
FROM golang:1.19 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pact-tests:
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -v --run TestContracts

pact: manifests generate fmt vet envtest ## Run just Pact tests.
make pact-tests
LOG_LEVEL=debug make pact-tests

test: manifests generate fmt vet envtest ## Run tests.
make unit-tests
Expand Down
2 changes: 0 additions & 2 deletions OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ approvers:
- kim-tsao
- maysunfaisal
- michael-valdron
- mike-hoang
- thepetk
- yangcao77

Expand All @@ -16,6 +15,5 @@ reviewers:
- kim-tsao
- maysunfaisal
- michael-valdron
- mike-hoang
- thepetk
- yangcao77
27 changes: 22 additions & 5 deletions cdq-analysis/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
FROM registry.access.redhat.com/ubi9/go-toolset:latest

WORKDIR /app
# Build the gitops generator binary
FROM golang:1.18 as builder

WORKDIR /workspace
# Copy the source code
COPY . .

# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

RUN go build -o ./main
# Build
RUN CGO_ENABLED=0 GOOS=linux go build -a -o cdq-analysis main.go


FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6-751
RUN microdnf update --setopt=install_weak_deps=0 -y && microdnf install git

# Set up the non-root workspace and copy over the gitops generator binary and entrypoint script
WORKDIR /workspace
COPY --from=builder /workspace/cdq-analysis .

COPY entrypoint.sh .
RUN chgrp -R 0 /workspace && chmod -R g=u /workspace

USER 1001

ENTRYPOINT ["/workspace/entrypoint.sh"]
7 changes: 7 additions & 0 deletions cdq-analysis/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
set -eux

./cdq-analysis --name "$NAME" --namespace "$NAMESPACE" -- contextPath "$CONTEXT_PATH" \
--revision "$REVISION" --URL "$URL" --DevfileRegistryURL "$DEVFILE_REGISTRY_URL" \
--devfilePath "$DEVFILE_PATH" --dockerfilePath "$DOCKERFILE_PATH" --isDevfilePresent $IS_DEVFILE_PRESENT \
--isDockerfilePresent $IS_DOCKERFILE_PRESENT --createK8sJob $CREATE_K8S_Job
9 changes: 6 additions & 3 deletions cdq-analysis/go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
module github.com/redhat-appstudio/application-service/cdq-analysis

go 1.18
go 1.19

require (
github.com/devfile/alizer v1.1.1-1.18b
github.com/devfile/api/v2 v2.2.1-alpha.0.20230413012049-a6c32fca0dbd
github.com/devfile/library/v2 v2.2.1-0.20230418160146-e75481b7eebd
github.com/devfile/library/v2 v2.2.1-0.20230821212346-99a3776c0b1e
github.com/devfile/registry-support/index/generator v0.0.0-20221018203505-df96d34d4273
github.com/devfile/registry-support/registry-library v0.0.0-20221018213054-47b3ffaeadba
github.com/go-logr/logr v1.2.4
github.com/hashicorp/go-multierror v1.1.1
github.com/pkg/errors v0.9.1
github.com/spf13/afero v1.8.0
github.com/stretchr/testify v1.8.1
go.uber.org/zap v1.24.0
Expand All @@ -33,6 +34,7 @@ require (
github.com/containerd/typeurl v1.0.2 // indirect
github.com/creack/pty v1.1.17 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/distribution/distribution/v3 v3.0.0-20211118083504-a29a3c99a684 // indirect
github.com/docker/cli v23.0.0-rc.1+incompatible // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v23.0.0-rc.1+incompatible // indirect
Expand Down Expand Up @@ -73,6 +75,7 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.15.12 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
Expand All @@ -90,12 +93,12 @@ require (
github.com/openshift/api v0.0.0-20210503193030-25175d9d392d // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
Expand Down
10 changes: 7 additions & 3 deletions cdq-analysis/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ github.com/devfile/api/v2 v2.2.1-alpha.0.20230413012049-a6c32fca0dbd/go.mod h1:q
github.com/devfile/library v1.2.1-0.20211104222135-49d635cb492f/go.mod h1:uFZZdTuRqA68FVe/JoJHP92CgINyQkyWnM2Qyiim+50=
github.com/devfile/library v1.2.1-0.20220308191614-f0f7e11b17de/go.mod h1:GSPfJaBg0+bBjBHbwBE5aerJLH6tWGQu2q2rHYd9czM=
github.com/devfile/library/v2 v2.0.1/go.mod h1:paJ0PARAVy0br13VpBEQ4fO3rZVDxWtooQ29+23PNBk=
github.com/devfile/library/v2 v2.2.1-0.20230418160146-e75481b7eebd h1:YHSwUdfWsG9Qk7Vn+NfafELv6+G6a43RRE/NjS0TfK0=
github.com/devfile/library/v2 v2.2.1-0.20230418160146-e75481b7eebd/go.mod h1:jXIVOBkEqh7YJddFcZ+vak47rlbCW//f+qqG5hUozhM=
github.com/devfile/library/v2 v2.2.1-0.20230821212346-99a3776c0b1e h1:ozHGZOXlBvtf4YqZRrMiSNH6q6gjw6XaUisMhWG4Vwg=
github.com/devfile/library/v2 v2.2.1-0.20230821212346-99a3776c0b1e/go.mod h1:7oEhkC6GW6OKmAP8HbxbaQ+nFbnACQuU7anYhJroltQ=
github.com/devfile/registry-support/index/generator v0.0.0-20220222194908-7a90a4214f3e/go.mod h1:iRPBxs+ZjfLEduVXpCCIOzdD2588Zv9OCs/CcXMcCCY=
github.com/devfile/registry-support/index/generator v0.0.0-20220527155645-8328a8a883be/go.mod h1:1fyDJL+fPHtcrYA6yjSVWeLmXmjCNth0d5Rq1rvtryc=
github.com/devfile/registry-support/index/generator v0.0.0-20221018203505-df96d34d4273 h1:DXENQSRTEDsk9com38njPg5511DD12HPIgzyFUErnpM=
Expand Down Expand Up @@ -673,8 +673,9 @@ github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
Expand Down Expand Up @@ -889,6 +890,9 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
Expand Down
Loading

0 comments on commit d8f84fe

Please sign in to comment.