Bazelize package builds #923
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
# GitHub Workflows file | |
name: main | |
defaults: | |
run: | |
shell: bash --noprofile --norc -euo pipefail {0} | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
# defaults: | |
# run: | |
# shell: bash | |
env: | |
# https://github.com/bazelbuild/bazel/issues/3001 | |
# MSYS2_ARG_CONV_EXCL: "*" | |
# MSYS_NO_PATHCONV: 1 | |
RUSTFLAGS: -Dwarnings | |
jobs: | |
version: | |
name: Current proxydetox version | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: Fetch dependencies | |
run: | | |
bazel build --nobuild --config=ci //pkg:version | |
- name: Build version | |
run: | | |
bazel build --config=ci //:current_version | |
- name: Version | |
id: version | |
run: | | |
bazel run --config=ci //:current_version | tee -a $GITHUB_OUTPUT | |
bazel_build_and_test: | |
name: Bazel build and test | |
runs-on: ${{ matrix.os }} | |
needs: version | |
strategy: | |
matrix: | |
build: | |
- macos-aarch64 | |
- macos-x86_64 | |
- ubuntu-20.04 | |
- ubuntu-22.04 | |
# - windows | |
include: | |
- build: macos-aarch64 | |
os: macos-latest | |
buildflags: --features=negotiate --config=aarch64_apple_darwin --//:version=${{ needs.version.outputs.version }} | |
dotest: false | |
pkgfile: proxydetox-${{ needs.version.outputs.version }}-aarch64-apple-darwin.pkg | |
- build: macos-x86_64 | |
os: macos-latest | |
buildflags: --features=negotiate --config=x86_64_apple_darwin --//:version=${{ needs.version.outputs.version }} | |
dotest: true | |
pkgfile: proxydetox-${{ needs.version.outputs.version }}-x86_64-apple-darwin.pkg | |
- build: ubuntu-20.04 | |
os: ubuntu-20.04 | |
buildflags: --features=negotiate --//:version=${{ needs.version.outputs.version }} | |
dotest: true | |
pkgfile: proxydetox-${{ needs.version.outputs.version }}-x86_64-focal.deb | |
- build: ubuntu-22.04 | |
os: ubuntu-22.04 | |
buildflags: --features=negotiate --//:version=${{ needs.version.outputs.version }} | |
dotest: true | |
pkgfile: proxydetox-${{ needs.version.outputs.version }}-x86_64-jammy.deb | |
# - build: windows | |
# os: windows-latest | |
# buildflags: --features=negotiate --//:version=${{ needs.version.outputs.version }} | |
# dotest: true | |
# pkgfile: proxydetox-${{ needs.version.outputs.version }}-x86_64-linux.zip | |
steps: | |
- name: Git checkout with LF | |
run: | | |
git config --global core.autocrlf false | |
git config --global core.eol lf | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- name: Bazel cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/bazel_build_cache | |
~/.cache/bazel_repo_cache | |
key: ${{ runner.os }}-bazel-${{ hashFiles('Cargo.Bazel.lock', 'WORKSPACE') }} | |
restore-keys: | | |
${{ runner.os }}-bazel- | |
- name: Setup Windows Bazelrc | |
# https://bazel.build/configure/windows | |
run: | | |
echo "startup --output_user_root=C:/tmp" > ${{ github.workspace }}/user.bazelrc | |
if: startswith(matrix.os, 'windows') | |
- name: Install Linux dependency | |
run: sudo apt-get install libkrb5-dev | |
if: startswith(matrix.os, 'ubuntu') | |
- name: Run tests | |
run: 'bazel test --config=ci ${{ matrix.buildflags }} "//..."' | |
if: ${{ matrix.dotest }} | |
- name: Build package | |
run: bazel build -c opt --config=ci ${{ matrix.buildflags }} //pkg | |
- name: Query package file | |
id: querypkg | |
run: | | |
BAZEL_OUT=$(bazel info --config=ci output_path) | |
PKGFILE=$(bazel cquery --config=ci ${{ matrix.buildflags }} --output=files //pkg) | |
printf 'pkgfile=%s/%s\n' "${BAZEL_OUT}" "${PKGFILE#bazel-out/}" | tee -a "${GITHUB_OUTPUT}" | |
- name: Upload package artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.pkgfile }} | |
path: ./${{ steps.querypkg.outputs.pkgfile }} | |
cargo_build_and_test: | |
name: Cargo build and test | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
build: | |
- windows | |
include: | |
- build: windows | |
os: windows-latest | |
mkcmd: ./tools/mkzip.ps1 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
key: ${{ matrix.os }} | |
- name: Install Linux dependency | |
run: sudo apt-get install libkrb5-dev | |
if: startswith(matrix.os, 'ubuntu') | |
# see https://github.com/rust-lang/rust-bindgen/issues/1797 | |
- name: Install Windows dependency (LLVM) | |
uses: KyleMayes/[email protected] | |
if: startswith(matrix.os, 'windows') | |
with: | |
version: "11.0" | |
directory: ${{ runner.temp }}/llvm | |
- name: Set LIBCLANG_PATH | |
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV | |
if: startswith(matrix.os, 'windows') | |
- name: Run cargo test | |
run: cargo test | |
- name: Build Release Package | |
id: buildpkg | |
run: ${{ matrix.mkcmd }} | |
- name: Upload package artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.buildpkg.outputs.pkgfile }} | |
path: ./${{ steps.buildpkg.outputs.pkgfile }} | |
format_check: | |
name: Rust lint | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
lint: [clippy, fmt] | |
include: | |
- lint: clippy | |
flags: --all | |
- lint: fmt | |
flags: --all -- --check | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
components: rustfmt, clippy | |
override: true | |
- name: Install Linux dependency | |
run: sudo apt-get install libkrb5-dev | |
if: ${{ matrix.lint == 'clippy' }} | |
- name: Lint check | |
run: cargo ${{ matrix.lint }} ${{ matrix.flags }} |