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

Shellcheck #2825

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 85 additions & 76 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,87 +4,96 @@ agents:
queue: agent-runners-linux-amd64

steps:
- name: ":go::robot_face: Check Code Committed"
key: check-code-committed
command: .buildkite/steps/check-code-committed.sh
plugins:
- docker-compose#v4.14.0:
config: .buildkite/docker-compose.yml
cli-version: 2
run: agent
- group: "🧪 Tests and Checks ✅"
steps:
- name: ":go::robot_face: Check Code Committed"
key: check-code-committed
command: .buildkite/steps/check-code-committed.sh
plugins:
- docker-compose#v4.14.0:
config: .buildkite/docker-compose.yml
cli-version: 2
run: agent

- name: ":linux: Linux AMD64 Tests"
key: test-linux-amd64
command: ".buildkite/steps/tests.sh"
artifact_paths: junit-*.xml
plugins:
- docker-compose#v4.14.0:
config: .buildkite/docker-compose.yml
cli-version: 2
run: agent
- test-collector#v1.2.0:
files: "junit-*.xml"
format: "junit"
- artifacts#v1.9.0:
upload: "cover.{html,out}"
- name: "🐢🔎 Shellcheck"
key: shellcheck
command: .buildkite/steps/shellcheck.sh
plugins:
- docker#v5.8.0:
image: koalaman/shellcheck-alpine

- name: ":linux: Linux ARM64 Tests"
key: test-linux-arm64
command: ".buildkite/steps/tests.sh"
artifact_paths: junit-*.xml
agents:
queue: agent-runners-linux-arm64
plugins:
- docker-compose#v4.14.0:
config: .buildkite/docker-compose.yml
cli-version: 2
run: agent
- test-collector#v1.2.0:
files: "junit-*.xml"
format: "junit"
- artifacts#v1.9.0:
upload: "cover.{html,out}"
- name: ":linux: Linux AMD64 Tests"
key: test-linux-amd64
command: ".buildkite/steps/tests.sh"
artifact_paths: junit-*.xml
plugins:
- docker-compose#v4.14.0:
config: .buildkite/docker-compose.yml
cli-version: 2
run: agent
- test-collector#v1.2.0:
files: "junit-*.xml"
format: "junit"
- artifacts#v1.9.0:
upload: "cover.{html,out}"

- name: ":satellite: Detect Data Races"
key: test-race-linux-arm64
command: ".buildkite/steps/tests.sh -race"
artifact_paths: junit-*.xml
agents:
queue: agent-runners-linux-arm64
plugins:
- docker-compose#v4.14.0:
config: .buildkite/docker-compose.yml
cli-version: 2
run: agent
- test-collector#v1.2.0:
files: "junit-*.xml"
format: "junit"
- artifacts#v1.9.0:
upload: "cover.{html,out}"
- name: ":linux: Linux ARM64 Tests"
key: test-linux-arm64
command: ".buildkite/steps/tests.sh"
artifact_paths: junit-*.xml
agents:
queue: agent-runners-linux-arm64
plugins:
- docker-compose#v4.14.0:
config: .buildkite/docker-compose.yml
cli-version: 2
run: agent
- test-collector#v1.2.0:
files: "junit-*.xml"
format: "junit"
- artifacts#v1.9.0:
upload: "cover.{html,out}"

- name: ":windows: Windows AMD64 Tests"
key: test-windows
command: "bash .buildkite\\steps\\tests.sh"
artifact_paths: junit-*.xml
agents:
queue: agent-runners-windows-amd64
plugins:
- test-collector#v1.2.0:
files: "junit-*.xml"
format: "junit"
- artifacts#v1.9.0:
upload: "cover.{html,out}"
- name: ":satellite: Detect Data Races"
key: test-race-linux-arm64
command: ".buildkite/steps/tests.sh -race"
artifact_paths: junit-*.xml
agents:
queue: agent-runners-linux-arm64
plugins:
- docker-compose#v4.14.0:
config: .buildkite/docker-compose.yml
cli-version: 2
run: agent
- test-collector#v1.2.0:
files: "junit-*.xml"
format: "junit"
- artifacts#v1.9.0:
upload: "cover.{html,out}"

- label: ":writing_hand: Annotate with Test Failures"
depends_on:
- test-linux-amd64
- test-race-linux-arm64
- test-linux-arm64
- test-windows
allow_dependency_failure: true
plugins:
- junit-annotate#v1.6.0:
artifacts: junit-*.xml
- name: ":windows: Windows AMD64 Tests"
key: test-windows
command: "bash .buildkite\\steps\\tests.sh"
artifact_paths: junit-*.xml
agents:
queue: agent-runners-windows-amd64
plugins:
- test-collector#v1.2.0:
files: "junit-*.xml"
format: "junit"
- artifacts#v1.9.0:
upload: "cover.{html,out}"

