Skip to content

Commit 55ff3e8

Browse files
committed
rules_ada v0.1.0
1 parent 8c836be commit 55ff3e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+3627
-0
lines changed

.bazelrc

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
###############################################################################
2+
## Bazel Configuration Flags
3+
##
4+
## `.bazelrc` is a Bazel configuration file.
5+
## https://bazel.build/docs/best-practices#bazelrc-file
6+
###############################################################################
7+
8+
# Skip building runfiles links for faster builds.
9+
build --nobuild_runfile_links
10+
11+
# https://bazel.build/reference/command-line-reference#flag--enable_platform_specific_config
12+
common --enable_platform_specific_config
13+
14+
# Enable the only currently supported report type
15+
# https://bazel.build/reference/command-line-reference#flag--combined_report
16+
coverage --combined_report=lcov
17+
18+
# Avoid fully cached builds reporting no coverage and failing CI
19+
# https://bazel.build/reference/command-line-reference#flag--experimental_fetch_all_coverage_outputs
20+
coverage --experimental_fetch_all_coverage_outputs
21+
22+
# Required for some of the tests
23+
# https://bazel.build/reference/command-line-reference#flag--experimental_cc_shared_library
24+
common --experimental_cc_shared_library
25+
26+
# Disable network access in sandboxes by default.
27+
build --sandbox_default_allow_network=false
28+
29+
###############################################################################
30+
## Incompatibility flags
31+
###############################################################################
32+
33+
# https://github.com/bazelbuild/bazel/issues/8195
34+
build --incompatible_disallow_empty_glob=true
35+
36+
# https://github.com/bazelbuild/bazel/issues/12821
37+
build --nolegacy_external_runfiles
38+
39+
# https://github.com/bazelbuild/bazel/issues/23043.
40+
build --incompatible_autoload_externally=
41+
42+
###############################################################################
43+
## Custom user flags
44+
##
45+
## This should always be the last thing in the `.bazelrc` file to ensure
46+
## consistent behavior when setting flags in that file as `.bazelrc` files are
47+
## evaluated top to bottom.
48+
###############################################################################
49+
50+
try-import %workspace%/user.bazelrc

.github/github.bazelrc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Bazel settings for use in Github CI
2+
3+
# Always display the flags being used
4+
common --announce_rc
5+
6+
# Show errors in CI
7+
test --test_output=errors
8+
9+
# Show more information about failures
10+
build --verbose_failures
11+
12+
# UI for cleaner CI output
13+
common --color=no
14+
common --show_timestamps
15+
16+
# Show all failures
17+
common --keep_going
18+
19+
# Avoid gnulib tests which are highly volatile on different platforms.
20+
test --test_tag_filters=-gnu_autoconf_test

.github/release_notes.template

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# {version}
2+
3+
## Setup
4+
```python
5+
bazel_dep(name = "rules_ada", version = "{version}")
6+
```
7+
8+
Additional documentation can be found at: https://github.com/periareon/rules_ada

.github/workflows/bcr-publish.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# See https://github.com/bazel-contrib/publish-to-bcr
2+
name: Publish to BCR
3+
4+
on:
5+
# Allow the publish workflow to be called from another workflow.
6+
# In this case, we trigger it from the release.yaml workflow.
7+
workflow_call:
8+
inputs:
9+
release_version:
10+
required: true
11+
type: string
12+
secrets:
13+
BCR_PUBLISH_TOKEN:
14+
required: true
15+
# In case of problems, let release engineers retry by manually dispatching
16+
# the workflow from the GitHub UI.
17+
workflow_dispatch:
18+
inputs:
19+
release_version:
20+
required: true
21+
type: string
22+
description: Release version to publish to the Bazel Central Registry
23+
templates_ref:
24+
default: ''
25+
type: string
26+
description: Override the ref to read .bcr templates from
27+
jobs:
28+
publish:
29+
uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v1.1.0
30+
with:
31+
attest: false
32+
tag_name: ${{ inputs.release_version }}
33+
author_name: periareon-bot
34+
author_email: 260522848+periareon-bot@users.noreply.github.com
35+
# Tags don't include a "v" prefix
36+
tag_prefix: ""
37+
# GitHub repository which is a fork of the upstream where the Pull Request will be opened.
38+
registry_fork: periareon/bazel-central-registry
39+
templates_ref: ${{ inputs.templates_ref || inputs.release_version }}
40+
draft: false
41+
permissions:
42+
contents: write
43+
secrets:
44+
publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}

