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

Testing a Drone to GitHub Actions migration #2462

Draft
wants to merge 6 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
165 changes: 165 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
name: Build
on:
pull_request:
concurrency:
# Cancel any running workflow for the same branch when new commits are pushed.
# We group both by ref_name (available when CI is triggered by a push to a branch/tag)
# and head_ref (available when CI is triggered by a PR).
group: "${{ github.ref_name }}-${{ github.head_ref }}"
cancel-in-progress: true
jobs:
setup_environment:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- name: Cache Go
id: go_cache
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install dependencies
if: steps.go_cache.outputs.cache-hit != 'true'
run: go mod download

build_linux:
name: Build on Linux
needs: [setup_environment]
runs-on: ubuntu-latest
container: grafana/alloy-build-image:v0.1.8
strategy:
matrix:
os: [linux]
arch: [amd64, arm64, ppc64le, s390x]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set ownership
# https://github.com/actions/runner/issues/2033#issuecomment-1204205989
run: |
# this is to fix GIT not liking owner of the checkout dir
chown -R $(id -u):$(id -g) $PWD
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- name: Cache Go
id: go-cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- run: make generate-ui
- run: GO_TAGS="builtinassets promtail_journal_enabled" GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} GOARM= make alloy

build_linux_boringcrypto:
name: Build on Linux (boringcrypto)
needs: [setup_environment]
runs-on: ubuntu-latest
container: grafana/alloy-build-image:v0.1.8-boringcrypto
strategy:
matrix:
os: [linux]
arch: [amd64, arm64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set ownership
# https://github.com/actions/runner/issues/2033#issuecomment-1204205989
run: |
# this is to fix GIT not liking owner of the checkout dir
chown -R $(id -u):$(id -g) $PWD
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- name: Cache Go
id: go-cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- run: make generate-ui
- run: GO_TAGS="builtinassets promtail_journal_enabled" GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} GOARM= GOEXPERIMENT=boringcrypto make alloy

build_mac_intel:
name: Build on MacOS (Intel)
runs-on: macos-14-large
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- run: make generate-ui
- run: GO_TAGS="builtinassets" GOOS=darwin GOARCH=amd64 GOARM= make alloy

build_mac_arm:
name: Build on MacOS (ARM)
runs-on: macos-14-xlarge
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- run: make generate-ui
- run: GO_TAGS="builtinassets" GOOS=darwin GOARCH=arm64 GOARM= make alloy

build_windows:
name: Build on Windows (AMD64)
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- run: make generate-ui
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable
- run: echo "GO_TAGS=builtinassets" | Out-File -FilePath $env:GITHUB_ENV -Append
- run: echo "GOOS=windows" | Out-File -FilePath $env:GITHUB_ENV -Append
- run: echo "GOARCH=amd64" | Out-File -FilePath $env:GITHUB_ENV -Append
- run: make alloy

build_freebsd:
name: Build on FreeBSD (AMD64)
runs-on: ubuntu-latest
container: grafana/alloy-build-image:v0.1.8
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set ownership
# https://github.com/actions/runner/issues/2033#issuecomment-1204205989
run: |
# this is to fix GIT not liking owner of the checkout dir
chown -R $(id -u):$(id -g) $PWD
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- run: make generate-ui
- run: GO_TAGS="builtinassets" GOOS=freebsd GOARCH=amd64 GOARM= make alloy
41 changes: 41 additions & 0 deletions .github/workflows/create_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Create Docker images
on:
push:
tags:
- build-image/v*

jobs:
test_linux_system_packages:
name: Test Linux system packages
runs-on:
labels: github-hosted-ubuntu-x64-small
container:
image: grafana/alloy-build-image:v0.1.8
volumes:
- /var/run/docker.sock
steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Split tag name
env:
FULL_TAG: ${{ github.ref_name }}
id: split_tag
run: echo "image_version=${FULL_TAG##*/}" >> $GITHUB_OUTPUT

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}

