*: Update license header #6373
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Snap | |
on: | |
push: | |
branches: | |
- main | |
- release-* | |
pull_request: | |
branches: | |
- main | |
- release-* | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idconcurrency | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
env: | |
# renovate: datasource=go depName=github.com/goreleaser/goreleaser | |
GORELEASER_VERSION: v1.23.0 | |
permissions: | |
contents: write | |
jobs: | |
skip-check: | |
name: Skip check | |
continue-on-error: true | |
runs-on: ubuntu-latest | |
outputs: | |
should_skip: ${{ steps.skip-check.outputs.should_skip }} | |
permissions: | |
actions: write | |
contents: read | |
steps: | |
- id: skip-check | |
uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1 | |
with: | |
do_not_skip: '["schedule", "workflow_dispatch"]' | |
paths: |- | |
[ | |
"**.go", | |
".dockerignore", | |
".github/workflows/snap.yml", | |
".go-version", | |
"3rdparty", | |
"Dockerfile*", | |
"Makefile", | |
"bpf/Makefile", | |
"go.mod", | |
"go.sum" | |
] | |
skip_after_successful_duplicate: false | |
dependencies: | |
name: Build and download dependencies | |
needs: skip-check | |
if: ${{ needs.skip-check.outputs.should_skip != 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- name: Set up Clang | |
uses: KyleMayes/install-llvm-action@be40c5af3a4adc3e4a03199995ab73aa37536712 # v1.9.0 | |
with: | |
version: "14" | |
- name: Install libbpf dependencies | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -yq libelf-dev zlib1g-dev | |
- name: Initialize and update libbpf submodule | |
run: git submodule init && git submodule update | |
- name: Build BPF | |
run: | | |
make ARCH=amd64 bpf | |
make ARCH=arm64 bpf | |
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 | |
with: | |
name: ebpf-object-file-release | |
path: bpf/out | |
if-no-files-found: error | |
binaries: | |
name: Goreleaser release | |
runs-on: ubuntu-latest | |
needs: dependencies | |
container: | |
image: docker.io/goreleaser/goreleaser-cross:v1.21.5@sha256:3427076d3799c1cf4507f14c6f44f21de7c1ae598ebb7dcd14757959f246dedf | |
options: --privileged | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Check out the code | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
fetch-depth: 0 | |
# https://github.com/actions/checkout/issues/766 | |
- name: Add repository directory to the git global config as a safe directory | |
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}" | |
- name: Set Tag | |
run: | | |
echo "goreleaser_current_tag=`git describe --match 'v*' --tags`" >> $GITHUB_ENV | |
- name: Set up Go | |
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | |
with: | |
go-version-file: .go-version | |
- name: Fetch all tags | |
run: git fetch --force --tags | |
- name: Initialize and update libbpf submodule | |
run: git submodule init && git submodule update | |
- name: Install libbpf dependencies | |
run: | | |
apt-get update -y | |
apt-get install -yq lld libelf-dev zlib1g-dev libelf-dev:arm64 zlib1g-dev:arm64 pkg-config | |
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | |
with: | |
name: ebpf-object-file-release | |
path: bpf/out | |
- name: List downloaded files | |
shell: bash | |
run: | | |
ls -lR bpf | |
mkdir -p pkg/profiler/cpu/bpf/programs/objects | |
cp -r bpf/out/* pkg/profiler/cpu/bpf/programs/objects | |
rm pkg/profiler/cpu/bpf/programs/objects/*/pid_namespace.bpf.o | |
mkdir -p pkg/contained/bpf | |
cp -r bpf/out/* pkg/contained/bpf | |
find pkg/contained/bpf/*/ -type f | grep -v "pid_namespace.bpf.o" | xargs -I{} bash -c "rm {}" | |
- name: Run Goreleaser | |
run: goreleaser release --clean --debug --snapshot --skip-validate --skip-publish | |
env: | |
GORELEASER_CURRENT_TAG: "${{ env.goreleaser_current_tag }}" | |
- name: Archive generated artifacts | |
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 | |
with: | |
name: parca-agent-dist-release | |
if-no-files-found: error | |
path: | | |
goreleaser/dist | |
!goreleaser/dist/*.txt | |
snap: | |
name: Build Snap | |
runs-on: ubuntu-latest | |
needs: binaries | |
outputs: | |
snap: ${{ steps.snapcraft.outputs.snap }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | |
with: | |
name: parca-agent-dist-release | |
path: dist | |
- name: Setup LXD (for Snapcraft) | |
uses: whywaita/setup-lxd@16e1bb2e132ea11dfa2a8b8be7750cb9ab1ccbcd # tag=v1.0.0 | |
with: | |
lxd_version: latest/stable | |
- name: Setup Snapcraft | |
run: | | |
sudo snap install snapcraft --channel 7.x/stable --classic | |
# Unbork LXD networking due to conflict with Docker iptables rules | |
sudo iptables -F FORWARD | |
sudo iptables -P FORWARD ACCEPT | |
- name: Build snaps | |
run: | | |
# Copy the metadata.json is so snapcraft can parse it for version info | |
cp ./dist/metadata.json snap/local/metadata.json | |
# Build the amd64 snap | |
cp ./dist/parca-agent-amd64_linux_amd64_v1/parca-agent snap/local/parca-agent | |
snapcraft pack --verbose --build-for amd64 | |
# Build the arm64 snap | |
cp ./dist/parca-agent-arm64_linux_arm64/parca-agent snap/local/parca-agent | |
snapcraft pack --verbose --build-for arm64 | |
- name: Upload locally built snap artifact | |
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 | |
with: | |
name: built-snaps | |
path: | | |
*.snap | |
test: | |
name: Test Snap | |
needs: snap | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fetch built snap | |
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | |
with: | |
name: built-snaps | |
- name: Install snap & invoke Parca Agent | |
run: | | |
sudo snap install --classic --dangerous *_amd64.snap | |
sudo snap set parca-agent log-level=debug | |
parca-agent --help | |
- name: Start Parca Agent - default config | |
run: | | |
sudo snap start parca-agent | |
# Set some options to allow retries while Parca Agent comes back up | |
CURL_OPTS=(--max-time 20 --retry 5 --retry-delay 3 --retry-connrefused) | |
curl ${CURL_OPTS[@]} http://localhost:7071/ | |
curl ${CURL_OPTS[@]} http://localhost:7071/metrics | |
- name: Configure snap - node name | |
run: | | |
sudo snap set parca-agent node=foobar | |
sudo snap restart parca-agent | |
# Set some options to allow retries while Parca Agent comes back up | |
CURL_OPTS=(--max-time 20 --retry 5 --retry-delay 3 --retry-connrefused) | |
curl ${CURL_OPTS[@]} http://localhost:7071/ | |
curl ${CURL_OPTS[@]} http://localhost:7071/metrics | |
- name: Configure snap - http address | |
run: | | |
sudo snap set parca-agent http-address=":8081" | |
sudo snap restart parca-agent | |
# Set some options to allow retries while Parca comes back up | |
CURL_OPTS=(--max-time 20 --retry 5 --retry-delay 3 --retry-connrefused) | |
curl ${CURL_OPTS[@]} http://localhost:8081/ | |
curl ${CURL_OPTS[@]} http://localhost:8081/metrics | |
# In case the above tests fail, dump the logs for inspection | |
- name: Dump snap service logs | |
if: failure() | |
run: | | |
sudo snap logs parca-agent -n=all | |
release-edge: | |
name: Release Snap (latest/edge) | |
needs: test | |
if: ${{ github.event_name != 'pull_request' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | |
with: | |
name: built-snaps | |
- name: Install snapcraft | |
run: | | |
sudo snap install snapcraft --classic --channel=7.x/stable | |
- name: Release to latest/edge | |
env: | |
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} | |
run: | | |
snapcraft upload *_amd64.snap --release edge | |
snapcraft upload *_arm64.snap --release edge |