Merge pull request #1333 from Billy99/billy99-docs-ocp #81
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: build | |
on: # yamllint disable-line rule:truthy | |
push: | |
branches: [main] | |
tags: | |
- v* | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
env: | |
CARGO_TERM_COLOR: always | |
# Use to pin rust nightly to specific version. | |
NIGHTLY_VERSION: nightly-2024-09-24 | |
jobs: | |
check-license: | |
runs-on: ubuntu-24.04 | |
timeout-minutes: 3 | |
steps: | |
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4 | |
- name: Check License Header | |
uses: apache/skywalking-eyes@cd7b195c51fd3d6ad52afceb760719ddc6b3ee91 | |
build: | |
runs-on: ubuntu-24.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: | |
- arch: amd64 | |
rust-target: x86_64-unknown-linux-gnu | |
filename: linux-x86_64 | |
command: cargo | |
- arch: arm64 | |
rust-target: aarch64-unknown-linux-gnu | |
filename: linux-arm64 | |
command: cross | |
- arch: ppc64le | |
rust-target: powerpc64le-unknown-linux-gnu | |
filename: linux-ppc64le | |
command: cross | |
- arch: s390x | |
rust-target: s390x-unknown-linux-gnu | |
filename: linux-s390x | |
command: cross | |
name: Build bpfman (${{ matrix.arch.arch }}) | |
steps: | |
- name: Free up space | |
run: | | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /opt/ghc | |
sudo rm -rf "/usr/local/share/boost" | |
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | |
sudo rm -rf /usr/local/lib/android | |
- name: Install dependencies | |
# Dependencies only needed to build eBPF and used by integration-tests, only on amd64 | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
run: | | |
sudo apt-get update | |
sudo apt-get install -qy \ | |
git \ | |
clang \ | |
llvm \ | |
protobuf-compiler \ | |
cmake \ | |
perl \ | |
libssl-dev \ | |
gcc-multilib \ | |
libelf-dev \ | |
- name: Checkout bpfman | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4 | |
- name: Checkout libbpf | |
# libbpf only needed to build eBPF and used by integration-tests, only on amd64 | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4 | |
with: | |
repository: libbpf/libbpf | |
path: libbpf | |
fetch-depth: 0 | |
- name: Install rust toolchain - stable | |
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # @v1 | |
with: | |
toolchain: stable | |
override: true | |
target: ${{ matrix.arch.rust-target }} | |
- name: Install rust toolchain - ${{ env.NIGHTLY_VERSION }} | |
# Only need for checks (like lint and clippy) that only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # @v1 | |
with: | |
toolchain: ${{ env.NIGHTLY_VERSION }} | |
components: rustfmt, rust-src | |
override: false | |
# Only install cross if we need it | |
# Install via cargo-binstall which I found faster | |
- name: Install Cross | |
if: ${{ matrix.arch.command == 'cross' }} | |
shell: bash | |
run: | | |
cargo install cross --git https://github.com/cross-rs/cross | |
- uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # @v2 | |
- name: Install cargo-llvm-cov | |
# Only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
uses: taiki-e/install-action@ac87e9813a4968fd0c941361295f6d119b826393 # @cargo-llvm-cov | |
- name: Install toml linter | |
# Only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
uses: taiki-e/install-action@e29814c376696105d80cec9e9efaa98bae8e7347 # @v2 | |
with: | |
tool: taplo-cli | |
- name: toml-lint | |
# Only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
run: taplo fmt --check | |
- name: yaml-lint | |
# Only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
run: yamllint -c .yamllint.yaml --strict . | |
- name: Check C formatting | |
# Only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
run: git ls-files -- '*.c' '*.h' | xargs clang-format --dry-run --Werror | |
- name: Build eBPF | |
# Only need to build eBPF once and used by integration-tests, only on amd64 | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
run: | | |
${{ matrix.arch.command }} xtask build-ebpf --libbpf-dir ./libbpf | |
- name: Package Integration Test eBPF | |
# Only need to build eBPF once and used by integration-tests, only on amd64 | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
run: | | |
tar -czvf integration-test.tar.gz tests/integration-test/bpf/.output | |
- name: Archive Integration Test eBPF | |
# Only need to build eBPF once and used by integration-tests, only on amd64 | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # @v4 | |
with: | |
name: bpfman-integration-test | |
path: | | |
integration-test.tar.gz | |
- name: Check formatting | |
# Only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
run: | | |
cargo +${{ env.NIGHTLY_VERSION }} fmt --all -- --check | |
- name: Check public API | |
# Only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
run: cargo xtask public-api --target ${{ matrix.arch.rust-target }} --toolchain ${{ env.NIGHTLY_VERSION }} | |
- name: Run documentation tests | |
# Only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
run: | | |
cargo test --doc --all-features | |
- name: Build | |
run: | | |
${{ matrix.arch.command }} build --verbose --target ${{ matrix.arch.rust-target }} | |
- name: Package bpfman Binaries | |
# Tar and archive the build for basic-integration-tests, only on amd64 | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
run: | | |
cd target/${{ matrix.arch.rust-target }}/debug | |
tar -czvf bpfman-debug-${{ matrix.arch.filename }}.tar.gz bpfman bpfman-rpc bpfman-ns bpf-metrics-exporter bpf-log-exporter | |
- name: Archive bpfman Binaries | |
# Tar and archive the build for basic-integration-tests, only on amd64 | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # @v4 | |
with: | |
name: bpfman-debug-${{ matrix.arch.filename }} | |
path: | | |
./target/${{ matrix.arch.rust-target }}/debug/bpfman-debug-${{ matrix.arch.filename }}.tar.gz | |
- name: Build manpages | |
# Only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
run: cargo xtask build-man-page | |
- name: Package manpages | |
# Only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
run: | | |
tar -czvf manpages.tar.gz .output/manpage/ | |
- name: Archive manpages | |
# Only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # @v4 | |
with: | |
name: bpfman-manpages | |
path: | | |
manpages.tar.gz | |
- name: Build CLI TAB Completion | |
# Only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
run: cargo xtask build-completion | |
- name: Package CLI TAB Completion | |
# Only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
run: | | |
tar -czvf cli-tab-completion.tar.gz .output/completions/ | |
- name: Archive CLI TAB Completion | |
# Only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # @v4 | |
with: | |
name: bpfman-cli-tab-completion | |
path: | | |
cli-tab-completion.tar.gz | |
## If the push is a tag....build and upload the release bpfman binaries to an archive | |
- name: Build Release | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: | | |
${{ matrix.arch.command }} build --verbose --release --target ${{ matrix.arch.rust-target }} | |
- name: Package bpfman Release Binaries | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: | | |
cd target/${{ matrix.arch.rust-target }}/release | |
tar -czvf bpfman-${{ matrix.arch.filename }}.tar.gz bpfman bpfman-rpc bpfman-ns bpf-metrics-exporter bpf-log-exporter | |
- name: Archive bpfman Release Binaries | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # @v4 | |
with: | |
name: bpfman-release-${{ matrix.arch.filename }} | |
path: ./target/${{ matrix.arch.rust-target }}/release/bpfman-${{ matrix.arch.filename }}.tar.gz | |
- name: Run Unit Tests | |
# Only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
run: cargo llvm-cov test --all-features -p bpfman -p bpfman-api --lcov --output-path lcov.info | |
env: | |
RUST_BACKTRACE: full | |
- name: Archive Rust code coverage results | |
# Only need to run once | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # @v4 | |
with: | |
name: coverage-rust | |
path: lcov.info | |
if-no-files-found: error | |
## Build go modules | |
build-go: | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: | |
- arch: amd64 | |
filename: linux-x86_64 | |
- arch: arm64 | |
filename: linux-arm64 | |
- arch: ppc64le | |
filename: linux-ppc64le | |
- arch: s390x | |
filename: linux-s390x | |
runs-on: ubuntu-24.04 | |
name: Build Go Modules (${{ matrix.arch.arch }}) | |
steps: | |
- name: Checkout bpfman | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4 | |
- name: Install go | |
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # @v5 | |
with: | |
# prettier-ignore | |
go-version: '1.22' # yamllint disable-line rule:quoted-strings | |
- name: Go mod check | |
# Only need to run go mod once, so just pick one of the arch to run on. | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
run: | | |
go mod tidy | |
git diff --exit-code go.mod go.sum | |
- name: Lint | |
# Only need to lint the code once, so just pick one of the arch to run on. | |
if: ${{ matrix.arch.arch == 'amd64' }} | |
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # @v6 | |
with: | |
## https://github.com/golangci/golangci-lint-action/issues/369 | |
version: v1.54.2 | |
skip-cache: true | |
skip-save-cache: true | |
args: -v --timeout 5m | |
- name: Build Examples | |
run: | | |
cd examples | |
GOARCH=${{ matrix.arch.arch }} make build | |
basic-integration-tests: | |
runs-on: ubuntu-24.04 | |
needs: [build, build-go] | |
steps: | |
- name: Set up environment for running integration tests from manual trigger | |
if: github.event_name == 'workflow_dispatch' | |
run: | | |
echo "XDP_PASS_IMAGE_LOC=quay.io/bpfman-bytecode/xdp_pass:${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
echo "TC_PASS_IMAGE_LOC=quay.io/bpfman-bytecode/tc_pass:${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
echo "TRACEPOINT_IMAGE_LOC=quay.io/bpfman-bytecode/tracepoint:${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
echo "UPROBE_IMAGE_LOC=quay.io/bpfman-bytecode/uprobe:${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
echo "URETPROBE_IMAGE_LOC=quay.io/bpfman-bytecode/uretprobe:${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
echo "KPROBE_IMAGE_LOC=quay.io/bpfman-bytecode/kprobe:${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
echo "KRETPROBE_IMAGE_LOC=quay.io/bpfman-bytecode/kretprobe:${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
echo "XDP_COUNTER_IMAGE_LOC=quay.io/bpfman-bytecode/go-xdp-counter:${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
echo "TC_COUNTER_IMAGE_LOC=quay.io/bpfman-bytecode/go-tc-counter:${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
echo "TCX_COUNTER_IMAGE_LOC=quay.io/bpfman-bytecode/go-tcx-counter:${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
echo "TRACEPOINT_COUNTER_IMAGE_LOC=quay.io/bpfman-bytecode/go-tracepoint-counter:${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
echo "FENTRY_IMAGE_LOC=quay.io/bpfman-bytecode/fentry:${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
echo "FEXIT_IMAGE_LOC=quay.io/bpfman-bytecode/fexit:${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # @v3 | |
with: | |
driver-opts: network=host | |
- name: Checkout bpfman | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4 | |
- name: Download bpfman x86_64 build | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # @v4 | |
with: | |
name: bpfman-debug-linux-x86_64 | |
merge-multiple: true | |
- name: Unpack binaries | |
run: | | |
mkdir -p target/debug | |
tar -C target/debug -xzvf bpfman-debug-linux-x86_64.tar.gz | |
- name: Download Integration Test eBPF | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # @v4 | |
with: | |
name: bpfman-integration-test | |
merge-multiple: true | |
- name: Unpack Integration Test eBPF | |
run: | | |
tar -xzvf integration-test.tar.gz | |
- name: Download manpages | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # @v4 | |
with: | |
name: bpfman-manpages | |
merge-multiple: true | |
- name: Unpack manpages | |
run: | | |
tar -xzvf manpages.tar.gz | |
- name: Download CLI TAB Completion | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # @v4 | |
with: | |
name: bpfman-cli-tab-completion | |
merge-multiple: true | |
- name: Unpack CLI TAB Completion | |
run: | | |
tar -xzvf cli-tab-completion.tar.gz | |
- name: Install libelf-dev | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y linux-headers-`uname -r` clang lldb lld libelf-dev gcc-multilib libbpf-dev | |
- name: Generate go wrapped eBPF | |
run: | | |
cd examples && make generate | |
- name: Run the bpfman installer | |
run: sudo ./scripts/setup.sh install | |
- name: Verify the bpfman systemd service is active | |
run: systemctl is-active bpfman.socket | |
- name: Verify the CLI can reach bpfman | |
run: sudo bpfman list | |
- name: Verify the manpages are installed | |
run: man bpfman list | |
- name: Stop the bpfman systemd service | |
run: | | |
sudo systemctl stop bpfman | |
sudo ./scripts/setup.sh uninstall | |
- name: Run integration tests | |
run: cargo xtask integration-test | |
build-docs: | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout bpfman | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4 | |
- name: Install Python3 | |
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # @v5 | |
with: | |
python-version: 3.x | |
- name: Mkdocs Build | |
run: | | |
pip install mkdocs-material | |
pip install -r requirements.txt | |
mkdocs build --strict | |
coverage: | |
needs: [build, build-go] | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Download rust coverage artifacts | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # @v4 | |
with: | |
name: coverage-rust | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # @v4 | |
with: | |
files: ./lcov.info | |
verbose: true | |
# Creates Release | |
# Copies built bpfman binaries to release artifacts | |
# Publish's bpfman and bpfman-api crates to crates.io | |
release: | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: [build] | |
environment: crates.io | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout bpfman | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # @v4 | |
- name: Set env | |
run: | | |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
if [[ ${GITHUB_REF#refs/*/} =~ "rc" ]]; then | |
echo "PRE_RELEASE=true" >> $GITHUB_ENV | |
else | |
echo "PRE_RELEASE=false" >> $GITHUB_ENV | |
fi | |
- name: Download bpfman Release Binaries | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # @v4 | |
with: | |
pattern: bpfman-release-* | |
merge-multiple: true | |
- name: release | |
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # @v2 | |
with: | |
body_path: ./changelogs/CHANGELOG-${{ env.RELEASE_VERSION }}.md | |
prerelease: ${{ env.PRE_RELEASE }} | |
files: | | |
bpfman-linux-x86_64.tar.gz | |
bpfman-linux-arm64.tar.gz | |
bpfman-linux-ppc64le.tar.gz | |
bpfman-linux-s390x.tar.gz | |
- name: publish bpfman crate | |
run: cargo publish -p bpfman --token ${{ secrets.BPFMAN_DEV_TOKEN }} | |
- name: publish bpfman-api crate | |
run: cargo publish -p bpfman-api --token ${{ secrets.BPFMAN_DEV_TOKEN }} | |
- name: publish bpf-log-exporter crate | |
run: cargo publish -p bpf-log-exporter --token ${{ secrets.BPFMAN_DEV_TOKEN }} | |
- name: publish bpf-metrics-exporter crate | |
run: cargo publish -p bpf-metrics-exporter --token ${{ secrets.BPFMAN_DEV_TOKEN }} | |
build-workflow-complete: | |
needs: | |
[ | |
check-license, | |
build, | |
build-go, | |
build-docs, | |
coverage, | |
basic-integration-tests, | |
] | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Build Complete | |
run: echo "Build Complete" |