Skip to content

Convert Drone jobs to GH workflows (part 1) #7153

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

Draft
wants to merge 20 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
12 changes: 6 additions & 6 deletions .github/workflows/check-linux-build-image.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Check Linux build image

on:
pull_request:
paths:
- 'build-image/*'
workflow_call:

permissions:
contents: read
Expand All @@ -23,20 +21,22 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3

- name: Create test Linux build image
- name: Check Linux build image
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6
with:
context: ./build-image
push: false
tags: grafana/agent-build-image:latest
platforms: 'linux/amd64,linux/arm64'
build-args: |
GO_RUNTIME=golang:1.24.2-bullseye

- name: Create test Linux build image for boring crypto
- name: Check Linux boringcrypto build image
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6
with:
context: ./build-image
push: false
push: ${{ env.should_push_image == 'true' }}
tags: grafana/agent-build-image:latest
platforms: 'linux/amd64,linux/arm64'
build-args: |
GO_RUNTIME=mcr.microsoft.com/oss/go/microsoft/golang:1.24.2-bullseye
8 changes: 3 additions & 5 deletions .github/workflows/check-windows-build-image.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Check Windows build image

on:
pull_request:
paths:
- 'build-image/windows/**'
workflow_call:

permissions:
contents: read
Expand All @@ -17,11 +15,11 @@ jobs:
with:
persist-credentials: false

- name: Create test Windows build image
- name: Check Windows build image
uses: mr-smithers-excellent/docker-build-push@59523c638baec979a74fea99caa9e29d97e5963c # v6
with:
image: grafana/agent-build-image
tags: latest
tags: latest-windows
registry: docker.io
pushImage: false
dockerfile: ./build-image/windows/Dockerfile
109 changes: 109 additions & 0 deletions .github/workflows/crosscompile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Crosscompile

on:
push:
branches:
- main
workflow_call:
inputs:
build_image_version:
description: 'Version of the grafana/agent-build-image to use'
required: false
type: string
default: '0.44.2' # TODO: update to 0.44.3 once available

permissions:
contents: read

