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

Bazelize package builds #248

Merged
merged 4 commits into from
Dec 17, 2023
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
29 changes: 29 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,33 @@ build --verbose_failures

build --flag_alias=features=//:features

build --verbose_failures

test --test_output=errors

build --enable_platform_specific_config

build:macos --apple_crosstool_top=@local_config_apple_cc//:toolchain
build:macos --crosstool_top=@local_config_apple_cc//:toolchain
build:macos --host_crosstool_top=@local_config_apple_cc//:toolchain

build:x86_64_apple_darwin --platforms=:x86_64-apple-darwin
build:x86_64_apple_darwin --cpu=darwin_x86_64

build:aarch64_apple_darwin --platforms=:aarch64-apple-darwin
build:aarch64_apple_darwin --cpu=darwin_arm64

# Always display the flags being used
common:ci --announce_rc

# UI for cleaner CI output
common:ci --color=no
common:ci --curses=no
common:ci --show_timestamps
common:ci --ui_event_filters=-info
common:ci --noshow_progress

build:ci --disk_cache=~/.cache/bazel_build_cache
build:ci --repository_cache=~/.cache/bazel_repo_cache

try-import %workspace%/user.bazelrc
233 changes: 181 additions & 52 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,189 @@

name: main

defaults:
run:
shell: bash --noprofile --norc -euo pipefail {0}

on:
push:
branches: [ main ]
branches:
- main
tags:
- 'v*'
pull_request:
branches: [ main ]
branches:
- main

env:
# https://github.com/bazelbuild/bazel/issues/3001
# MSYS2_ARG_CONV_EXCL: "*"
# MSYS_NO_PATHCONV: 1
RUSTFLAGS: -Dwarnings

jobs:
build_and_test:
name: Build and test

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_test:
name: Bazel test
runs-on: ${{ matrix.os }}

needs: version

strategy:
matrix:
build:
- macos-aarch64
- macos-x86_64
- ubuntu-20.04
- ubuntu-22.04
- windows
# - windows
include:
- build: macos-x86_64
os: macos-latest
buildflags: --features=negotiate --config=x86_64_apple_darwin --//:version=${{ needs.version.outputs.version }}
- build: ubuntu-20.04
os: ubuntu-20.04
mkcmd: ./tools/mkdeb.sh -d focal
buildflags: --features=negotiate --//:version=${{ needs.version.outputs.version }}
- build: ubuntu-22.04
os: ubuntu-22.04
mkcmd: ./tools/mkdeb.sh -d jammy
buildflags: --features=negotiate --//:version=${{ needs.version.outputs.version }}
# - build: windows
# os: windows-latest
# buildflags: --features=negotiate --//:version=${{ needs.version.outputs.version }}

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: ${{ matrix.build }}-bazel-test-${{ hashFiles('Cargo.Bazel.lock', 'WORKSPACE') }}
restore-keys: |
${{ matrix.build }}-bazel-test-
- name: Setup Windows Bazelrc
# https://bazel.build/configure/windows
run: |
echo "startup --output_user_root=C:/tmp" > ${{ github.workspace }}/user.bazelrc
shell: cmd
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 }} "//..."'
shell: cmd
if: ${{ startswith(matrix.os, 'windows') }}
- name: Run tests
run: 'bazel test --config=ci ${{ matrix.buildflags }} "//..."'
if: ${{ ! startswith(matrix.os, 'windows') }}

bazel_build:
name: Bazel build release package
runs-on: ${{ matrix.os }}

needs:
- bazel_test
- version

