Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/github.com/elastic/ela…
Browse files Browse the repository at this point in the history
…stic-agent-autodiscover-0.6.11
  • Loading branch information
AndersonQ authored Apr 8, 2024
2 parents 4b3da4b + 43cb148 commit 31b12b8
Show file tree
Hide file tree
Showing 77 changed files with 2,038 additions and 746 deletions.
34 changes: 17 additions & 17 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,20 +256,20 @@ steps:

# Triggers a dynamic step: Sync K8s
# Runs only on main and if k8s files are changed
- label: "Trigger k8s sync"
branches: main
plugins:
- monebag/monorepo-diff#v2.5.9:
diff: "git diff --name-only HEAD~1"
watch:
- path:
- deploy/kubernetes/*
- version/docs/version.asciidoc
config:
label: "Sync K8s"
command: ".buildkite/scripts/steps/sync-k8s.sh"
agents:
provider: "gcp"
image: "family/core-ubuntu-2204"
env:
- GH_VERSION=2.4.0
# - label: "Trigger k8s sync"
# branches: main
# plugins:
# - monebag/monorepo-diff#v2.5.9:
# diff: "git diff --name-only HEAD~1"
# watch:
# - path:
# - deploy/kubernetes/*
# - version/docs/version.asciidoc
# config:
# label: "Sync K8s"
# command: ".buildkite/scripts/steps/sync-k8s.sh"
# agents:
# provider: "gcp"
# image: "family/core-ubuntu-2204"
# env:
# - GH_VERSION=2.4.0
35 changes: 35 additions & 0 deletions .github/workflows/bump-agent-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
set -e

version_requirements=$(mage integration:updateVersions)
changes=$(git status -s -uno .agent-versions.json)
if [ -z "$changes" ]
then
echo "The versions file didn't change, skipping..."
else
echo "The versions file changed"
open=$(gh pr list --repo "$GITHUB_REPOSITORY" --label="update-versions" --limit 1 --state open --base "$GITHUB_REF_NAME")
if [ -n "$open" ]
then
echo "Another PR for $GITHUB_REF_NAME is in review, skipping..."
exit 0
fi
git diff -p
git add ".agent-versions.json"

nl=$'\n' # otherwise the new line character is not recognized properly
commit_desc="This file is used for picking agent versions in integration tests.${nl}${nl}The file's content is based on responses from https://www.elastic.co/api/product_versions and https://snapshots.elastic.co${nl}${nl}The current update is generated based on the following requirements:${nl}${nl}\`\`\`json${nl}${version_requirements}${nl}\`\`\`"

git commit -m "[$GITHUB_REF_NAME][Automation] Update .agent-versions.json" -m "$commit_desc"
git push --set-upstream origin "update-agent-versions-$GITHUB_RUN_ID"
gh pr create \
--base "$GITHUB_REF_NAME" \
--fill-first \
--head "update-agent-versions-$GITHUB_RUN_ID" \
--label 'Team:Elastic-Agent' \
--label 'update-versions' \
--label 'skip-changelog' \
--label 'backport-skip' \
--repo $GITHUB_REPOSITORY
echo "::set-output name=pr::true" # set step output for notifications
fi
70 changes: 37 additions & 33 deletions .github/workflows/bump-agent-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,21 @@ jobs:
update_versions:
runs-on: ubuntu-latest
steps:
- name: Setup Git
uses: elastic/apm-pipeline-library/.github/actions/setup-git@current

- uses: elastic/apm-pipeline-library/.github/actions/github-token@current
with:
url: ${{ secrets.VAULT_ADDR }}
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}

- 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
Expand All @@ -20,41 +33,32 @@ 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
id: update
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
changes=$(git status -s -uno .agent-versions.json)
if [ -z "$changes" ]
then
echo "The versions file didn't change, skipping..."
else
echo "The versions file changed"
open=$(gh pr list --repo "$GITHUB_REPOSITORY" --label="update-versions" --limit 1 --state open --base "$GITHUB_REF_NAME")
if [ -n "$open" ]
then
echo "Another PR for $GITHUB_REF_NAME is in review, skipping..."
exit 0
fi
git diff -p
git config --global user.name 'apmmachine'
git config --global user.email '[email protected]'
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 push --set-upstream origin "update-agent-versions-$GITHUB_RUN_ID"
gh pr create \
--base "$GITHUB_REF_NAME" \
--fill-first \
--head "update-agent-versions-$GITHUB_RUN_ID" \
--label 'Team:Elastic-Agent' \
--label 'update-versions' \
--label 'skip-changelog' \
--label 'backport-skip' \
--repo $GITHUB_REPOSITORY
fi
GH_TOKEN: ${{ env.GITHUB_TOKEN }}
run: ./.github/workflows/bump-agent-versions.sh

- if: ${{ failure() }}
uses: elastic/apm-pipeline-library/.github/actions/slack-message@current
with:
url: ${{ secrets.VAULT_ADDR }}
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}
message: ":traffic_cone: Elastic Agent versions file update failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
channel: "#ingest-notifications"

- if: ${{ success() && steps.update.output.pr == true}}
uses: elastic/apm-pipeline-library/.github/actions/slack-message@current
with:
url: ${{ secrets.VAULT_ADDR }}
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}
message: "Update for Elastic Agent versions file has been created https://github.com/elastic/elastic-agent/pulls?q=is%3Aopen+is%3Apr+label%3Aupdate-versions"
channel: "#ingest-notifications"
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.21.8
1.21.9
8 changes: 4 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ linters-settings:

gosimple:
# Select the Go version to target. The default is '1.13'.
go: "1.21.8"
go: "1.21.9"

nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
Expand All @@ -136,17 +136,17 @@ linters-settings:

staticcheck:
# Select the Go version to target. The default is '1.13'.
go: "1.21.8"
go: "1.21.9"
checks: ["all"]

stylecheck:
# Select the Go version to target. The default is '1.13'.
go: "1.21.8"
go: "1.21.9"
checks: ["all"]

unused:
# Select the Go version to target. The default is '1.13'.
go: "1.21.8"
go: "1.21.9"

gosec:
excludes:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GO_VERSION=1.21.8
ARG GO_VERSION=1.21.9
FROM circleci/golang:${GO_VERSION}


Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.skaffold
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GO_VERSION=1.21.8
ARG GO_VERSION=1.21.9
ARG crossbuild_image="docker.elastic.co/beats-dev/golang-crossbuild"
ARG AGENT_VERSION=8.9.0-SNAPSHOT
ARG AGENT_IMAGE="docker.elastic.co/beats/elastic-agent"
Expand Down
Loading

0 comments on commit 31b12b8

Please sign in to comment.