-
Notifications
You must be signed in to change notification settings - Fork 440
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
output supported versions #3058
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,239 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2024 Datadog, Inc. | ||
|
||
package main | ||
|
||
import ( | ||
"bufio" | ||
"bytes" | ||
"context" | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
"sort" | ||
"regexp" | ||
"strings" | ||
"sync" | ||
"time" | ||
) | ||
|
||
type ModuleVersion struct { | ||
Name string | ||
MinVersion string | ||
MaxVersion string | ||
isInstrumented bool | ||
|
||
} | ||
|
||
func isSubdirectory(url, pattern string) bool { | ||
if strings.HasPrefix(url, pattern) { | ||
// Ensure the match is either exact or followed by a "/" | ||
return len(url) == len(pattern) || url[len(pattern)] == '/' | ||
} | ||
return false | ||
} | ||
|
||
func parseGoMod(filePath string) ([]ModuleVersion, error) { | ||
// This parses the go.mod file and extracts modules with their minimum versions. | ||
var modules []ModuleVersion | ||
|
||
file, err := os.Open(filePath) | ||
if err != nil { | ||
return nil, fmt.Errorf("error: %s not found", filePath) | ||
} | ||
defer file.Close() | ||
|
||
regex := regexp.MustCompile(`^\s*([^\s]+)\s+v([0-9]+\.[0-9]+\.[0-9]+.*)`) | ||
|
||
scanner := bufio.NewScanner(file) | ||
inRequireBlock := false | ||
|
||
for scanner.Scan() { | ||
line := strings.TrimSpace(scanner.Text()) | ||
|
||
if strings.HasPrefix(line, "require (") { | ||
inRequireBlock = true | ||
continue | ||
} | ||
|
||
if inRequireBlock && line == ")" { | ||
inRequireBlock = false | ||
continue | ||
} | ||
|
||
if inRequireBlock || strings.HasPrefix(line, "require ") { | ||
match := regex.FindStringSubmatch(line) | ||
if match != nil { | ||
modules = append(modules, ModuleVersion{ | ||
Name: match[1], | ||
MinVersion: match[2], | ||
}) | ||
} | ||
} | ||
} | ||
|
||
if err := scanner.Err(); err != nil { | ||
return nil, fmt.Errorf("error reading file: %v", err) | ||
} | ||
|
||
return modules, nil | ||
} | ||
|
||
func fetchLatestVersion(module string) (string, error) { | ||
// Fetches latest version with `go list` | ||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) | ||
defer cancel() | ||
|
||
cmd := exec.CommandContext(ctx, "go", "list", "-m", "-versions", module) | ||
var stdout, stderr bytes.Buffer | ||
cmd.Stdout = &stdout | ||
cmd.Stderr = &stderr | ||
|
||
err := cmd.Run() | ||
if ctx.Err() == context.DeadlineExceeded { | ||
return "", fmt.Errorf("command timed out") | ||
} | ||
if err != nil { | ||
return "", fmt.Errorf("command error: %s", stderr.String()) | ||
} | ||
|
||
versions := strings.Fields(stdout.String()) | ||
// fmt.Println("Versions:", versions) | ||
if len(versions) < 1 { | ||
return "", fmt.Errorf("no versions found for module: %s", module) | ||
} | ||
|
||
return versions[len(versions)-1], nil | ||
} | ||
func isModuleInstrumented(moduleName string, instrumentedSet map[string]struct{}) bool { | ||
// whether the module has automatic tracing supported (by Orchestrion) | ||
// _, isInstrumented := instrumentedSet[moduleName] | ||
isInstrumented := false | ||
for key := range instrumentedSet { | ||
if isSubdirectory(moduleName, key) { | ||
isInstrumented = true | ||
break | ||
} | ||
} | ||
return isInstrumented | ||
} | ||
|
||
func fetchAllLatestVersions(modules []ModuleVersion) []ModuleVersion { | ||
// Concurrently fetches the latest version of each module. | ||
|
||
var wg sync.WaitGroup | ||
var mu sync.Mutex | ||
|
||
updatedModules := make([]ModuleVersion, 0, len(modules)) | ||
|
||
wg.Add(len(modules)) | ||
for _, mod := range modules { | ||
go func(mod ModuleVersion) { | ||
defer wg.Done() | ||
latestVersion, err := fetchLatestVersion(mod.Name) | ||
if err != nil { | ||
fmt.Printf("Error fetching latest version for %s: %v\n", mod.Name, err) | ||
mu.Lock() | ||
updatedModules = append(updatedModules, ModuleVersion{mod.Name, mod.MinVersion, "Error", mod.isInstrumented}) | ||
mu.Unlock() | ||
return | ||
} | ||
|
||
mu.Lock() | ||
updatedModules = append(updatedModules, ModuleVersion{mod.Name, | ||
mod.MinVersion, latestVersion, mod.isInstrumented}) | ||
mu.Unlock() | ||
}(mod) | ||
} | ||
|
||
wg.Wait() | ||
return updatedModules | ||
} | ||
|
||
func outputVersionsAsMarkdown(modules []ModuleVersion, filePath string) error { | ||
file, err := os.Create(filePath) | ||
if err != nil { | ||
return fmt.Errorf("error creating file: %v", err) | ||
} | ||
defer file.Close() | ||
|
||
fmt.Fprintln(file, "| Dependency | Minimum Version | Maximum Version | Auto-Instrumented |") | ||
fmt.Fprintln(file, "|------------|-----------------|-----------------|-----------------|") | ||
|
||
// Sort modules by name | ||
sort.Slice(modules, func(i, j int) bool { | ||
return modules[i].Name < modules[j].Name | ||
}) | ||
|
||
for _, mod := range modules { | ||
fmt.Fprintf(file, "| %s | v%s | %s | %+v\n", mod.Name, mod.MinVersion, mod.MaxVersion, mod.isInstrumented) | ||
} | ||
return nil | ||
} | ||
|
||
func main() { | ||
goModPath := "integration_go.mod" // path to integration_go.mod | ||
outputPath := "supported_versions.md" | ||
instrumentedSet := map[string]struct{}{ | ||
"database/sql": {}, | ||
"github.com/gin-gonic/gin": {}, | ||
"github.com/go-chi/chi/v5": {}, | ||
"github.com/go-chi/chi": {}, | ||
"github.com/go-redis/redis/v7": {}, | ||
"github.com/go-redis/redis/v8": {}, | ||
"github.com/gofiber/fiber/v2": {}, | ||
"github.com/gomodule/redigo/redis": {}, | ||
"github.com/gorilla/mux": {}, | ||
"github.com/jinzhu/gorm": {}, | ||
"github.com/labstack/echo/v4": {}, | ||
"google.golang.org/grpc": {}, | ||
"gorm.io/gorm": {}, | ||
"net/http": {}, | ||
"go.mongodb.org/mongo-driver/mongo": {}, | ||
"github.com/aws/aws-sdk-go": {}, | ||
"github.com/hashicorp/vault": {}, | ||
"github.com/IBM/sarama": {}, | ||
"github.com/Shopify/sarama": {}, | ||
"k8s.io/client-go": {}, | ||
"log/slog": {}, | ||
"os": {}, | ||
"github.com/aws/aws-sdk-go-v2": {}, | ||
"github.com/redis/go-redis/v9": {}, | ||
"github.com/gocql/gocql": {}, | ||
"cloud.google.com/go/pubsub": {}, | ||
"github.com/99designs/gqlgen": {}, | ||
"github.com/redis/go-redis": {}, | ||
"github.com/graph-gophers/graphql-go": {}, | ||
"github.com/graphql-go/graphql": {}, | ||
"github.com/jackc/pgx": {}, | ||
"github.com/elastic/go-elasticsearch": {}, | ||
"github.com/twitchtv/twirp": {}, | ||
"github.com/segmentio/kafka-go": {}, | ||
"github.com/confluentinc/confluent-kafka-go/kafka": {}, | ||
"github.com/confluentinc/confluent-kafka-go/kafka/v2": {}, | ||
"github.com/julienschmidt/httprouter": {}, | ||
"github.com/sirupsen/logrus": {}, | ||
} | ||
|
||
modules, err := parseGoMod(goModPath) | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
|
||
for i := range modules { | ||
modules[i].isInstrumented = isModuleInstrumented(modules[i].Name, instrumentedSet) | ||
} | ||
|
||
modulesWithLatest := fetchAllLatestVersions(modules) | ||
|
||
err = outputVersionsAsMarkdown(modulesWithLatest, outputPath) | ||
if err != nil { | ||
fmt.Printf("Error writing output file: %v\n", err) | ||
return | ||
} | ||
|
||
fmt.Println("Version information written to", outputPath) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Supported Versions | ||
on: | ||
workflow_run: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
workflows: ["Smoke Tests"] | ||
branches: [main] | ||
types: | ||
- completed | ||
|
||
concurrency: | ||
# Automatically cancel previous runs if a new one is triggered to conserve resources. | ||
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
on-smoke-tests-success: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: read | ||
contents: write | ||
pull-requests: write | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
- run: echo 'Smoke Tests workflow passed' | ||
|
||
- run: go run .github/workflows/apps/output_integration_versions.go | ||
|
||
- run: git diff | ||
|
||
# note: This will only run when there *are* changes to integration versions | ||
- name: Create Pull Request | ||
id: pr | ||
uses: peter-evans/create-pull-request@v6 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: "update-latest-supported-versions" | ||
commit-message: "Update supported versions" | ||
base: main | ||
title: "chore: update latest supported" | ||
labels: changelog/no-changelog | ||
body: "Test" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,15 +42,13 @@ require ( | |
github.com/gocql/gocql v1.6.0 | ||
github.com/gofiber/fiber/v2 v2.52.5 | ||
github.com/gomodule/redigo v1.8.9 | ||
github.com/google/pprof v0.0.0-20230817174616-7a8ec2ada47b | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably put these changes in a separate PR |
||
github.com/google/uuid v1.5.0 | ||
github.com/gorilla/mux v1.8.0 | ||
github.com/graph-gophers/graphql-go v1.5.0 | ||
github.com/graphql-go/graphql v0.8.1 | ||
github.com/graphql-go/handler v0.2.3 | ||
github.com/hashicorp/consul/api v1.24.0 | ||
github.com/hashicorp/go-multierror v1.1.1 | ||
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 | ||
github.com/hashicorp/vault/api v1.9.2 | ||
github.com/hashicorp/vault/sdk v0.9.2 | ||
github.com/jackc/pgx/v5 v5.6.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this go.mod being generated? |
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,85 @@ | ||||||
| Dependency | Minimum Version | Maximum Version | Auto-Instrumented | | ||||||
|------------|-----------------|-----------------|-----------------| | ||||||
| cloud.google.com/go/pubsub | v1.33.0 | v1.45.3 | true | ||||||
| github.com/99designs/gqlgen | v0.17.36 | v0.17.62 | true | ||||||
| github.com/IBM/sarama | v1.40.0 | v1.44.0 | true | ||||||
| github.com/Shopify/sarama | v1.38.1 | v1.44.0 | true | ||||||
| github.com/aws/aws-sdk-go | v1.44.327 | v1.55.5 | true | ||||||
| github.com/aws/aws-sdk-go-v2 | v1.20.3 | v2.0.0-preview.4+incompatible | true | ||||||
| github.com/aws/aws-sdk-go-v2/config | v1.18.21 | v1.28.7 | true | ||||||
| github.com/aws/aws-sdk-go-v2/service/dynamodb | v1.21.4 | v1.38.1 | true | ||||||
| github.com/aws/aws-sdk-go-v2/service/ec2 | v1.93.2 | v1.198.1 | true | ||||||
| github.com/aws/aws-sdk-go-v2/service/eventbridge | v1.20.4 | v1.36.1 | true | ||||||
| github.com/aws/aws-sdk-go-v2/service/kinesis | v1.18.4 | v1.32.8 | true | ||||||
| github.com/aws/aws-sdk-go-v2/service/s3 | v1.32.0 | v1.71.1 | true | ||||||
| github.com/aws/aws-sdk-go-v2/service/sfn | v1.19.4 | v1.34.2 | true | ||||||
| github.com/aws/aws-sdk-go-v2/service/sns | v1.21.4 | v1.33.8 | true | ||||||
| github.com/aws/aws-sdk-go-v2/service/sqs | v1.24.4 | v1.37.4 | true | ||||||
| github.com/bradfitz/gomemcache | v0.0.0-20230611145640-acc696258285 | github.com/bradfitz/gomemcache | false | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. third column does not contain a version |
||||||
| github.com/confluentinc/confluent-kafka-go | v1.9.2 | v1.9.3-RC3 | false | ||||||
| github.com/confluentinc/confluent-kafka-go/v2 | v2.2.0 | v2.6.1 | false | ||||||
| github.com/denisenkom/go-mssqldb | v0.11.0 | v0.12.3 | false | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not an integration There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. marking the subsequent related comments as resolved, addressed these in #3064 |
||||||
| github.com/dimfeld/httptreemux/v5 | v5.5.0 | v5.5.0 | false | ||||||
| github.com/elastic/go-elasticsearch/v6 | v6.8.5 | v6.8.10 | true | ||||||
| github.com/elastic/go-elasticsearch/v7 | v7.17.10 | v7.17.10 | true | ||||||
| github.com/elastic/go-elasticsearch/v8 | v8.15.0 | v8.17.0 | true | ||||||
| github.com/emicklei/go-restful | v2.16.0+incompatible | v2.16.0+incompatible | false | ||||||
| github.com/emicklei/go-restful/v3 | v3.11.0 | v3.12.1 | false | ||||||
| github.com/garyburd/redigo | v1.6.4 | v1.6.4 | false | ||||||
| github.com/gin-gonic/gin | v1.9.1 | v1.10.0 | true | ||||||
| github.com/globalsign/mgo | v0.0.0-20181015135952-eeefdecb41b8 | github.com/globalsign/mgo | false | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. third column doesn't contain a version |
||||||
| github.com/go-chi/chi | v1.5.4 | v4.1.2+incompatible | true | ||||||
| github.com/go-chi/chi/v5 | v5.0.10 | v5.2.0 | true | ||||||
| github.com/go-pg/pg/v10 | v10.11.1 | v10.14.0 | false | ||||||
| github.com/go-redis/redis | v6.15.9+incompatible | v6.15.9+incompatible | false | ||||||
| github.com/go-redis/redis/v7 | v7.4.1 | v7.4.1 | true | ||||||
| github.com/go-redis/redis/v8 | v8.11.5 | v8.11.5 | true | ||||||
| github.com/go-redis/redis/v9 | v9.7.0 // renamed to redis/go-redis in v9 | v9.7.0 | false | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
First column should be the module name (not the repo name) + those comments shouldn't be here IMO |
||||||
| github.com/go-sql-driver/mysql | v1.6.0 | v1.8.1 | false | ||||||
quinna-h marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| github.com/gocql/gocql | v1.6.0 | v1.7.0 | true | ||||||
| github.com/gofiber/fiber/v2 | v2.52.5 | v2.52.6 | true | ||||||
| github.com/gomodule/redigo | v1.8.9 | v1.9.2 | false | ||||||
| github.com/google/uuid | v1.5.0 | v1.6.0 | false | ||||||
quinna-h marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| github.com/gorilla/mux | v1.8.0 | v1.8.1 | true | ||||||
| github.com/graph-gophers/graphql-go | v1.5.0 | v1.5.0 | true | ||||||
| github.com/graphql-go/graphql | v0.8.1 | v0.8.1 | true | ||||||
| github.com/graphql-go/handler | v0.2.3 | v0.2.4 | false | ||||||
quinna-h marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| github.com/hashicorp/consul/api | v1.24.0 | v1.31.0 | false | ||||||
| github.com/hashicorp/go-multierror | v1.1.1 | v1.1.1 | false | ||||||
quinna-h marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| github.com/hashicorp/vault/api | v1.9.2 | v1.15.0 | true | ||||||
| github.com/hashicorp/vault/sdk | v0.9.2 | v0.14.0 | true | ||||||
| github.com/jackc/pgx/v5 | v5.6.0 | v5.7.2 | true | ||||||
| github.com/jinzhu/gorm | v1.9.16 | v1.9.16 | true | ||||||
| github.com/jmoiron/sqlx | v1.3.5 | v1.4.0 | false | ||||||
| github.com/julienschmidt/httprouter | v1.3.0 | v1.3.0 | true | ||||||
| github.com/labstack/echo | v3.3.10+incompatible | v3.3.10+incompatible | false | ||||||
| github.com/labstack/echo/v4 | v4.11.1 | v4.13.3 | true | ||||||
| github.com/lib/pq | v1.10.2 | v1.10.9 | false | ||||||
| github.com/mattn/go-sqlite3 | v1.14.18 | v1.14.24 | false | ||||||
| github.com/microsoft/go-mssqldb | v0.21.0 | v1.8.0 | false | ||||||
quinna-h marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| github.com/miekg/dns | v1.1.55 | v1.1.62 | false | ||||||
| github.com/redis/go-redis/v9 | v9.7.0 | v9.7.0 | true | ||||||
| github.com/segmentio/kafka-go | v0.4.42 | v0.4.47 | true | ||||||
| github.com/sirupsen/logrus | v1.9.3 | v1.9.3 | true | ||||||
| github.com/syndtr/goleveldb | v1.0.1-0.20220721030215-126854af5e6d | v1.0.0 | false | ||||||
| github.com/tidwall/buntdb | v1.3.0 | v1.3.2 | false | ||||||
| github.com/twitchtv/twirp | v8.1.3+incompatible | v8.1.3+incompatible | true | ||||||
| github.com/uptrace/bun | v1.1.17 | v1.2.7 | false | ||||||
| github.com/uptrace/bun/dialect/sqlitedialect | v1.1.17 | v1.2.7 | false | ||||||
| github.com/urfave/negroni | v1.0.0 | v1.0.0 | false | ||||||
| github.com/valyala/fasthttp | v1.51.0 | v1.58.0 | false | ||||||
| github.com/vektah/gqlparser/v2 | v2.5.16 | v2.5.21 | false | ||||||
quinna-h marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| github.com/zenazn/goji | v1.0.1 | v1.0.1 | false | ||||||
| go.mongodb.org/mongo-driver | v1.12.1 | v1.17.1 | false | ||||||
| go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp | v0.44.0 | v0.58.0 | false | ||||||
quinna-h marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| google.golang.org/api | v0.128.0 | v0.214.0 | false | ||||||
| google.golang.org/grpc | v1.57.1 | v1.70.0-dev | true | ||||||
| google.golang.org/protobuf | v1.33.0 | v1.36.1 | false | ||||||
quinna-h marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| gopkg.in/jinzhu/gorm.v1 | v1.9.2 | v1.9.2 | false | ||||||
| gopkg.in/olivere/elastic.v3 | v3.0.75 | v3.0.75 | false | ||||||
| gopkg.in/olivere/elastic.v5 | v5.0.84 | v5.0.86 | false | ||||||
| gorm.io/driver/mysql | v1.0.1 | v1.5.7 | false | ||||||
| gorm.io/driver/postgres | v1.4.6 | v1.5.11 | false | ||||||
| gorm.io/driver/sqlserver | v1.4.2 | v1.5.4 | false | ||||||
quinna-h marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| gorm.io/gorm | v1.25.3 | v1.25.12 | true | ||||||
| k8s.io/client-go | v0.23.17 | v0.33.0-alpha.0 | true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is from https://github.com/DataDog/orchestrion?tab=readme-ov-file#supported-libraries