Skip to content

Commit

Permalink
try composite actions
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Terzolo <[email protected]>
  • Loading branch information
Andreagit97 committed Jul 14, 2024
1 parent 411a1ec commit 6a020bc
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 21 deletions.
22 changes: 22 additions & 0 deletions .github/actions/setup-env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Setup Environment"
description: "Installs dependencies and go code"
inputs:
# Define any inputs if needed
runs:
using: "composite"
steps:
- name: Install deps
run: |
sudo apt update -y
sudo apt install -y --no-install-recommends build-essential git clang llvm libelf-dev libbpf-dev
- name: Checkout commit
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: "go.mod"
check-latest: true
50 changes: 29 additions & 21 deletions .github/workflows/build_test.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
name: Build and test

on:
pull_request:
push:
branches:
- main

jobs:
build_and_test:
runs-on: ubuntu-24.04
steps:
- name: Install deps
run: |
sudo apt update -y
sudo apt install -y --no-install-recommends build-essential git clang llvm libelf-dev libbpf-dev
- name: Setup Environment
uses: ./.github/actions/setup-env

- name: Checkout commit
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
fetch-depth: 0
# - name: Install deps
# run: |
# sudo apt update -y
# sudo apt install -y --no-install-recommends build-essential git clang llvm libelf-dev libbpf-dev

- name: Setup Go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
check-latest: true
# - name: Checkout commit
# uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
# with:
# fetch-depth: 0

# - name: Setup Go
# uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
# with:
# go-version-file: "go.mod"
# check-latest: true

- name: Build
run: |
Expand All @@ -34,30 +35,37 @@ jobs:
- name: Run tests
run: |
sudo -E env "PATH=$PATH" go test ./... -count=1
# use goreleaser to build all supported archs
upload_dev_artifacts:
needs: build_and_test
runs-on: ubuntu-24.04
steps:
- name: Setup Environment
uses: ./.github/actions/setup-env

# use goreleaser to build all supported archs
- name: Build all supported archs
id: run-goreleaser
uses: goreleaser/goreleaser-action@5742e2a039330cbb23ebf35f046f814d4c6ff811 # v5.1.0
with:
distribution: goreleaser
version: latest
args: release --snapshot --clean

- name: Archive x86_64 tar.gz
uses: actions/upload-artifact@v3
with:
name: x86_64
path: ./dist/bpftree_Linux_x86_64.tar.gz
path: ./dist/bpftree_Linux_x86_64.tar.gz

- name: Archive arm64 tar.gz
uses: actions/upload-artifact@v3
with:
name: arm64
path: ./dist/bpftree_Linux_arm64.tar.gz
path: ./dist/bpftree_Linux_arm64.tar.gz

- name: Archive s390x tar.gz
uses: actions/upload-artifact@v3
with:
name: s390x
path: ./dist/bpftree_Linux_s390x.tar.gz
path: ./dist/bpftree_Linux_s390x.tar.gz

0 comments on commit 6a020bc

Please sign in to comment.