.github/workflows/ci.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
merge_group:
8+
pull_request:
9+
types:
10+
- opened
11+
- synchronize
12+
13+
env:
14+
BAZEL_STARTUP_FLAGS: --bazelrc=${{ github.workspace }}/.github/github.bazelrc
15+
16+
jobs:
17+
ci:
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- os: macos-latest
24+
- os: ubuntu-24.04
25+
- os: ubuntu-24.04-arm
26+
- os: windows-2022
27+
steps:
28+
# Checkout the code
29+
- uses: actions/checkout@v4
30+
31+
- uses: bazel-contrib/setup-bazel@0.14.0
32+
with:
33+
bazelisk-cache: true
34+
disk-cache: ${{ github.workflow }}
35+
repository-cache: true
36+
37+
- name: Setup Bazelrc (Windows)
38+
run: |
39+
echo "TEMP=$env:RUNNER_TEMP" >> "$env:GITHUB_ENV"
40+
echo "TMP=$env:RUNNER_TEMP" >> "$env:GITHUB_ENV"
41+
echo "startup --output_user_root=D:/bzl" > ./user.bazelrc
42+
if: startswith(runner.os, 'Windows')
43+
- name: Setup Bazelrc
44+
run: |
45+
echo "common --keep_going" >> ./user.bazelrc
46+
47+
# Build and Test the code
48+
- name: Test (Unix)
49+
run: bazel ${BAZEL_STARTUP_FLAGS[@]} test //...
50+
if: startswith(runner.os, 'Windows') != true
51+
- name: Test (Windows)
52+
run: bazel $env:BAZEL_STARTUP_FLAGS test //...
53+
if: startswith(runner.os, 'Windows')
54+
55+
ci-format:
56+
runs-on: ubuntu-24.04
57+
steps:
58+
# Checkout the code
59+
- uses: actions/checkout@v4
60+
- uses: bazel-contrib/setup-bazel@0.14.0
61+
with:
62+
bazelisk-cache: true
63+
disk-cache: ${{ github.workflow }}
64+
repository-cache: true
65+
66+
- name: Buildifier
67+
run: |
68+
wget "https://github.com/bazelbuild/buildtools/releases/download/v${BUILDIFIER_VERSION}/buildifier-linux-amd64" -O buildifier
69+
chmod +x ./buildifier
70+
./buildifier -lint=warn -mode=check -warnings=all -r ${{ github.workspace }}
71+
rm ./buildifier
72+
env:
73+
BUILDIFIER_VERSION: 8.2.0
74+
- uses: DoozyX/clang-format-lint-action@v0.14
75+
with:
76+
source: '.'
77+
extensions: 'h,c,cc'
78+
clangFormatVersion: 14

.github/workflows/docs.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
docs:
10+
name: Docs
11+
permissions:
12+
contents: write
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@master
16+
- name: Run tests
17+
run: bazel run --compilation_mode=opt --stamp //docs:publish_book
18+
- name: Deploy to GitHub Pages
19+
uses: JamesIves/github-pages-deploy-action@4.1.7
20+
with:
21+
branch: gh-pages # The branch the action should deploy to.
22+
folder: docs/book # The folder the action should deploy.

