diff --git a/.github/workflows/apps/latest_major_version.go b/.github/workflows/apps/latest_major_version.go new file mode 100644 index 0000000000..d1a7a5ccba --- /dev/null +++ b/.github/workflows/apps/latest_major_version.go @@ -0,0 +1,153 @@ +// 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 2016 Datadog, Inc. + +package main + +import ( + "encoding/json" + "fmt" + "sort" + "github.com/Masterminds/semver/v3" + "golang.org/x/mod/modfile" + "net/http" + "os" + "regexp" + "strings" +) + +type Tag struct { + Name string +} + +func getLatestMajorVersion(repo string) (string, error) { + // Get latest major version available for repo from github. + const apiURL = "https://api.github.com/repos/%s/tags" + url := fmt.Sprintf(apiURL, repo) + + resp, err := http.Get(url) + if err != nil { + return "", err + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return "", fmt.Errorf("failed to fetch tags: %s", resp.Status) + } + + var tags []struct { + Name string `json:"name"` + } + + if err := json.NewDecoder(resp.Body).Decode(&tags); err != nil { + return "", err + } + latestByMajor := make(map[int]*semver.Version) + + for _, tag := range tags { + v, err := semver.NewVersion(tag.Name) + if err != nil { + continue // Skip invalid versions + } + + if v.Prerelease() != "" { + continue // Ignore pre-release versions + } + + major := int(v.Major()) + if current, exists := latestByMajor[major]; !exists || v.GreaterThan(current) { + latestByMajor[major] = v + } + } + + var latestMajor *semver.Version + for _, v := range latestByMajor { + if latestMajor == nil || v.Major() > latestMajor.Major() { + latestMajor = v + } + } + + if latestMajor != nil { + return fmt.Sprintf("v%d", latestMajor.Major()), nil + } + + return "", fmt.Errorf("no valid versions found") + +} + +func main() { + + data, err := os.ReadFile("integration_go.mod") + if err != nil { + fmt.Println("Error reading integration_go.mod:", err) + return + } + + modFile, err := modfile.Parse("integration_go.mod", data, nil) + if err != nil { + fmt.Println("Error parsing integration_go.mod:", err) + return + } + + latestMajor := make(map[string]*semver.Version) + + // Match on versions with /v{major} + versionRegex := regexp.MustCompile(`^(?P.+?)/v(\d+)$`) + + // Iterate over the required modules and update latest major version if necessary + for _, req := range modFile.Require { + module := req.Mod.Path + + if match := versionRegex.FindStringSubmatch(module); match != nil { + url := match[1] // base module URL (e.g., github.com/foo) + majorVersionStr := "v" + match[2] // Create semantic version string (e.g., "v2") + + moduleName := strings.TrimPrefix(strings.TrimSpace(url), "github.com/") + + // Parse the semantic version + majorVersion, err := semver.NewVersion(majorVersionStr) + if err != nil { + fmt.Printf("Skip invalid version for module %s: %v\n", module, err) + continue + } + + if existing, ok := latestMajor[moduleName]; !ok || majorVersion.GreaterThan(existing) { + latestMajor[moduleName] = majorVersion + } + } + } + + // Output latest major version that we support. + // Check if a new major version in Github is available that we don't support. + // If so, output that a new latest is available. + + // Sort the output + modules := make([]string, 0, len(latestMajor)) + for module := range latestMajor { + modules = append(modules, module) + } + sort.Strings(modules) + + for _, module := range modules { + major := latestMajor[module] + + latestVersion, err := getLatestMajorVersion(module) // latest version available + if err != nil { + fmt.Printf("Error fetching latest version for module '%s': %v\n", module, err) + continue + } + + latestVersionParsed, err := semver.NewVersion(latestVersion) + if err != nil { + fmt.Printf("Error parsing latest version '%s' for module '%s': %v\n", latestVersion, module, err) + continue + } + + fmt.Printf("Latest DD major version of %s: %d\n", module, major.Major()) + if major.LessThan(latestVersionParsed) { + fmt.Printf("New latest major version of %s available: %d\n", module, latestVersionParsed.Major()) + } + + } +} diff --git a/.github/workflows/outdated-integrations.yml b/.github/workflows/outdated-integrations.yml new file mode 100644 index 0000000000..0e559c8039 --- /dev/null +++ b/.github/workflows/outdated-integrations.yml @@ -0,0 +1,41 @@ +name: Outdated Integrations +on: + schedule: + - cron: "0 0 * * 0" # Runs every Sunday at midnight UTC + workflow_dispatch: + +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: + test: + name: Find new major versions for the contrib package dependencies + runs-on: ubuntu-latest + permissions: + actions: read + contents: write + pull-requests: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + + - run: go get github.com/Masterminds/semver/v3 + + - run: go run .github/workflows/apps/latest_major_version.go > latests.txt + + - run: git diff + + - name: Create Pull Request + id: pr + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: "upgrade-latest-major-version" + commit-message: "Update latests file" + base: main + title: "chore: update latest majors" + labels: changelog/no-changelog + body: "Auto-generated PR from Outdated Integrations workflow to update latests major versions" diff --git a/integration_go.mod b/integration_go.mod new file mode 100644 index 0000000000..0bf48eaca0 --- /dev/null +++ b/integration_go.mod @@ -0,0 +1,91 @@ +module gopkg.in/DataDog/dd-trace-go.v1 // This file is manually maintained and updated + +go 1.22.0 + +require ( + cloud.google.com/go/pubsub v1.33.0 + github.com/99designs/gqlgen v0.17.36 + github.com/IBM/sarama v1.40.0 + github.com/Shopify/sarama v1.38.1 + github.com/aws/aws-sdk-go v1.44.327 + github.com/aws/aws-sdk-go-v2 v1.20.3 + github.com/aws/aws-sdk-go-v2/config v1.18.21 + github.com/aws/aws-sdk-go-v2/service/dynamodb v1.21.4 + github.com/aws/aws-sdk-go-v2/service/ec2 v1.93.2 + github.com/aws/aws-sdk-go-v2/service/eventbridge v1.20.4 + github.com/aws/aws-sdk-go-v2/service/kinesis v1.18.4 + github.com/aws/aws-sdk-go-v2/service/s3 v1.32.0 + github.com/aws/aws-sdk-go-v2/service/sfn v1.19.4 + github.com/aws/aws-sdk-go-v2/service/sns v1.21.4 + github.com/aws/aws-sdk-go-v2/service/sqs v1.24.4 + github.com/bradfitz/gomemcache v0.0.0-20230611145640-acc696258285 + github.com/confluentinc/confluent-kafka-go v1.9.2 + github.com/confluentinc/confluent-kafka-go/v2 v2.2.0 + github.com/denisenkom/go-mssqldb v0.11.0 + github.com/dimfeld/httptreemux/v5 v5.5.0 + github.com/elastic/go-elasticsearch/v6 v6.8.5 + github.com/elastic/go-elasticsearch/v7 v7.17.10 + github.com/elastic/go-elasticsearch/v8 v8.15.0 + github.com/emicklei/go-restful v2.16.0+incompatible + github.com/emicklei/go-restful/v3 v3.11.0 + github.com/garyburd/redigo v1.6.4 + github.com/gin-gonic/gin v1.9.1 + github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 + github.com/go-chi/chi v1.5.4 + github.com/go-chi/chi/v5 v5.0.10 + github.com/go-pg/pg/v10 v10.11.1 + github.com/go-redis/redis v6.15.9+incompatible + github.com/go-redis/redis/v7 v7.4.1 + github.com/go-redis/redis/v8 v8.11.5 + github.com/go-redis/redis/v9 v9.7.0 // renamed to redis/go-redis in v9 + github.com/go-sql-driver/mysql v1.6.0 + 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 + 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 + github.com/jinzhu/gorm v1.9.16 + github.com/jmoiron/sqlx v1.3.5 + github.com/julienschmidt/httprouter v1.3.0 + github.com/labstack/echo v3.3.10+incompatible + github.com/labstack/echo/v4 v4.11.1 + github.com/lib/pq v1.10.2 + github.com/mattn/go-sqlite3 v1.14.18 + github.com/microsoft/go-mssqldb v0.21.0 + github.com/miekg/dns v1.1.55 + github.com/redis/go-redis/v9 v9.7.0 + github.com/segmentio/kafka-go v0.4.42 + github.com/sirupsen/logrus v1.9.3 + github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d + github.com/tidwall/buntdb v1.3.0 + github.com/twitchtv/twirp v8.1.3+incompatible + github.com/uptrace/bun v1.1.17 + github.com/uptrace/bun/dialect/sqlitedialect v1.1.17 + github.com/urfave/negroni v1.0.0 + github.com/valyala/fasthttp v1.51.0 + github.com/vektah/gqlparser/v2 v2.5.16 + github.com/zenazn/goji v1.0.1 + go.mongodb.org/mongo-driver v1.12.1 + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.44.0 + google.golang.org/api v0.128.0 + google.golang.org/grpc v1.57.1 + google.golang.org/protobuf v1.33.0 + gopkg.in/jinzhu/gorm.v1 v1.9.2 + gopkg.in/olivere/elastic.v3 v3.0.75 + gopkg.in/olivere/elastic.v5 v5.0.84 + gorm.io/driver/mysql v1.0.1 + gorm.io/driver/postgres v1.4.6 + gorm.io/driver/sqlserver v1.4.2 + gorm.io/gorm v1.25.3 + k8s.io/client-go v0.23.17 +) \ No newline at end of file