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

feat: reduce executable size #59

Merged
merged 4 commits into from
May 6, 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
34 changes: 17 additions & 17 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
operating-system: [ ubuntu-latest, windows-latest, macos-12 ]
env:
PACT_DO_NOT_TRACK: true
RUST_LOG: trace
Expand All @@ -24,17 +24,17 @@ jobs:
with:
toolchain: stable
- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install plugin cli
run: scripts/install-plugin-cli.sh
shell: bash
- name: Install Protobuf plugin
run: ~/bin/pact-plugin-cli -y install protobuf
run: ~/.pact/bin/pact-plugin-cli -y install protobuf
shell: bash
- name: Install csv plugin
run: ~/bin/pact-plugin-cli -y install csv
run: ~/.pact/bin/pact-plugin-cli -y install csv
shell: bash
- name: Install Pact verifier
run: scripts/install-verifier-cli.sh
Expand All @@ -51,8 +51,8 @@ jobs:
nohup ./target/debug/csv-provider &
PID=$!
trap "kill $PID" EXIT
pact_do_not_track=true ~/bin/pact_verifier_cli -f ../csv-consumer-rust/target/pacts/CsvClient-CsvServer.json -p 8080
pact_do_not_track=true ~/bin/pact_verifier_cli -f ../csv-consumer-jvm/build/pacts/CsvClient-CsvServer.json -p 8080
pact_do_not_track=true ~/.pact/bin/pact_verifier_cli -f ../csv-consumer-rust/target/pacts/CsvClient-CsvServer.json -p 8080
pact_do_not_track=true ~/.pact/bin/pact_verifier_cli -f ../csv-consumer-jvm/build/pacts/CsvClient-CsvServer.json -p 8080
cd ../csv-provider-jvm
mkdir -p server/src/test/resources/pacts
cp ../csv-consumer-jvm/build/pacts/CsvClient-CsvServer.json server/src/test/resources/pacts
Expand All @@ -70,7 +70,7 @@ jobs:
nohup ./target/debug/csv-provider &
PID=$!
trap "kill $PID" EXIT
pact_do_not_track=true ~/bin/pact_verifier_cli -f ../csv-consumer-jvm/build/pacts/CsvClient-CsvServer.json -p 8080
pact_do_not_track=true ~/.pact/bin/pact_verifier_cli -f ../csv-consumer-jvm/build/pacts/CsvClient-CsvServer.json -p 8080
shell: bash
working-directory: examples/csv
if: runner.os == 'Windows'
Expand All @@ -84,7 +84,7 @@ jobs:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
operating-system: [ ubuntu-latest, windows-latest, macos-12 ]
env:
PACT_DO_NOT_TRACK: true
RUST_LOG: trace
Expand All @@ -99,7 +99,7 @@ jobs:
with:
toolchain: stable
- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Go
Expand All @@ -110,7 +110,7 @@ jobs:
run: scripts/install-plugin-cli.sh
shell: bash
- name: Install Protobuf plugin
run: ~/bin/pact-plugin-cli -y install protobuf
run: ~/.pact/bin/pact-plugin-cli -y install protobuf
shell: bash
- name: Install Pact verifier
run: scripts/install-verifier-cli.sh
Expand Down Expand Up @@ -138,8 +138,8 @@ jobs:
PID=$!
trap "kill $PID" EXIT
timeout --foreground -s TERM 30s bash -c 'while [[ "$(curl -s -o /dev/null -m 3 -L -w ''%{http_code}'' -XPOST -d'{}' http://127.0.0.1:8111)" != "200" ]]; do echo "Waiting for http://127.0.0.1:8111" && sleep 2; done'
pact_do_not_track=true ~/bin/pact_verifier_cli -f ../protobuf-consumer-rust/target/pacts/protobuf-consumer-rust-protobuf-provider.json -p 8111
pact_do_not_track=true ~/bin/pact_verifier_cli -f ../protobuf-consumer-jvm/build/pacts/protobuf-consumer-protobuf-provider.json -p 8111
pact_do_not_track=true ~/.pact/bin/pact_verifier_cli -f ../protobuf-consumer-rust/target/pacts/protobuf-consumer-rust-protobuf-provider.json -p 8111
pact_do_not_track=true ~/.pact/bin/pact_verifier_cli -f ../protobuf-consumer-jvm/build/pacts/protobuf-consumer-protobuf-provider.json -p 8111
shell: bash
working-directory: examples/protobuf
if: runner.os == 'Linux'
Expand All @@ -158,8 +158,8 @@ jobs:
PID=$!
trap "kill $PID" EXIT
timeout --foreground -s TERM 30s bash -c 'while [[ "$(curl -s -o /dev/null -m 3 -L -w ''%{http_code}'' -XPOST -d'{}' http://127.0.0.1:8111)" != "200" ]]; do echo "Waiting for http://127.0.0.1:8111" && sleep 2; done'
pact_do_not_track=true ~/bin/pact_verifier_cli -f ../protobuf-consumer-rust/target/pacts/protobuf-consumer-rust-protobuf-provider.json -p 8111
pact_do_not_track=true ~/bin/pact_verifier_cli -f ../protobuf-consumer-jvm/build/pacts/protobuf-consumer-protobuf-provider.json -p 8111
pact_do_not_track=true ~/.pact/bin/pact_verifier_cli -f ../protobuf-consumer-rust/target/pacts/protobuf-consumer-rust-protobuf-provider.json -p 8111
pact_do_not_track=true ~/.pact/bin/pact_verifier_cli -f ../protobuf-consumer-jvm/build/pacts/protobuf-consumer-protobuf-provider.json -p 8111
shell: bash
working-directory: examples/protobuf
if: runner.os != 'Linux'
Expand All @@ -173,7 +173,7 @@ jobs:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
operating-system: [ ubuntu-latest, windows-latest, macos-12 ]
env:
PACT_DO_NOT_TRACK: true
RUST_LOG: trace
Expand All @@ -188,7 +188,7 @@ jobs:
with:
toolchain: stable
- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Go
Expand All @@ -199,7 +199,7 @@ jobs:
run: scripts/install-plugin-cli.sh
shell: bash
- name: Install Protobuf plugin
run: ~/bin/pact-plugin-cli -y install protobuf
run: ~/.pact/bin/pact-plugin-cli -y install protobuf
shell: bash
- name: Install Pact verifier
run: scripts/install-verifier-cli.sh
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
operating-system: [ ubuntu-latest, windows-latest, macos-12 ]
steps:
- uses: actions/checkout@v4
- name: Set up JDK 19
Expand All @@ -18,7 +18,7 @@ jobs:
distribution: 'temurin'
java-version: 19
- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build plugin driver
Expand All @@ -28,7 +28,7 @@ jobs:
run: scripts/install-plugin-cli.sh
shell: bash
- name: Install Protobuf plugin
run: ~/bin/pact-plugin-cli -y install protobuf
run: ~/.pact/bin/pact-plugin-cli -y install protobuf
shell: bash
- name: Run plugin driver tests
run: ./gradlew -s --no-daemon -i check
Expand All @@ -51,7 +51,7 @@ jobs:
distribution: 'temurin'
java-version: ${{ matrix.jdk }}
- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build plugin driver
Expand All @@ -61,7 +61,7 @@ jobs:
run: scripts/install-plugin-cli.sh
shell: bash
- name: Install Protobuf plugin
run: ~/bin/pact-plugin-cli -y install protobuf
run: ~/.pact/bin/pact-plugin-cli -y install protobuf
shell: bash
- name: Run plugin driver tests
run: ./gradlew -s --no-daemon -i check
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/plugin-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ jobs:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
operating-system: [ ubuntu-latest, windows-latest, macos-12 ]
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build plugin CLI
Expand Down
79 changes: 58 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,88 @@ on:
release:
types: [published]