.github/workflows/release.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# ---
2+
# name: Release
3+
# on:
4+
# workflow_dispatch:
5+
# push:
6+
# branches:
7+
# - main
8+
# paths:
9+
# # Only trigger for new releases
10+
# - "version.bzl"
11+
12+
# defaults:
13+
# run:
14+
# shell: bash
15+
16+
# env:
17+
# BAZEL_STARTUP_FLAGS: --bazelrc=${{ github.workspace }}/.github/github.bazelrc
18+
19+
# jobs:
20+
# release:
21+
# if: ${{ github.repository_owner == 'periareon' }}
22+
# permissions:
23+
# contents: write
24+
# actions: write
25+
# attestations: write
26+
# outputs:
27+
# release_version: ${{ steps.version.outputs.release_version }}
28+
# runs-on: ubuntu-latest
29+
# steps:
30+
# - uses: actions/checkout@v2
31+
# with:
32+
# ref: main
33+
# - name: Detect the current version
34+
# id: version
35+
# run: |
36+
# version="$(grep 'VERSION =' ./version.bzl | sed 's/VERSION = "//' | sed 's/"//')"
37+
# echo "RELEASE_VERSION=${version}" >> $GITHUB_ENV
38+
# echo "release_version=${version}" >> $GITHUB_OUTPUT
39+
# # Ensure this does not exclude the module used for the .bcr presubmit job.
40+
# - name: Create release artifact
41+
# run: |
42+
# tar -czf ${{ github.workspace }}/.github/rules_ada.tar.gz --exclude=".git" --exclude=".github" -C ${{ github.workspace }} .
43+
# sha256_base64="$(shasum --algorithm 256 ${{ github.workspace }}/.github/rules_ada.tar.gz | awk '{ print $1 }' | xxd -r -p | base64)"
44+
# echo "ARCHIVE_SHA256_BASE64=${sha256_base64}" >> "${GITHUB_ENV}"
45+
# - name: Generate release notes
46+
# run: |
47+
# # Generate the release notes
48+
# sed 's/{version}/${{env.RELEASE_VERSION}}/g' ${{ github.workspace }}/.github/release_notes.template \
49+
# | sed 's#{sha256_base64}#${{ env.ARCHIVE_SHA256_BASE64 }}#g' \
50+
# > ${{ github.workspace }}/.github/release_notes.txt
51+
# - name: Release
52+
# uses: softprops/action-gh-release@v1
53+
# id: rules_release
54+
# with:
55+
# generate_release_notes: true
56+
# tag_name: ${{ env.RELEASE_VERSION }}
57+
# body_path: ${{ github.workspace }}/.github/release_notes.txt
58+
# target_commitish: ${{ github.base_ref }}
59+
# - name: "Upload the rules archive"
60+
# uses: actions/upload-release-asset@v1
61+
# env:
62+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
# with:
64+
# upload_url: ${{ steps.rules_release.outputs.upload_url }}
65+
# asset_name: rules_ada-${{ env.RELEASE_VERSION }}.tar.gz
66+
# asset_path: ${{ github.workspace }}/.github/rules_ada.tar.gz
67+
# asset_content_type: application/gzip
68+
69+
# bcr-publish:
70+
# needs: [release]
71+
# permissions:
72+
# contents: write
73+
# uses: ./.github/workflows/bcr-publish.yaml
74+
# with:
75+
# release_version: ${{ needs.release.outputs.release_version }}
76+
# secrets:
77+
# BCR_PUBLISH_TOKEN: ${{ secrets.BCR_PUBLISH_TOKEN }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Git ignore patterns
2+
3+
/bazel-*
4+
user.bazelrc

BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
exports_files([
2+
"LICENSE",
3+
"MODULE.bazel",
4+
"version.bzl",
5+
])

MODULE.bazel

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""rules_ada"""
2+
3+
module(
4+
name = "rules_ada",
5+
version = "0.1.0",
6+
)
7+
8+
bazel_dep(name = "platforms", version = "1.0.0")
9+
bazel_dep(name = "bazel_skylib", version = "1.8.2")
10+
bazel_dep(name = "rules_cc", version = "0.2.17")
11+
bazel_dep(name = "rules_shell", version = "0.6.1")
12+
13+
gnat = use_extension("//ada:extensions.bzl", "gnat_extension")
14+
use_repo(gnat, "gnat_toolchains")
15+
16+
register_toolchains(
17+
"@gnat_toolchains//:all",
18+
)
19+
20+
bazel_dep(name = "rules_rust", version = "0.69.0", dev_dependency = True)
21+
bazel_dep(name = "rules_rust_mdbook", version = "0.69.0", dev_dependency = True)
22+
bazel_dep(name = "rules_venv", version = "0.11.0", dev_dependency = True)
23+
bazel_dep(name = "stardoc", version = "0.8.1", dev_dependency = True)
24+
25+
rust = use_extension(
26+
"@rules_rust//rust:extensions.bzl",
27+
"rust",
28+
dev_dependency = True,
29+
)
30+
rust.toolchain(edition = "2021")
31+
use_repo(rust, "rust_toolchains")
32+
33+
register_toolchains(
34+
"@rust_toolchains//:all",
35+
dev_dependency = True,
36+
)

0 commit comments

Comments
 (0)