Skip to content

more changes

more changes #12

Workflow file for this run

name: Snap
on:
push:
branches:
- main
- release-*
pull_request:
branches:
- main
- release-*
env:
# renovate: datasource=go depName=github.com/goreleaser/goreleaser
GORELEASER_VERSION: v1.17.2
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@12aca0a884f6137d619d6a8a09fcc3406ced5281 # v5.3.0
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@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Set up Go
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
with:
go-version-file: .go-version
- name: Set up Clang
uses: KyleMayes/install-llvm-action@13d5d77cbf0bd7e35cb02a8f9ed4bb85bed3393b # v1.8.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 bpf
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: ebpf-object-file-release
path: pkg/profiler/cpu/cpu-profiler.bpf.o
if-no-files-found: error
binaries:
name: Goreleaser release
runs-on: ubuntu-latest
needs: dependencies
container:
image: docker.io/goreleaser/goreleaser-cross:v1.20.4
options: --privileged
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check out the code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
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@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
with:
go-version-file: .go-version
cache: true
- 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
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: ebpf-object-file-release
path: pkg/profiler/cpu/cpu-profiler.bpf.o
- 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@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
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@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- 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@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
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