- run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name multiarch --driver docker-container --use
docker buildx build --build-arg="GO_RUNTIME=golang:1.23.5-bullseye" --push --platform linux/amd64,linux/arm64 -t ptodev/alloy-build-image:${{ steps.split_tag.outputs.image_version }} ./tools/build-image
15 changes: 15 additions & 0 deletions .github/workflows/test_dockerhub_login.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Test logging in to DockerHub
on:
pull_request:

# permissions:
# contents: read
# id-token: write

jobs:
test_linux:
name: Test login
runs-on: ubuntu-latest
steps:
- name: Login to DockerHub (from vault)
uses: grafana/shared-workflows/actions/[email protected]
30 changes: 30 additions & 0 deletions .github/workflows/test_full.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test (Full)
on:
push:
branches:
- main
# TODO: Remove this later
pull_request:
jobs:
test_linux:
name: Test (Full)
runs-on: ubuntu-latest
container:
image: grafana/alloy-build-image:v0.1.8
volumes:
- /var/run/docker.sock
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set ownership
# https://github.com/actions/runner/issues/2033#issuecomment-1204205989
run: |
# this is to fix GIT not liking owner of the checkout dir
chown -R $(id -u):$(id -g) $PWD
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
# TODO: Enable caching later.
cache: false
- run: K8S_USE_DOCKER_NETWORK=1 make test
35 changes: 35 additions & 0 deletions .github/workflows/test_linux_system_packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test Linux system packages
on:
push:
branches:
- main
paths:
- packaging/**
- internal/tools/packaging_test/**
- Makefile
- tools/make/*.mk
# TODO: Remove this later
pull_request:
jobs:
test_linux_system_packages:
name: Test Linux system packages
runs-on: ubuntu-latest
container:
image: grafana/alloy-build-image:v0.1.8
volumes:
- /var/run/docker.sock
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set ownership
# https://github.com/actions/runner/issues/2033#issuecomment-1204205989
run: |
# this is to fix GIT not liking owner of the checkout dir
chown -R $(id -u):$(id -g) $PWD
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- run: DOCKER_OPTS="" make dist/alloy-linux-amd64
- run: DOCKER_OPTS="" make test-packages
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Test (Mac)
on:
# Run tests on main just so the module and build cache can be saved and used
# in PRs. This speeds up the time it takes to test PRs dramatically.
Expand All @@ -9,7 +9,7 @@ on:
pull_request:
jobs:
test:
name: Test
name: Test (Mac)
strategy:
matrix:
platform: [macos-latest-xlarge]
Expand All @@ -23,4 +23,4 @@ jobs:
go-version: "1.23"
cache: true
- name: Test
run: CGO_LDFLAGS="-ld_classic $CGO_LDFLAGS" make GO_TAGS="nodocker" test
run: CGO_LDFLAGS="-ld_classic $CGO_LDFLAGS" make GO_TAGS="nodocker" test
31 changes: 31 additions & 0 deletions .github/workflows/test_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test
on:
pull_request:
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go 1.23
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- run: sudo apt-get update -y && sudo apt-get install -y libsystemd-dev
- run: make lint

test_linux:
name: Test Linux
runs-on: ubuntu-latest
container: grafana/alloy-build-image:v0.1.8
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go 1.23
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- run: make GO_TAGS="nodocker" test
28 changes: 28 additions & 0 deletions .github/workflows/test_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test (Windows)
on:
# TODO: Run the Windows tests for each PR?
# For now we don't do it just because it takes time.
push:
# TODO: Also run the tests when a Windows-specific features is changed.
# For example, the Windows Exporter for Prometheus and Event Log tailers.
branches:
- main
# TODO: Remove this before merging!!!!!!!!!!!!!!!
pull_request:
jobs:
test_windows:
name: Test (Windows)
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go 1.23
uses: actions/setup-go@v5
with:
go-version-file: go.mod
# TODO: Enable caching later.
# We'll need to make sure the same cache is reused by the workflow to build Windows binaries.
cache: false
- name: Test
run: '& "C:/Program Files/git/bin/bash.exe" -c ''go test -tags="nodocker,nonetwork"
./...'''
Loading