-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Stephanie <[email protected]>
- Loading branch information
Showing
55 changed files
with
2,030 additions
and
843 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
@@ -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: | | ||
|
@@ -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: | | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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: | ||
|
@@ -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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.