strategy:
matrix:
build:
- macos-aarch64
- macos-x86_64
- ubuntu-20.04
- ubuntu-22.04
# - windows
include:
- build: macos-aarch64
os: macos-latest
mkcmd: ./tools/mkpkg.sh -a aarch64 -t aarch64-apple-darwin
buildflags: --features=negotiate --config=aarch64_apple_darwin --//:version=${{ needs.version.outputs.version }}
pkgfile: proxydetox-${{ needs.version.outputs.version }}-apple-darwin-aarch64.pkg
- build: macos-x86_64
os: macos-latest
mkcmd: ./tools/mkpkg.sh
- build: windows
os: windows-latest
mkcmd: ./tools/mkzip.ps1
buildflags: --features=negotiate --config=x86_64_apple_darwin --//:version=${{ needs.version.outputs.version }}
pkgfile: proxydetox-${{ needs.version.outputs.version }}-apple-darwin-x86_64.pkg
- build: ubuntu-20.04
os: ubuntu-20.04
buildflags: --features=negotiate --//:version=${{ needs.version.outputs.version }}
pkgfile: proxydetox-${{ needs.version.outputs.version }}-focal_amd64.deb
- build: ubuntu-22.04
os: ubuntu-22.04
buildflags: --features=negotiate --//:version=${{ needs.version.outputs.version }}
pkgfile: proxydetox-${{ needs.version.outputs.version }}-jammy_amd64.deb
# - build: windows
# os: windows-latest
# buildflags: --features=negotiate --//:version=${{ needs.version.outputs.version }}
# pkgfile: proxydetox-${{ needs.version.outputs.version }}-windows-x86_64.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: ${{ matrix.build }}-bazel-test-${{ hashFiles('Cargo.Bazel.lock', 'WORKSPACE') }}
restore-keys: |
${{ matrix.build }}-bazel-test-
- name: Setup Windows Bazelrc
# https://bazel.build/configure/windows
run: |
echo "startup --output_user_root=C:/tmp" > ${{ github.workspace }}\user.bazelrc
shell: cmd
if: startswith(matrix.os, 'windows')
- name: Install Linux dependency
run: sudo apt-get install libkrb5-dev
if: startswith(matrix.os, 'ubuntu')
- name: Build package
run: bazel build -c opt --config=ci ${{ matrix.buildflags }} "//pkg"
- name: Copy package
run: bazel run -c opt --config=ci ${{ matrix.buildflags }} "//pkg:copy" -- ${{ matrix.pkgfile }}
- name: Upload package artifact
uses: actions/upload-artifact@v3
with:
name: pkg
path: ./${{ matrix.pkgfile }}

cargo_build_and_test:
name: Cargo build and test
runs-on: windows-latest

steps:
- name: Checkout repository
Expand All @@ -52,67 +197,51 @@ jobs:
toolchain: stable
profile: minimal
override: true
- name: Install Rust (macos-aarach64)
if: ${{ matrix.build == 'macos-aarch64' }}
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: aarch64-apple-darwin
profile: minimal
- 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')
key: ${{ runner.os }}
# see https://github.com/rust-lang/rust-bindgen/issues/1797
- name: Install Windows dependency (LLVM)
uses: KyleMayes/[email protected]
if: startswith(matrix.os, 'windows')
if: startswith(runner.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')
shell: pwsh
if: startswith(runner.os, 'windows')
- name: Run cargo test
run: cargo test
- name: Build Release Package
id: buildpkg
run: ${{ matrix.mkcmd }}
run: ./tools/mkzip.ps1
shell: pwsh
- name: Upload package artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.buildpkg.outputs.pkgfile }}
name: pkg
path: ./${{ steps.buildpkg.outputs.pkgfile }}

bazel_build:
name: Bazel build
runs-on: ${{ matrix.os }}

strategy:
matrix:
build: [macos]
include:
- build: macos
os: macos-latest

mkrelease:
name: Create Release
runs-on: ubuntu-latest
needs:
- bazel_build
- cargo_build_and_test
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Download pkg artifact
uses: actions/download-artifact@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: Bazel build
run: bazel build --disk_cache=~/.cache/bazel_build_cache --repository_cache=~/.cache/bazel_repo_cache //macos/app:ProxydetoxApp
name: pkg
- name: Create Release
run: |
gh release create v${{ github.event.inputs.version }} --generate-notes *.deb *.pkg *.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

format_check:
name: Rust lint
Expand Down
Loading
Loading