Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add Linux pkg-config/.so test coverage #412

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/pkg-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: pkg-config

permissions:
contents: read

on:
push:
pull_request:
merge_group:
schedule:
- cron: '15 12 * * 3'

jobs:
build:
name: Build+test
runs-on: ubuntu-latest
cpu marked this conversation as resolved.
Show resolved Hide resolved
env:
PREFIX: /tmp/librustls
strategy:
matrix:
cc: [clang, gcc]
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install cargo-c
env:
LINK: https://github.com/lu-zero/cargo-c/releases/latest/download
CARGO_C_FILE: cargo-c-x86_64-unknown-linux-musl.tar.gz
run: |
curl -L $LINK/$CARGO_C_FILE | tar xz -C ~/.cargo/bin

- name: Install the library
run: make --file=Makefile.pkg-config PREFIX=${PREFIX} install

- name: Build the client/server examples
run: PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig make --file=Makefile.pkg-config

- name: Verify client is dynamically linked
run: LD_LIBRARY_PATH=$PREFIX/lib ldd target/client | grep "rustls"

- name: Verify server is dynamically linked
run: LD_LIBRARY_PATH=$PREFIX/lib ldd target/server | grep "rustls"

- name: Run the integration tests
run: LD_LIBRARY_PATH=$PREFIX/lib make --file=Makefile.pkg-config integration
9 changes: 1 addition & 8 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,7 @@ jobs:
persist-credentials: false
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@nightly
- name: Install cargo-c
env:
LINK: https://github.com/lu-zero/cargo-c/releases/latest/download
CARGO_C_FILE: cargo-c-x86_64-unknown-linux-musl.tar.gz
run: |
curl -L $LINK/$CARGO_C_FILE | tar xz -C ~/.cargo/bin
- name: Build and test with cargo-c
run: cargo capi test


miri:
name: Miri
Expand Down
51 changes: 51 additions & 0 deletions Makefile.pkg-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Makefile for building & testing the client/server examples using pkg-config
# and dynamically linking. For static linking see the default 'Makefile'.
cpu marked this conversation as resolved.
Show resolved Hide resolved
# This Makefile is for testing only. For install instructions, see the README.
#
# Example usage:
# PREFIX=/tmp/librustls
# make --file Makefile.pkg-config install PREFIX=$PREFIX
# PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig/ make --file Makefile.pkg-config
# LD_LIBRARY_PATH=$PREFIX/lib make --file Makefile.pkg-config integration

CARGO ?= cargo
CARGOFLAGS += --locked

CFLAGS := -Werror -Wall -Wextra -Wpedantic -g -I src/
PROFILE := release
PREFIX=/usr/local

ifeq ($(CC), clang)
CFLAGS += -fsanitize=address -fsanitize=undefined
LDFLAGS += -fsanitize=address
endif
cpu marked this conversation as resolved.
Show resolved Hide resolved

ifeq ($(PROFILE), release)
CFLAGS += -O3
CARGOFLAGS += --release
endif

all: target/client target/server

integration: all
${CARGO} test --locked --test client_server -- --ignored

target:
mkdir -p $@

install:
cargo cinstall $(CARGOFLAGS) --prefix=$(PREFIX)

target/%.o: tests/%.c tests/common.h | target
$(CC) -o $@ -c $< $(CFLAGS) $(shell pkg-config --cflags rustls)

target/client: target/client.o target/common.o
$(CC) -o $@ $^ $(LDFLAGS) $(shell pkg-config --libs rustls)

target/server: target/server.o target/common.o
$(CC) -o $@ $^ $(LDFLAGS) $(shell pkg-config --libs rustls)

clean:
rm -rf target

.PHONY: all install clean integration