Skip to content

Testing the Drone to GitHub Actions migration #383

Testing the Drone to GitHub Actions migration

Testing the Drone to GitHub Actions migration #383

Workflow file for this run

name: Build and test
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 code
uses: actions/checkout@v4
- name: Set up Go 1.23
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- name: Cache Go
id: go-cache
uses: actions/[email protected]
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Log cache miss
if: steps.go-cache.outputs.cache-hit != 'true'
run: echo "Cache was not hit"
- name: Log cache hit
if: steps.go-cache.outputs.cache-hit == 'true'
run: echo "Cache was hit"
lint:
name: Lint
runs-on: ubuntu-latest
needs: setup-environment
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: Cache Go
id: go-cache
uses: actions/[email protected]
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Log cache miss
if: steps.go-cache.outputs.cache-hit != 'true'
run: echo "Cache was not hit"
- name: Log cache hit
if: steps.go-cache.outputs.cache-hit == 'true'
run: echo "Cache was hit"
- 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
needs: setup-environment
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
- name: Cache Go
id: go-cache
uses: actions/[email protected]
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Log cache miss
if: steps.go-cache.outputs.cache-hit != 'true'
run: echo "Cache was not hit"
- name: Log cache hit
if: steps.go-cache.outputs.cache-hit == 'true'
run: echo "Cache was hit"
- run: make GO_TAGS="nodocker" test
build_linux:
name: Build on Linux
runs-on: ubuntu-latest
needs: setup-environment
container: grafana/alloy-build-image:v0.1.8
strategy:
matrix:
os: [linux]
arch: [amd64, arm64, ppc64le, s390x]
steps:
- name: Install zstd
run: |
apt-get update
apt-get install zstd
- 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/[email protected]
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Log cache miss
if: steps.go-cache.outputs.cache-hit != 'true'
run: echo "Cache was not hit"
- name: Log cache hit
if: steps.go-cache.outputs.cache-hit == 'true'
run: echo "Cache was hit"
- 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)
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
# TODO: Try enabling caching later. It might use up too much disk space on runners so needs extra testing.
cache: false
- 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
needs: setup-environment
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: Cache Go
id: go-cache
uses: actions/[email protected]
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Log cache miss
if: steps.go-cache.outputs.cache-hit != 'true'
run: echo "Cache was not hit"
- name: Log cache hit
if: steps.go-cache.outputs.cache-hit == 'true'
run: echo "Cache was hit"
- 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
# TODO: Try enabling caching later. It might use up too much disk space on runners so needs extra testing.
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
# TODO: Try enabling caching later. It might use up too much disk space on runners so needs extra testing.
cache: false
- run: make generate-ui
- 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
# TODO: Try enabling caching later. It might use up too much disk space on runners so needs extra testing.
cache: false
- run: make generate-ui
- run: GO_TAGS="builtinassets" GOOS=freebsd GOARCH=amd64 GOARM= make alloy