- label: ":writing_hand: Annotate with Test Failures"
depends_on:
- test-linux-amd64
- test-race-linux-arm64
- test-linux-arm64
- test-windows
allow_dependency_failure: true
plugins:
- junit-annotate#v1.6.0:
artifacts: junit-*.xml

- group: ":hammer_and_wrench: Binary builds"
steps:
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/steps/build-binary.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

Expand Down
2 changes: 1 addition & 1 deletion .buildkite/steps/build-debian-packages.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

echo "--- Getting agent version from build meta data"
Expand Down
17 changes: 11 additions & 6 deletions .buildkite/steps/build-github-release.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#!/bin/bash
#!/usr/bin/env bash
set -e

echo '--- Getting agent version from build meta data'

export FULL_AGENT_VERSION=$(buildkite-agent meta-data get "agent-version-full")
export AGENT_VERSION=$(buildkite-agent meta-data get "agent-version")
export BUILD_VERSION=$(buildkite-agent meta-data get "agent-version-build")
FULL_AGENT_VERSION=$(buildkite-agent meta-data get "agent-version-full")
export FULL_AGENT_VERSION

AGENT_VERSION=$(buildkite-agent meta-data get "agent-version")
export AGENT_VERSION

BUILD_VERSION=$(buildkite-agent meta-data get "agent-version-build")
export BUILD_VERSION

echo "Full agent version: $FULL_AGENT_VERSION"
echo "Agent version: $AGENT_VERSION"
Expand All @@ -20,7 +25,7 @@ buildkite-agent artifact download "pkg/*" .
function build() {
echo "--- Building release for: $1"

./scripts/build-github-release.sh $1 $AGENT_VERSION
./scripts/build-github-release.sh "$1" "$AGENT_VERSION"
}

# Export the function so we can use it in xargs
Expand All @@ -30,4 +35,4 @@ export -f build
rm -rf releases

