Skip to content

Commit

Permalink
Bringup (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjreiniger authored Dec 29, 2023
1 parent 7ba1d85 commit 285ec71
Show file tree
Hide file tree
Showing 42 changed files with 9,471 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tests
generate
85 changes: 85 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
try-import user.bazelrc

# build --javacopt=-Werror
build --javacopt=-Xlint:all,-serial,-processing,-options

# Windows
build:windows --copt=/W3
build:windows --copt=/WX
build:windows --copt=/std:c++20
build:windows --copt=/Zc:preprocessor
build:windows --copt=/wd5105
build:windows --cxxopt=/wd4146
build:windows --cxxopt=/wd4267
build:windows --cxxopt=/wd4244

# Windows Arm
build:windows_arm --copt=/W3
build:windows_arm --copt=/WX
build:windows_arm --copt=/std:c++20
build:windows_arm --copt=/Zc:preprocessor
build:windows_arm --copt=/wd5105
build:windows_arm --cxxopt=/wd4146
build:windows_arm --cxxopt=/wd4267
build:windows_arm --cxxopt=/wd4244
build:windows_arm --cpu=x64_arm64_windows

# Linux
build:linux --copt=-Wall
build:linux --copt=-Wextra
build:linux --copt=-Werror
build:linux --copt=-std=c++20
build:linux --linkopt=-pthread

# MacOS
build:macos --copt=-Wall
build:macos --copt=-Wextra
build:macos --copt=-Werror
build:macos --copt=-std=c++20
build:macos --cxxopt=-Wno-unused-parameter
build:macos --cxxopt=-Wno-error=deprecated-declarations
build:macos --cxxopt=-Wno-error=deprecated-enum-enum-conversion
build:macos --cxxopt=-Wno-error=deprecated-anon-enum-enum-conversion
build:macos --cxxopt=-Wno-error=inconsistent-missing-override
build:macos --cxxopt=-Wno-error=overloaded-virtual

# Roborio
build:roborio --incompatible_enable_cc_toolchain_resolution
build:roborio --copt=-std=c++20
build:roborio --platforms=@rules_bzlmodrio_toolchains//platforms/roborio
build:roborio --build_tag_filters=-no-roborio
build:roborio --features=compiler_param_file
build:roborio --platform_suffix=roborio

# bullseye32
build:bullseye32 --incompatible_enable_cc_toolchain_resolution
build:bullseye32 --copt=-std=c++20
build:bullseye32 --platforms=@rules_bzlmodrio_toolchains//platforms/bullseye32
build:bullseye32 --build_tag_filters=-no-bullseye
build:bullseye32 --features=compiler_param_file
build:bullseye32 --platform_suffix=bullseye32

# bullseye64
build:bullseye64 --incompatible_enable_cc_toolchain_resolution
build:bullseye64 --copt=-std=c++20
build:bullseye64 --platforms=@rules_bzlmodrio_toolchains//platforms/bullseye64
build:bullseye64 --build_tag_filters=-no-bullseye
build:bullseye64 --features=compiler_param_file
build:bullseye64 --platform_suffix=bullseye64

# rasppi
build:raspi32 --incompatible_enable_cc_toolchain_resolution
build:raspi32 --copt=-std=c++20
build:raspi32 --platforms=@rules_bzlmodrio_toolchains//platforms/raspi32
build:raspi32 --build_tag_filters=-no-raspi
build:raspi32 --features=compiler_param_file
build:raspi32 --platform_suffix=raspi32

# Global
import .bazelrc-buildbuddy
test --test_output=errors
build --java_language_version=17
build --java_runtime_version=roboriojdk_17
build --tool_java_language_version=17
build --tool_java_runtime_version=roboriojdk_17
build --registry=https://raw.githubusercontent.com/pjreiniger/bazel-central-registry/bzlmodrio/
10 changes: 10 additions & 0 deletions .bazelrc-buildbuddy
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
build:remote --bes_results_url=https://app.buildbuddy.io/invocation/
build:remote --bes_backend=grpcs://remote.buildbuddy.io
build:remote --remote_cache=grpcs://remote.buildbuddy.io
build:remote --remote_download_toplevel # Helps remove network bottleneck if caching is enabled
build:remote --remote_timeout=3600

build --experimental_inmemory_jdeps_files
build --experimental_inmemory_dotd_files

build:ci --build_metadata=ROLE=CI
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.0.0
90 changes: 90 additions & 0 deletions .github/workflows/auto_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Auto Update
on:
workflow_dispatch:
schedule:
# Check everyday at 20:00 UTC
- cron: '0 20 * * *'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
auto_update_module:
name: "Auto Update Module"
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.20.x
uses: actions/setup-go@v4
with:
go-version: 1.20.x
id: go

- uses: actions/checkout@v3

- name: Install Buildifier
run: |
cd $(mktemp -d)
GO111MODULE=on go install github.com/bazelbuild/buildtools/buildifier@latest
# Checkout repository
- uses: actions/checkout@v3
with:
path: rules/rules_bzlmodrio_jdk

# Checkout gentool
- uses: actions/checkout@v3
with:
repository: 'bzlmodRio/gentool.git'
fetch-depth: 0
path: gentool
ref: refactor_dev



- name: Setup Cache
uses: actions/cache@v3
with:
path: |
~/bzlmod_cache/*.sha256
key: ${{ runner.os }}-${{ hashFiles('**/generate/**') }}
restore-keys: |
${{ runner.os }}-
${{ runner.os }}
# Run update
- name: Run update
run: bazel run //:auto_update
working-directory: rules/rules_bzlmodrio_jdk/generate

- name: Generate if changed
run: |
if [[ $(git --no-pager diff --exit-code HEAD) != '' ]]; then
echo "Something changed, need to re-generate"
bazel run //:generate
buildifier -warnings all --lint=fix -r ..
cd ..
bazel build //... --nobuild --enable_bzlmod --lockfile_mode=update
cd tests
bazel build //... --nobuild --enable_bzlmod --lockfile_mode=update
else
echo "No changes!"
fi;
working-directory: rules/rules_bzlmodrio_jdk/generate

- name: Store new version
run: echo "NEW_VERSION=$(bazel run //:get_version)" >> $GITHUB_ENV
working-directory: rules/rules_bzlmodrio_jdk/generate

# Create pull requests
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
env:
GITHUB_TOKEN: ${{ secrets.AUTO_UPDATE_KEY }}
with:
path: rules/rules_bzlmodrio_jdk
base: main
token: ${{ secrets.AUTO_UPDATE_KEY }}
reviewers: pjreiniger
branch: autoupdate_${{ env.NEW_VERSION }}
title: "Auto Update to '${{ env.NEW_VERSION }}'"
117 changes: 117 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Build example project
on: [pull_request, push]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
build_native:
strategy:
fail-fast: false
matrix:
include:
# Build non-bzlmod, native
- { name: "windows - native", os: windows-2022, command: "test", config: "--noenable_bzlmod --config=windows", bazel_options: "--output_user_root=C:\\bazelroot", }
- { name: "windows arm - native", os: windows-2022, command: "build", config: "--noenable_bzlmod --config=windows_arm", bazel_options: "--output_user_root=C:\\bazelroot", }
- { name: "ubuntu - native", os: ubuntu-latest, command: "test", config: "--noenable_bzlmod --config=linux", bazel_options: "", }
- { name: "macos - native", os: macos-latest, command: "test", config: "--noenable_bzlmod --config=macos", bazel_options: "", }

# Build bzlmod, native
- { name: "windows - bzlmod native", os: windows-2022, command: "test", config: "--enable_bzlmod --config=windows", bazel_options: "--output_user_root=C:\\bazelroot", }
- { name: "windows arm - bzlmod native", os: windows-2022, command: "build", config: "--enable_bzlmod --config=windows_arm", bazel_options: "--output_user_root=C:\\bazelroot", }
- { name: "ubuntu - bzlmod native", os: ubuntu-latest, command: "test", config: "--enable_bzlmod --config=linux", bazel_options: "", }
- { name: "macos - bzlmod native", os: macos-latest, command: "test", config: "--enable_bzlmod --config=macos", bazel_options: "", }

name: "Build - ${{ matrix.name }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with: { python-version: '3.10.8' }
- run: bazel ${{ matrix.bazel_options }} build -k ${{ matrix.config }} --config=remote @rules_bzlmodrio_jdk//...
working-directory: tests
- run: bazel ${{ matrix.bazel_options }} build -k ${{ matrix.config }} --verbose_failures --config=remote //... || true
working-directory: tests
- run: bazel ${{ matrix.bazel_options }} ${{ matrix.command }} //... -k ${{ matrix.config }} --verbose_failures --config=remote
working-directory: tests


build_roborio:
strategy:
fail-fast: false
matrix:
include:
# Build non-bzlmod, roborio
- { name: "windows - roborio", os: windows-2022, command: "build", config: "--noenable_bzlmod --config=roborio", bazel_options: "--output_user_root=C:\\bazelroot", }
- { name: "ubuntu - roborio", os: ubuntu-latest, command: "build", config: "--noenable_bzlmod --config=roborio", bazel_options: "", }
- { name: "macos - roborio", os: macos-latest, command: "build", config: "--noenable_bzlmod --config=roborio", bazel_options: "", }

# Build bzlmod, roborio
# - { name: "windows - bzlmod roborio", os: windows-2022, command: "build", config: "--enable_bzlmod --config=roborio", bazel_options: "--output_user_root=C:\\bazelroot", }
- { name: "ubuntu - bzlmod roborio", os: ubuntu-latest, command: "build", config: "--enable_bzlmod --config=roborio", bazel_options: "", }
- { name: "macos - bzlmod roborio", os: macos-latest, command: "build", config: "--enable_bzlmod --config=roborio", bazel_options: "", }
name: "Build - ${{ matrix.name }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with: { python-version: '3.10.8' }
- name: Build and allow failure # TODO Sometimes symlinks don't get created correctly the first time around
run: bazel ${{ matrix.bazel_options }} ${{ matrix.command }} //... -k ${{ matrix.config }} --verbose_failures --config=remote || true
working-directory: tests
- run: bazel ${{ matrix.bazel_options }} ${{ matrix.command }} //... -k ${{ matrix.config }} --verbose_failures --config=remote
working-directory: tests

build_bullseye32:
strategy:
fail-fast: false
matrix:
include:
# Build non-bzlmod, bullseye32
- { name: "windows - bullseye32", os: windows-2022, command: "build", config: "--noenable_bzlmod --config=bullseye32", bazel_options: "--output_user_root=C:\\bazelroot", }
- { name: "ubuntu - bullseye32", os: ubuntu-latest, command: "build", config: "--noenable_bzlmod --config=bullseye32", bazel_options: "", }
- { name: "macos - bullseye32", os: macos-latest, command: "build", config: "--noenable_bzlmod --config=bullseye32", bazel_options: "", }

# Build bzlmod, bullseye32
- { name: "windows - bzlmod bullseye32", os: windows-2022, command: "build", config: "--enable_bzlmod --config=bullseye32", bazel_options: "--output_user_root=C:\\bazelroot", }
- { name: "ubuntu - bzlmod bullseye32", os: ubuntu-latest, command: "build", config: "--enable_bzlmod --config=bullseye32", bazel_options: "", }
- { name: "macos - bzlmod bullseye32", os: macos-latest, command: "build", config: "--enable_bzlmod --config=bullseye32", bazel_options: "", }
name: "Build - ${{ matrix.name }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with: { python-version: '3.10.8' }
- name: Build and allow failure # TODO Sometimes symlinks don't get created correctly the first time around
run: bazel ${{ matrix.bazel_options }} ${{ matrix.command }} //... -k ${{ matrix.config }} --verbose_failures --config=remote || true
working-directory: tests
- run: bazel ${{ matrix.bazel_options }} ${{ matrix.command }} //... -k ${{ matrix.config }} --verbose_failures --config=remote
working-directory: tests


build_bullseye64:
strategy:
fail-fast: false
matrix:
include:
# Build non-bzlmod, bullseye32:
- { name: "windows - bullseye64", os: windows-2022, command: "build", config: "--noenable_bzlmod --config=bullseye64", bazel_options: "--output_user_root=C:\\bazelroot", }
- { name: "ubuntu - bullseye64", os: ubuntu-latest, command: "build", config: "--noenable_bzlmod --config=bullseye64", bazel_options: "", }
- { name: "macos - bullseye64", os: macos-latest, command: "build", config: "--noenable_bzlmod --config=bullseye32", bazel_options: "", }

# Build bzlmod, bullseye32:
- { name: "windows - bzlmod bullseye64", os: windows-2022, command: "build", config: "--enable_bzlmod --config=bullseye64", bazel_options: "--output_user_root=C:\\bazelroot", }
- { name: "ubuntu - bzlmod bullseye64", os: ubuntu-latest, command: "build", config: "--enable_bzlmod --config=bullseye64", bazel_options: "", }
- { name: "macos - bzlmod bullseye64", os: macos-latest, command: "build", config: "--enable_bzlmod --config=bullseye64", bazel_options: "", }
name: "Build - ${{ matrix.name }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with: { python-version: '3.10.8' }
- name: Build and allow failure # TODO Sometimes symlinks don't get created correctly the first time around
run: bazel ${{ matrix.bazel_options }} ${{ matrix.command }} //... -k ${{ matrix.config }} --verbose_failures --config=remote || true
working-directory: tests
- run: bazel ${{ matrix.bazel_options }} ${{ matrix.command }} //... -k ${{ matrix.config }} --verbose_failures --config=remote
working-directory: tests
66 changes: 66 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Lint and Format

on: [pull_request, push]

jobs:
lint_python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
wpiformat:
name: "wpiformat"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Fetch main
run: |
git fetch origin main
git branch -f main origin/main
if: github.ref != 'refs/heads/main'
- uses: actions/setup-python@v4
with: { python-version: '3.10.8' }
- name: Install clang-format
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo sh -c "echo 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main' >> /etc/apt/sources.list.d/proposed-repositories.list"
sudo apt-get update -q
sudo apt-get install -y clang-format-14
- run: bazel run @rules_wpiformat//wpiformat -- -f ..
working-directory: tests
if: github.ref != 'refs/heads/main'

- name: Check Output
run: git --no-pager diff --exit-code HEAD
buildifier:
name: "buildifier"
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.20.x
uses: actions/setup-go@v4
with:
go-version: 1.20.x
id: go

- uses: actions/checkout@v3

- name: Install Buildifier
run: |
cd $(mktemp -d)
GO111MODULE=on go install github.com/bazelbuild/buildtools/buildifier@latest
- name: Run buildifier
run: buildifier -warnings all --lint=fix -r .

- name: Check Output
run: git --no-pager diff --exit-code HEAD

- name: Generate diff
run: git diff HEAD > buildifier-fixes.patch
if: ${{ failure() }}

- uses: actions/upload-artifact@v2
with:
name: buildifier fixes
path: buildifier-fixes.patch
if: ${{ failure() }}
Loading

0 comments on commit 285ec71

Please sign in to comment.