pull_request:
branches:
- main
push:
branches:
- feat/musl_built_binaries

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true

jobs:
build-release:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest]
include:
- operating-system: ubuntu-20.04
targets: x86_64-unknown-linux-gnu,x86_64-unknown-linux-musl,aarch64-unknown-linux-gnu,aarch64-unknown-linux-musl
- operating-system: windows-2019
targets: aarch64-pc-windows-msvc,x86_64-pc-windows-msvc
- operating-system: macos-12
targets: aarch64-apple-darwin,x86_64-apple-darwin
fail-fast: false
env:
pact_do_not_track: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install stable Rust toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
override: true
target: aarch64-apple-darwin
targets: ${{ matrix.targets }}

- name: Rust caching
uses: Swatinem/rust-cache@v2

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
if: runner.os == 'Linux'
uses: docker/setup-buildx-action@v3

- name: Install LLVM
run: choco install -y llvm
if: runner.os == 'Windows'
- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- if: startsWith(github.ref, 'refs/tags/csv-plugin')
run: ./release.sh ${{ runner.os }}
- name: Cargo flags
id: cargo-flags
shell: bash
run: |
if [[ "${{ github.event_name }}" = "release" ]]; then
echo "flags=--release" >> "$GITHUB_OUTPUT"
else
echo "flags=" >> "$GITHUB_OUTPUT"
fi
- if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' ||
startsWith(github.ref, 'refs/tags/csv-plugin')
run: ./release.sh ${{ runner.os }} ${{ steps.cargo-flags.outputs.flags }}
shell: bash
working-directory: plugins/csv
- name: Upload Release Assets
if: startsWith(github.ref, 'refs/tags/csv-plugin')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: plugins/csv/target/artifacts/*
file_glob: true
tag: ${{ github.ref }}
- if: startsWith(github.ref, 'refs/tags/pact-plugin-cli')
run: ./release.sh ${{ runner.os }}
- if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' ||
startsWith(github.ref, 'refs/tags/pact-plugin-cli')
run: ./release.sh ${{ runner.os }} ${{ steps.cargo-flags.outputs.flags }}
shell: bash
working-directory: cli
- name: Upload Release Assets
if: startsWith(github.ref, 'refs/tags/pact-plugin-cli')
if: |
startsWith(github.ref, 'refs/tags/pact-plugin-cli') ||
startsWith(github.ref, 'refs/tags/csv-plugin')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: cli/target/artifacts/*
file: release_artifacts/*
file_glob: true
tag: ${{ github.ref }}
8 changes: 4 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ ubuntu-latest, windows-latest, macos-latest ]
operating-system: [ ubuntu-latest, windows-latest, macos-12 ]
env:
pact_do_not_track: true
steps:
Expand All @@ -17,17 +17,17 @@ jobs:
toolchain: stable
components: clippy
- name: Install Protoc
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install plugin cli
run: scripts/install-plugin-cli.sh
shell: bash
- name: Install Protobuf plugin
run: ~/bin/pact-plugin-cli -y install protobuf
run: ~/.pact/bin/pact-plugin-cli -y install protobuf
shell: bash
- name: Install csv plugin
run: ~/bin/pact-plugin-cli -y install csv
run: ~/.pact/bin/pact-plugin-cli -y install csv
shell: bash
- name: Tests
run: cargo test
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ build
target
pacts
*.out
# Generated Release Artifacts
release_artifacts

# Misc

Expand Down
11 changes: 11 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,14 @@ tempfile = "3.8.1"
expectest = "0.12.0"
test-log = "0.2.14"
env_logger = "0.10.1"

[profile.release]
strip = true
opt-level = "z"
codegen-units = 1
lto = true

# References
# https://doc.rust-lang.org/stable/rustc/codegen-options/
# https://doc.rust-lang.org/rustc/profile-guided-optimization.html
# https://github.com/johnthagen/min-sized-rust
Loading
Loading