# Loop over all the binaries and build them
ls pkg/* | xargs -I {} bash -c "build {}"
find pkg/* -print0 | xargs -I {} bash -c "build {}"
13 changes: 9 additions & 4 deletions .buildkite/steps/build-rpm-packages.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

echo "--- Getting agent version from build meta data"

export FULL_AGENT_VERSION=$(buildkite-agent meta-data get "agent-version-full")
export AGENT_VERSION=$(buildkite-agent meta-data get "agent-version")
export BUILD_VERSION=$(buildkite-agent meta-data get "agent-version-build")
FULL_AGENT_VERSION=$(buildkite-agent meta-data get "agent-version-full")
export FULL_AGENT_VERSION

AGENT_VERSION=$(buildkite-agent meta-data get "agent-version")
export AGENT_VERSION

BUILD_VERSION=$(buildkite-agent meta-data get "agent-version-build")
export BUILD_VERSION

echo "Full agent version: $FULL_AGENT_VERSION"
echo "Agent version: $AGENT_VERSION"
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/steps/check-changelog.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

Expand Down
2 changes: 1 addition & 1 deletion .buildkite/steps/extract-agent-version-metadata.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

agent_version=$(cat version/VERSION)
Expand Down
20 changes: 14 additions & 6 deletions .buildkite/steps/github-release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e

dry_run() {
Expand All @@ -10,7 +10,8 @@ dry_run() {
}

echo '--- Getting credentials from SSM'
export GITHUB_RELEASE_ACCESS_TOKEN=$(aws ssm get-parameter --name /pipelines/agent/GITHUB_RELEASE_ACCESS_TOKEN --with-decryption --output text --query Parameter.Value --region us-east-1)
GITHUB_RELEASE_ACCESS_TOKEN=$(aws ssm get-parameter --name /pipelines/agent/GITHUB_RELEASE_ACCESS_TOKEN --with-decryption --output text --query Parameter.Value --region us-east-1)
export GITHUB_RELEASE_ACCESS_TOKEN

if [[ "$GITHUB_RELEASE_ACCESS_TOKEN" == "" ]]; then
echo "Error: Missing \$GITHUB_RELEASE_ACCESS_TOKEN"
Expand All @@ -19,10 +20,17 @@ fi

echo '--- Getting agent version from build meta data'

export FULL_AGENT_VERSION=$(buildkite-agent meta-data get "agent-version-full")
export AGENT_VERSION=$(buildkite-agent meta-data get "agent-version")
export BUILD_VERSION=$(buildkite-agent meta-data get "agent-version-build")
export IS_PRERELEASE=$(buildkite-agent meta-data get "agent-is-prerelease")
FULL_AGENT_VERSION=$(buildkite-agent meta-data get "agent-version-full")
export FULL_AGENT_VERSION

AGENT_VERSION=$(buildkite-agent meta-data get "agent-version")
export AGENT_VERSION

BUILD_VERSION=$(buildkite-agent meta-data get "agent-version-build")
export BUILD_VERSION

IS_PRERELEASE=$(buildkite-agent meta-data get "agent-is-prerelease")
export IS_PRERELEASE

echo "Full agent version: $FULL_AGENT_VERSION"
echo "Agent version: $AGENT_VERSION"
Expand Down
5 changes: 3 additions & 2 deletions .buildkite/steps/publish-debian-package.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

artifacts_build=$(buildkite-agent meta-data get "agent-artifacts-build" )
Expand All @@ -24,7 +24,8 @@ if ! findmnt --source tmpfs --target /root/.gnupg; then
fi

echo "fetching signing key..."
export GPG_SIGNING_KEY=$(aws ssm get-parameter --name /pipelines/agent/GPG_SIGNING_KEY --with-decryption --output text --query Parameter.Value --region us-east-1)
GPG_SIGNING_KEY=$(aws ssm get-parameter --name /pipelines/agent/GPG_SIGNING_KEY --with-decryption --output text --query Parameter.Value --region us-east-1)
export GPG_SIGNING_KEY

echo "fetching secret key..."
aws ssm get-parameter --name /pipelines/agent/GPG_SECRET_KEY_ASCII --with-decryption --output text --query Parameter.Value --region us-east-1 > ${secret_key_path}
Expand Down
5 changes: 3 additions & 2 deletions .buildkite/steps/publish-debian-packagecloud.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

artifacts_build="$(buildkite-agent meta-data get "agent-artifacts-build")"
Expand Down Expand Up @@ -32,7 +32,8 @@ echo "--- Installing dependencies"
gem install package_cloud

echo "--- Requesting OIDC token"
export PACKAGECLOUD_TOKEN="$(buildkite-agent oidc request-token --audience "https://packagecloud.io/${REPOSITORY}" --lifetime 300)"
PACKAGECLOUD_TOKEN="$(buildkite-agent oidc request-token --audience "https://packagecloud.io/${REPOSITORY}" --lifetime 300)"
export PACKAGECLOUD_TOKEN

echo "--- Pushing to Packagecloud"
dry_run package_cloud push "${REPOSITORY}/${DISTRO_VERSION}" deb/*.deb
4 changes: 2 additions & 2 deletions .buildkite/steps/publish-docker-image.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

## This script can be run locally like this:
Expand Down Expand Up @@ -28,7 +28,7 @@ parse_version() {
IFS='.' read -r -a parts <<< "${v%-*}"

for idx in $(seq 1 ${#parts[*]}) ; do
sed -e 's/ /./g' <<< "${parts[@]:0:$idx}"
sed -e 's/ /./g' <<< "${parts[@]:0:$idx// /.}"
done

[[ "${v%-*}" == "$v" ]] || echo "$v"
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/steps/publish-docker-images.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

dry_run() {
Expand Down
6 changes: 3 additions & 3 deletions .buildkite/steps/publish-rpm-package.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

artifacts_build="$(buildkite-agent meta-data get "agent-artifacts-build")"
Expand Down Expand Up @@ -82,7 +82,7 @@ for ARCH in "x86_64" "i386" "aarch64"; do
"${ARCH_PATH}/repodata"

# Copy the new RPMs in.
find "rpm/" -type f -name "*${ARCH}*" | xargs cp -t "${ARCH_PATH}"
find "rpm/" -type f -name "*${ARCH}*" -print0 | xargs cp -t "${ARCH_PATH}"

echo "--- Updating yum repository for ${CODENAME}/${ARCH}"
if updaterepo "${ARCH_PATH}"; then
Expand All @@ -99,7 +99,7 @@ for ARCH in "x86_64" "i386" "aarch64"; do
"${ARCH_PATH}"

# Copy the new RPMs in again.
find "rpm/" -type f -name "*${ARCH}*" | xargs cp -t "${ARCH_PATH}"
find "rpm/" -type f -name "*${ARCH}*" -print0 | xargs cp -t "${ARCH_PATH}"

echo "--- Recreating yum repository for ${CODENAME}/${ARCH}"
createrepo "${ARCH_PATH}"
Expand Down
5 changes: 3 additions & 2 deletions .buildkite/steps/publish-rpm-packagecloud.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -euo pipefail

artifacts_build="$(buildkite-agent meta-data get "agent-artifacts-build")"
Expand Down Expand Up @@ -32,7 +32,8 @@ echo "--- Installing dependencies"
gem install package_cloud

echo "--- Requesting OIDC token"
export PACKAGECLOUD_TOKEN="$(buildkite-agent oidc request-token --audience "https://packagecloud.io/${REPOSITORY}" --lifetime 300)"
PACKAGECLOUD_TOKEN="$(buildkite-agent oidc request-token --audience "https://packagecloud.io/${REPOSITORY}" --lifetime 300)"
export PACKAGECLOUD_TOKEN

echo "--- Pushing to Packagecloud"
dry_run package_cloud push "${REPOSITORY}/${DISTRO_VERSION}" rpm/*.rpm
Loading