Skip to content

Add a version number the binary can print out. #128

Add a version number the binary can print out.

Add a version number the binary can print out. #128

Workflow file for this run

name: ci
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
Test:
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create Cache Timestamp
id: cache_timestamp
uses: nanzm/get-time-action@v2.0
with:
format: 'YYYY-MM-DD-HH-mm-ss'
- name: Mount bazel cache
uses: actions/cache@v4
with:
path: "~/.cache/bazel"
key: bazelcache_test_${{ steps.cache_timestamp.outputs.time }}
restore-keys: bazelcache_test_
- name: Test
run: |
export CC=gcc-13
export CXX=g++-13
bazel test --keep_going ...
MacOsBuild:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create Cache Timestamp
id: cache_timestamp
uses: nanzm/get-time-action@v2.0
with:
format: 'YYYY-MM-DD-HH-mm-ss'
- name: Mount bazel cache
uses: actions/cache@v4
with:
path: "/private/var/tmp/_bazel_runner"
key: bazelcache_mac_test_${{ steps.cache_timestamp.outputs.time }}
restore-keys: bazelcache_mac_test_
- name: Test
run: |
bazel test --keep_going ...
- name: Build
run: |
bazel build -c opt bant:bant
bazel-bin/bant/bant -V # Print version
# TODO: package ?
CodeFormatting:
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Dependencies
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
sudo ./llvm.sh 17
sudo apt-get install clang-format-17
go install github.com/bazelbuild/buildtools/buildifier@latest
echo "PATH=$PATH:$(go env GOPATH)/bin/" >> $GITHUB_ENV
- name: Run formatting style check
run: |
clang-format-17 --version
CLANG_FORMAT=clang-format-17 scripts/run-format.sh
git diff > /tmp/format-diff
if [ -s "/tmp/format-diff" ]; then
echo "Difference to optimal formatting"
cat /tmp/format-diff
echo
echo "=================== To Fix ==========================="
echo "Run scripts/run-format.sh"
echo "then"
echo " git commit -a --amend"
echo " git push -f"
exit 1
fi
RunBantOnBant:
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create Cache Timestamp
id: cache_timestamp
uses: nanzm/get-time-action@v2.0
with:
format: 'YYYY-MM-DD-HH-mm-ss'
- name: Mount cache
uses: actions/cache@v4
with:
path: |
~/.cache/bazel
key: bant-on-bant_${{ steps.cache_timestamp.outputs.time }}
restore-keys: bant-on-bant_
- name: Build Compilation DB
run: |
scripts/make-compilation-db.sh
bazel build //bant:version-header //bant:build-version
- name: Build bant
run: |
export CC=gcc-13
export CXX=g++-13
bazel build -c opt bant:bant
- name: Run bant on bant
run: |
bazel-bin/bant/bant dwyu ... -v -o/tmp/bant-output.txt
if [ -s "/tmp/bant-output.txt" ]; then
echo "Bant found changes to be made in BUILD files."
echo "======== Findings as buildozer edit script ==========="
echo
cat /tmp/bant-output.txt
echo
echo "=================== To Fix ==========================="
echo "Run"
echo " . <(bazel-bin/bant/bant dwyu ...)"
exit 1
fi
ClangTidy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Dependencies
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
sudo ./llvm.sh 18
sudo apt-get install clang-tidy-18
- name: Create Cache Timestamp
id: cache_timestamp
uses: nanzm/get-time-action@v2.0
with:
format: 'YYYY-MM-DD-HH-mm-ss'
- name: Mount clang-tidy cache
uses: actions/cache@v4
with:
path: |
~/.cache/clang-tidy
~/.cache/bazel
key: clang-tidy-cache_${{ steps.cache_timestamp.outputs.time }}
restore-keys: clang-tidy-cache_
- name: Build Compilation DB
run: |
scripts/make-compilation-db.sh
bazel build //bant:version-header //bant:build-version
- name: Run clang-tidy
run: |
clang-tidy-18 --version
CLANG_TIDY=clang-tidy-18 scripts/run-clang-tidy-cached.cc \
|| ( cat bant_clang-tidy.out ; exit 1)
BuildStaticBinary:
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create Cache Timestamp
id: cache_timestamp
uses: nanzm/get-time-action@v2.0
with:
format: 'YYYY-MM-DD-HH-mm-ss'
- name: Mount bazel cache
uses: actions/cache@v4
with:
path: "~/.cache/bazel"
key: bazelcache_release_${{ steps.cache_timestamp.outputs.time }}
restore-keys: bazelcache_release_
- name: Build
run: |
export CC=gcc-13
export CXX=g++-13
bazel build -c opt --//bant:create_static_linked_executables bant:bant
bazel-bin/bant/bant -V # Print version
# Version number: current tag dot number of commits after tagging.
VERSION=$(git describe --match=v* --long | sed 's|v\([^-]\+\)-\([[:digit:]]\+\).*|\1.\2|')
OUT=bant-v${VERSION}-x86
echo "OUT=${OUT}" >> $GITHUB_ENV
mkdir -p "${OUT}/bin"
install bazel-bin/bant/bant "${OUT}/bin"
strip "${OUT}/bin/bant"
# We need to pack it with with tar to retain proper unix permissions.
# Unfortunately, github then re-packs the result into a *.zip archive.
tar cvzf "${OUT}.tar.gz" ${OUT}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.OUT }}
path: ${{ env.OUT }}.tar.gz