Skip to content

Update Bazel version #197

Update Bazel version

Update Bazel version #197

Workflow file for this run

# GitHub Workflows file
name: main
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
version:
description: 'Version `x.y.z` (without leading `v`)'
type: string
required: true
jobs:
test:
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
build:
- linux
- windows
include:
- build: linux
os: ubuntu-20.04
config: gnu
- build: windows
os: windows-2019
config: cl
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Bazel cache
uses: actions/cache@v4
with:
path: |
~/.cache/bazel_build_cache
key: ${{ runner.os }}-bazel-test-${{ hashFiles('WORKSPACE') }}
restore-keys: |
${{ runner.os }}-bazel-test-
- name: Run bazel test
run: bazel test --config=${{ matrix.config }} --config=ci --disk_cache=~/.cache/bazel_build_cache //...
- name: Cache cleanup
run: ./tools/disk-cache-collect-garbage ~/.cache/bazel_build_cache
buildpkg:
name: Build Release Asset
runs-on: ${{ matrix.os }}
needs: test
strategy:
matrix:
build:
- linux
- macos-universal
include:
- build: linux
os: ubuntu-20.04
config: gnu
- build: macos-universal
os: macos-latest
config: gnu
- build: windows
os: windows-2019
config: cl
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Bazel cache
uses: actions/cache@v4
with:
path: |
~/.cache/bazel_build_cache
key: ${{ runner.os }}-bazel-buildpkg-${{ hashFiles('WORKSPACE') }}
restore-keys: |
${{ runner.os }}-bazel-buildpkg-
- name: Build Release Package
run: bazel build --config=${{ matrix.config }} --config=ci --config=release --//:version=${{ github.event.inputs.version || 0 }} --disk_cache=~/.cache/bazel_build_cache //:pkg
- name: Output file
id: outfile
run: |
from os import environ as env
from subprocess import check_output
from pathlib import Path
cfg = env.get("CONFIG", "gnu")
v = env.get("VERSION", "0")
execroot = Path(check_output(["bazel", "info", "execution_root"], text= True).strip())
pkg = Path(check_output(["bazel", "cquery", f"--config={cfg}", "--config=release", f"--//:version={v}", "--output=files", "--output_groups=", "//:pkg"], text=True).strip())
path = execroot / pkg
print(f"path={path}")
print(f"path={path}", file=open(env.get("GITHUB_OUTPUT", "stdout.txt"), "a"))
shell: python3 {0}
env:
CONFIG: ${{ matrix.config }}
VERSION: ${{ github.event.inputs.version || 0 }}
- name: Upload package artifact
uses: actions/upload-artifact@v4
with:
name: pkg-bazel-${{ matrix.build }}
path: ${{ steps.outfile.outputs.path }}
- name: Cache cleanup
run: ./tools/disk-cache-collect-garbage ~/.cache/bazel_build_cache
self_test:
name: Self test
runs-on: ubuntu-latest
needs: buildpkg
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run bazel to generate worktree
run: bazel build --config=gnu --config=ci //...
- name: Download pkg artifact
uses: actions/download-artifact@v4
with:
pattern: pkg-bazel-linux
- name: Install
run: |
sudo dpkg --install pkg-bazel-linux/bazel-compile-commands_*.deb
- name: Create compile-commands.json
run: |
/usr/bin/bazel-compile-commands -v -a --config=gnu --replace=-fno-canonical-system-headers= //...
- name: Run clang-tidy
run: |
clang-tidy -p "$(pwd)" $(find . -type f -name '*.cpp')
mkrelease:
name: Create Release
runs-on: ubuntu-latest
needs: buildpkg
if: github.event_name == 'workflow_dispatch'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download pkg artifact
uses: actions/download-artifact@v4
with:
pattern: pkg-*
merge-multiple: true
- name: Create Release
run: |
gh release create v${{ github.event.inputs.version }} --generate-notes *.deb *.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
format_check:
name: Style check
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install LLVM
uses: KyleMayes/install-llvm-action@v1.6.1
with:
version: "15.0.6"
- name: clang-format --version
run: clang-format --version
- name: Style check
run: ./tools/clang-format --dry-run -Werror