jobs:
# Mainline crosscompile matrix (M x N: targets x platforms)
crosscompile:
name: Build ${{ matrix.target }} (${{ matrix.platform.os }} ${{ matrix.platform.arch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [agent, agent-flow, agentctl, operator]
platform:
- {os: linux, arch: amd64}
- {os: linux, arch: arm64}
- {os: linux, arch: ppc64le}
- {os: linux, arch: s390x}
- {os: darwin, arch: amd64}
- {os: darwin, arch: arm64}
- {os: windows, arch: amd64}
- {os: freebsd, arch: amd64}

container:
image: grafana/agent-build-image:${{ inputs.build_image_version }}

steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: Fix git permissions
run: git config --global --add safe.directory "${{ github.workspace }}"

- name: Build ${{ matrix.target }}
run: |
make generate-ui

# Set GO_TAGS based on OS
if [ "${{ matrix.platform.os }}" = "linux" ]; then
GO_TAGS="builtinassets promtail_journal_enabled"
else
GO_TAGS="builtinassets"
fi

GO_TAGS="$GO_TAGS" GOOS=${{ matrix.platform.os }} GOARCH=${{ matrix.platform.arch }} GOARM=${{ matrix.platform.goarm }} make ${{ matrix.target }}

# Boringcrypto variants
crosscompile-boringcrypto:
name: Build ${{ matrix.target }} (${{ matrix.os }} ${{ matrix.arch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: agent-boringcrypto
os: linux
arch: amd64
experiment: boringcrypto
image: grafana/agent-build-image:${{ inputs.build_image_version }}
- target: agent-boringcrypto
os: linux
arch: arm64
experiment: boringcrypto
image: grafana/agent-build-image:${{ inputs.build_image_version }}
- target: agent-flow-windows-boringcrypto
os: windows
arch: amd64
experiment: cngcrypto
image: grafana/agent-build-image:${{ inputs.build_image_version }}-boringcrypto

container:
image: ${{ matrix.image }}

steps:
- name: Checkout code 🛎️
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: Fix git permissions
run: git config --global --add safe.directory "${{ github.workspace }}"

- name: Build ${{ matrix.target }} 🏗️
run: |
make generate-ui

# Set GO_TAGS based on OS
if [ "${{ matrix.os }}" = "linux" ]; then
GO_TAGS="builtinassets promtail_journal_enabled"
else
GO_TAGS="builtinassets"
fi

GO_TAGS="$GO_TAGS" GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} GOARM=${{ matrix.goarm }} GOEXPERIMENT=${{ matrix.experiment }} make ${{ matrix.target }}
29 changes: 0 additions & 29 deletions .github/workflows/integration-tests.yml

This file was deleted.

63 changes: 63 additions & 0 deletions .github/workflows/pull-request-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Pull Request Checks

on:
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
changes:
runs-on: ubuntu-latest
outputs:
build-image: ${{ steps.changes.outputs.build-image }}
build-image-windows: ${{ steps.changes.outputs.build-image-windows }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Check for changes
id: changes
run: |
if git diff --name-only origin/${GITHUB_BASE_REF}...HEAD | grep -q '^build-image/'; then
echo "build-image=true" >> $GITHUB_OUTPUT
else
echo "build-image=false" >> $GITHUB_OUTPUT
fi

if git diff --name-only origin/${GITHUB_BASE_REF}...HEAD | grep -q '^build-image/windows/'; then
echo "build-image-windows=true" >> $GITHUB_OUTPUT
else
echo "build-image-windows=false" >> $GITHUB_OUTPUT
fi
env:
GITHUB_BASE_REF: ${{ github.base_ref }}

test:
uses: ./.github/workflows/test.yml

test-crds:
uses: ./.github/workflows/test-crds.yml

test-dashboards:
uses: ./.github/workflows/test-dashboards.yml

crosscompile:
uses: ./.github/workflows/crosscompile.yml

check-linux-build-image:
needs: changes
if: ${{ needs.changes.outputs.build-image == 'true' }}
uses: ./.github/workflows/check-linux-build-image.yml

check-windows-build-image:
needs: changes
if: ${{ needs.changes.outputs.build-image-windows == 'true' }}
uses: ./.github/workflows/check-windows-build-image.yml
29 changes: 29 additions & 0 deletions .github/workflows/test-crds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test CRDs

on:
workflow_call:

permissions:
contents: read

jobs:
test-crds:
name: Test CRDs
runs-on: ubuntu-latest
container:
# TODO: Keep this in sync with build-container.mk somehow
image: grafana/agent-build-image:0.44.2
steps:
- name: Checkout code 🛎️
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: Mark repository as safe 🔒
run: git status || git config --system --add safe.directory "$GITHUB_WORKSPACE"

- name: Regenerate CRDs 📋
run: |
make generate-crds
ERR_MSG="Custom Resource Definitions are out of date. Please run 'make generate-crds' and commit changes!"
if [ ! -z "$(git status --porcelain)" ]; then echo $ERR_MSG >&2; exit 1; fi
29 changes: 29 additions & 0 deletions .github/workflows/test-dashboards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test Dashboards

on:
workflow_call:

permissions:
contents: read

jobs:
test-dashboards:
name: Test Dashboards
runs-on: ubuntu-latest
container:
# TODO: Keep this in sync with build-container.mk somehow
image: grafana/agent-build-image:0.44.2
steps:
- name: Checkout code 🛎️
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: Mark repository as safe 🔒
run: git status || git config --system --add safe.directory "$GITHUB_WORKSPACE"

- name: Regenerate dashboards 📊
run: |
make generate-dashboards
ERR_MSG="Dashboard definitions are out of date. Please run 'make generate-dashboards' and commit changes!"
if [ ! -z "$(git status --porcelain)" ]; then echo $ERR_MSG >&2; exit 1; fi
48 changes: 39 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,55 @@ on:
push:
branches:
- main
pull_request:
workflow_call:

permissions:
contents: read

jobs:
test:
name: Test
strategy:
matrix:
platform: [macos-latest-xlarge]
platform: [ubuntu-latest, macos-latest-xlarge]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Checkout code 🛎️
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Set up Go 1.24
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5

- name: Set up Go ⚙️
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version: "1.24"
cache: true
- name: Test
go-version-file: go.mod
cache: false

- name: Set up Git user 🔒
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Run tests 🧪
run: make GO_TAGS="nodocker" test

integration-test:
name: Integration test
runs-on: github-hosted-ubuntu-x64-large
steps:
- name: Checkout code 🛎️
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: Set up Go ⚙️
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: go.mod
cache: false

- name: Set OTEL Exporter Endpoint 📡
run: echo "OTEL_EXPORTER_ENDPOINT=172.17.0.1:4318" >> $GITHUB_ENV

- name: Run integration tests 🧪
run: make integration-test
Loading
Loading