From 09b7410d65b5b0f459175f395bfb6aba2535047d Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 4 Apr 2024 17:32:34 +0200 Subject: [PATCH] Update versions file automation (#4512) * Fix missing snapshots due to not fetched branches * Improve PR description + add the version requirements to the description/commit message --- .github/workflows/bump-agent-versions.yml | 13 +++++++++---- magefile.go | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bump-agent-versions.yml b/.github/workflows/bump-agent-versions.yml index 259c065c2bb..5fbea417449 100644 --- a/.github/workflows/bump-agent-versions.yml +++ b/.github/workflows/bump-agent-versions.yml @@ -11,6 +11,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + # no depth limit + # so, we can generate snapshot versions based on release branches + fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v4 @@ -20,16 +24,17 @@ jobs: - name: Set up branch run: git checkout -b update-agent-versions-$GITHUB_RUN_ID - - name: Update the agent version file + - name: Install mage uses: magefile/mage-action@v3 with: version: v1.13.0 - args: integration:updateVersions + install-only: true - - name: Check for file changes + - name: Update versions file env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + version_requirements=$(mage integration:updateVersions) changes=$(git status -s -uno .agent-versions.json) if [ -z "$changes" ] then @@ -46,7 +51,7 @@ jobs: git config --global user.name 'apmmachine' git config --global user.email 'apmmachine@users.noreply.github.com' git add ".agent-versions.json" - git commit -m "[$GITHUB_REF_NAME](automation) Update .agent-versions.json" -m "This file is used for picking agent versions in integration tests. It's content is based on the reponse from https://artifacts-api.elastic.co/v1/versions/" + git commit -m "[$GITHUB_REF_NAME](automation) Update .agent-versions.json" -m "This file is used for picking agent versions in integration tests.\n\nThe file's content is based on responses from https://www.elastic.co/api/product_versions and https://snapshots.elastic.co\n\nThe current update is generated based on the following requirements:\n\`\`\`json\n$version_requirements\n\`\`\`" git push --set-upstream origin "update-agent-versions-$GITHUB_RUN_ID" gh pr create \ --base "$GITHUB_REF_NAME" \ diff --git a/magefile.go b/magefile.go index 14b44e20737..607257a3b09 100644 --- a/magefile.go +++ b/magefile.go @@ -1612,7 +1612,7 @@ func (Integration) UpdateVersions(ctx context.Context) error { SnapshotBranches: branches, } b, _ := json.MarshalIndent(reqs, "", " ") - fmt.Printf("Current version requirements: \n%s\n", b) + fmt.Println(string(b)) pvc := pv.NewProductVersionsClient() sc := snapshots.NewSnapshotsClient()