From dd8e0469f981221285186a166b4ef4f251b2097a Mon Sep 17 00:00:00 2001 From: Andrea Terzolo Date: Sun, 14 Jul 2024 18:50:52 +0200 Subject: [PATCH] try composite actions Signed-off-by: Andrea Terzolo --- .github/actions/setup-env/action.yaml | 15 +++++++++++ .github/workflows/build_test.yaml | 38 ++++++++++++++------------- 2 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 .github/actions/setup-env/action.yaml diff --git a/.github/actions/setup-env/action.yaml b/.github/actions/setup-env/action.yaml new file mode 100644 index 0000000..f8298b4 --- /dev/null +++ b/.github/actions/setup-env/action.yaml @@ -0,0 +1,15 @@ +name: "Setup Environment" +description: "Installs dependencies and go code" +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: Setup Go + uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + with: + go-version-file: "go.mod" + check-latest: true diff --git a/.github/workflows/build_test.yaml b/.github/workflows/build_test.yaml index 7b6fd9a..dbf864e 100644 --- a/.github/workflows/build_test.yaml +++ b/.github/workflows/build_test.yaml @@ -1,30 +1,20 @@ 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: 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: Setup Environment + uses: ./.github/actions/setup-env - name: Build run: | @@ -34,8 +24,20 @@ 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: Checkout commit + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + with: + fetch-depth: 0 + + - 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 @@ -43,21 +45,21 @@ jobs: 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