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

currency: Automate ruby tracer currency report generation #385

Merged
merged 8 commits into from
Jun 17, 2024
Merged
36 changes: 36 additions & 0 deletions .tekton/.currency/currency-pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: ruby-currency-pipeline
spec:
params:
- name: revision
type: string
workspaces:
- name: ruby-currency-pvc
tasks:
- name: clone-repo
params:
- name: revision
value: $(params.revision)
taskRef:
name: ruby-git-clone-task
workspaces:
- name: task-pvc
workspace: ruby-currency-pvc
- name: generate-currency-report
runAfter:
- clone-repo
taskRef:
name: ruby-generate-currency-report-task
workspaces:
- name: task-pvc
workspace: ruby-currency-pvc
- name: upload-currency-report
runAfter:
- generate-currency-report
taskRef:
name: ruby-upload-currency-report-task
workspaces:
- name: task-pvc
workspace: ruby-currency-pvc
20 changes: 20 additions & 0 deletions .tekton/.currency/currency-pipelinerun.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: ruby-currency-pipelinerun
spec:
params:
- name: revision
value: "master"
pipelineRef:
name: ruby-currency-pipeline
serviceAccountName: currency-serviceaccount
workspaces:
- name: ruby-currency-pvc
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
29 changes: 29 additions & 0 deletions .tekton/.currency/currency-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: currency-serviceaccount
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: currency-clusterrole
rules:
- apiGroups: [""]
resources: ["pods", "pods/log"]
verbs: ["get", "list"]
- apiGroups: ["tekton.dev"]
resources: ["taskruns"]
verbs: ["get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: currency-clusterrolebinding
subjects:
- kind: ServiceAccount
name: currency-serviceaccount
namespace: default
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: currency-clusterrole
56 changes: 56 additions & 0 deletions .tekton/.currency/currency-scheduled-eventlistener.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: EventListener
metadata:
name: ruby-currency-cron-listener
spec:
serviceAccountName: tekton-triggers-eventlistener-serviceaccount
triggers:
- name: currency-cron-trigger
template:
ref: ruby-currency-trigger-template
---
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerTemplate
metadata:
name: ruby-currency-trigger-template
spec:
resourcetemplates:
- apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: ruby-currency-
spec:
pipelineRef:
name: ruby-currency-pipeline
serviceAccountName: currency-serviceaccount
params:
- name: revision
value: "master"
workspaces:
- name: ruby-currency-pvc
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: ruby-currency-cronjob
spec:
schedule: "5 3 * * Mon-Fri"
jobTemplate:
spec:
template:
spec:
containers:
- name: http-request-to-el-svc
# curlimages/curl:8.6.0
image: curlimages/curl@sha256:f2237028bed58de91f62aea74260bb2a299cf12fbcabc23cfaf125fef276c884
imagePullPolicy: IfNotPresent
args: ["curl", "-X", "POST", "--data", "{}", "el-ruby-currency-cron-listener.default.svc.cluster.local:8080"]
restartPolicy: OnFailure
---
94 changes: 94 additions & 0 deletions .tekton/.currency/currency-tasks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: ruby-git-clone-task
spec:
params:
- name: revision
type: string
workspaces:
- name: task-pvc
mountPath: /workspace
steps:
- name: clone-repo
# alpine/git:2.43.0
image: alpine/git@sha256:6ff4de047dcc8f0c7d75d2efff63fbc189e87d2f458305f2cc8f165ff83309cf
script: |
#!/bin/sh
echo "Cloning repo"
cd /workspace && git clone --filter=blob:none --sparse --depth 1 https://github.com/instana/ruby-sensor -b $(params.revision)
cd ruby-sensor
git sparse-checkout add .tekton/.currency
ls -lah /workspace/ruby-sensor
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: ruby-generate-currency-report-task
spec:
workspaces:
- name: task-pvc
mountPath: /workspace
steps:
- name: generate-currency-report
# 3.10.13-bookworm
image: python@sha256:c970ff53939772f47b0672e380328afb50d8fd1c0568ed4f82c22effc54244fc
script: |
#!/usr/bin/env bash

cd /workspace/ruby-sensor/.tekton/.currency

python -m venv /tmp/venv
source /tmp/venv/bin/activate
pip install -r resources/requirements.txt

python scripts/generate_report.py
if [ $? -ne 0 ]; then
echo "Error occured while generating the ruby tracer currency report." >&2
exit 1
fi
cat docs/report.md
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: ruby-upload-currency-report-task
spec:
params:
- name: github-token-secret
default: instanacd-github-api-token
workspaces:
- name: task-pvc
mountPath: /workspace
steps:
- name: upload-currency-report
# alpine/git:2.43.0
image: alpine/git@sha256:6ff4de047dcc8f0c7d75d2efff63fbc189e87d2f458305f2cc8f165ff83309cf
env:
- name: GH_ENTERPRISE_TOKEN
valueFrom:
secretKeyRef:
name: $(params.github-token-secret)
key: "GH_ENTERPRISE_TOKEN"
script: |
#!/bin/sh

cd /workspace
git clone https://oauth2:[email protected]/instana/tracer-reports.git

if [ $? -ne 0 ]; then
echo "The attempt to clone the tracer-reports repository failed, preventing the upload of ruby tracer currency report." >&2
exit 1
fi

cd tracer-reports

cp ../ruby-sensor/.tekton/.currency/docs/report.md ./automated/currency/ruby/report.md

git config user.name "Instanacd PAT for GitHub Enterprise"
git config user.email [email protected]

git add .

git commit -m "chore: Updated ruby currency report"
git push origin main
19 changes: 19 additions & 0 deletions .tekton/.currency/docs/report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
##### This page is auto-generated. Any change will be overwritten after the next sync. Please apply changes directly to the files in the [ruby tracer](https://github.com/instana/ruby-sensor) repo.
## Ruby supported packages and versions
| Package name | Support Policy | Beta version | Last Supported Version | Latest version | Up-to-date | Cloud Native |
|:---------------|:-----------------|:---------------|:-------------------------|:-----------------|:-------------|:---------------|
| Cuba | On demand | No | 4.0.3 | 4.0.3 | Yes | No |
| Rack | 0-day | No | 3.1.3 | 3.1.3 | Yes | No |
| Rails | 30-days | No | 7.1.3.4 | 7.1.3.4 | Yes | No |
| Rails::API | 30-days | No | 0.4.1 | 0.4.1 | Yes | No |
| Rails LTS | On demand | No | 5.2 | 5.2 | Yes | No |
| Roda | 30-days | No | 3.81.0 | 3.81.0 | Yes | No |
| Sinatra | 30-days | No | 4.0.0 | 4.0.0 | Yes | No |
| Excon | 30-days | No | 0.110.0 | 0.110.0 | Yes | Yes |
| gRPC | 30-days | No | 1.64.0 | 1.64.0 | Yes | No |
| Net::HTTP | 0-day | No | 0.4.1 | 0.4.1 | Yes | No |
| Rest-Client | 30-days | No | 2.1.0 | 2.1.0 | Yes | No |
| Dalli | 30-days | No | 3.2.8 | 3.2.8 | Yes | No |
| Resque | 30-days | No | 2.6.0 | 2.6.0 | Yes | Yes |
| Sidekiq | 30-days | No | 7.2.4 | 7.2.4 | Yes | Yes |
| GraphQL | 30-days | No | 2.3.5 | 2.3.5 | Yes | Yes |
5 changes: 5 additions & 0 deletions .tekton/.currency/resources/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
requests
pandas
beautifulsoup4
tabulate
kubernetes
94 changes: 94 additions & 0 deletions .tekton/.currency/resources/table.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"table": [
{
"Package name": "Cuba",
"Support Policy": "On demand",
"Beta version": "No",
"Cloud Native": "No"
},
{
"Package name": "Rack",
"Support Policy": "0-day",
"Beta version": "No",
"Cloud Native": "No"
},
{
"Package name": "Rails",
"Support Policy": "30-days",
"Beta version": "No",
"Cloud Native": "No"
},
{
"Package name": "Rails::API",
"Support Policy": "30-days",
"Beta version": "No",
"Cloud Native": "No"
},
{
"Package name": "Rails LTS",
"Support Policy": "On demand",
"Beta version": "No",
"Cloud Native": "No"
},
{
"Package name": "Roda",
"Support Policy": "30-days",
"Beta version": "No",
"Cloud Native": "No"
},
{
"Package name": "Sinatra",
"Support Policy": "30-days",
"Beta version": "No",
"Cloud Native": "No"
},
{
"Package name": "Excon",
"Support Policy": "30-days",
"Beta version": "No",
"Cloud Native": "Yes"
},
{
"Package name": "gRPC",
"Support Policy": "30-days",
"Beta version": "No",
"Cloud Native": "No"
},
{
"Package name": "Net::HTTP",
"Support Policy": "0-day",
"Beta version": "No",
"Cloud Native": "No"
},
{
"Package name": "Rest-Client",
"Support Policy": "30-days",
"Beta version": "No",
"Cloud Native": "No"
},
{
"Package name": "Dalli",
"Support Policy": "30-days",
"Beta version": "No",
"Cloud Native": "No"
},
{
"Package name": "Resque",
"Support Policy": "30-days",
"Beta version": "No",
"Cloud Native": "Yes"
},
{
"Package name": "Sidekiq",
"Support Policy": "30-days",
"Beta version": "No",
"Cloud Native": "Yes"
},
{
"Package name": "GraphQL",
"Support Policy": "30-days",
"Beta version": "No",
"Cloud Native": "Yes"
}
]
}
Loading
Loading