-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f0a9b2e
Showing
30 changed files
with
1,369 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
directories: | ||
. | ||
|
||
derive_targets_from_directories: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Bazel settings that apply to this repository. | ||
# Take care to document any settings that you expect users to apply. | ||
# Settings that apply only to CI are in .github/workflows/ci.bazelrc | ||
build --nolegacy_external_runfiles | ||
|
||
# Load any settings specific to the current user. | ||
# .bazelrc.user should appear in .gitignore so that settings are not shared with team members | ||
# This needs to be last statement in this | ||
# config, as the user configuration should be able to overwrite flags from this file. | ||
# See https://docs.bazel.build/versions/master/best-practices.html#bazelrc | ||
# (Note that we use .bazelrc.user so the file appears next to .bazelrc in directory listing, | ||
# rather than user.bazelrc as suggested in the Bazel docs) | ||
try-import %workspace%/.bazelrc.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
5.1.1 | ||
# The first line of this file is used by Bazelisk and Bazel to be sure | ||
# the right version of Bazel is used to build and test this repo. | ||
# This also defines which version is used on CI. | ||
# | ||
# Note that you should also run integration_tests against other Bazel | ||
# versions you support. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Bazel settings to apply on CI only | ||
# Included with a --bazelrc option in the call to bazel | ||
build --announce_rc | ||
test --test_output=errors | ||
build --disk_cache=$HOME/.cache/bazel | ||
build --repository_cache=$HOME/.cache/bazel-repo | ||
test --test_env=XDG_CACHE_HOME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: CI | ||
|
||
# Controls when the action will run. | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the main branch | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
- macos-latest | ||
# builds on windows fail | ||
# https://github.com/bazelbuild/rules_docker/issues/1524 | ||
# https://github.com/bazelbuild/rules_docker/issues/1438 | ||
# - windows-latest | ||
bazel: [ 4.2.1, 5.1.1 ] | ||
# The type of runner that the job will run on | ||
runs-on: ${{ matrix.os }} | ||
|
||
name: test-on-${{ matrix.os }}-with-bazel-${{ matrix.bazel }} | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v3 | ||
- uses: bazelbuild/setup-bazelisk@v2 | ||
- name: Mount bazel action cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: "~/.cache/bazel" | ||
key: bazel | ||
- name: Mount bazel repo cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: "~/.cache/bazel-repo" | ||
key: bazel-repo | ||
- name: Set Bazelisk Version ${{ matrix.bazel }} | ||
run: echo ${{ matrix.bazel }} > .bazelversion | ||
- name: Build | ||
shell: bash | ||
env: | ||
# Bazelisk will download bazel to here | ||
XDG_CACHE_HOME: ~/.cache/bazel-repo | ||
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc build ... | ||
- name: Test | ||
shell: bash | ||
env: | ||
# Bazelisk will download bazel to here | ||
XDG_CACHE_HOME: ~/.cache/bazel-repo | ||
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Cut a release whenever a new tag is pushed to the repo. | ||
# You should use an annotated tag, like `git tag -a v1.2.3` | ||
# and put the release notes into the commit message for the tag. | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*.*.*" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- uses: bazelbuild/setup-bazelisk@v2 | ||
- name: Check git state is clean | ||
run: git status --porcelain | ||
- name: Export release version | ||
run: 'echo "RELEASE_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV' | ||
- name: Build release archive | ||
env: | ||
# Bazelisk will download bazel to here | ||
XDG_CACHE_HOME: ~/.cache/bazel-repo | ||
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc build //:slamdev_rules_helmdiff | ||
- name: Set versioned archive name | ||
run: cp bazel-bin/slamdev_rules_helmdiff.tar.gz bazel-bin/slamdev_rules_helmdiff-v${{ env.RELEASE_VERSION }}.tar.gz | ||
- name: Export checksum | ||
run: 'echo "RELEASE_CHECKSUM=$(shasum -b -a 256 bazel-bin/slamdev_rules_helmdiff-v${{ env.RELEASE_VERSION }}.tar.gz | cut -d " " -f 1)" >> $GITHUB_ENV' | ||
- name: Upload release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: bazel-bin/slamdev_rules_helmdiff-v${{ env.RELEASE_VERSION }}.tar.gz | ||
fail_on_unmatched_files: true | ||
body: | | ||
```starlark | ||
http_archive( | ||
name = "slamdev_rules_helmdiff", | ||
sha256 = "${{ env.RELEASE_CHECKSUM }}", | ||
url = "https://github.com/slamdev/rules_helmdiff/releases/download/${{ env.RELEASE_VERSION }}/slamdev_rules_helmdiff-v${{ env.RELEASE_VERSION }}.tar.gz", | ||
) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bazel-* | ||
.ijwb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# See CONTRIBUTING.md for instructions. | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
|
||
# Commitizen runs in commit-msg stage | ||
# but we don't want to run the other hooks on commit messages | ||
default_stages: [commit] | ||
|
||
repos: | ||
# Check formatting and lint for starlark code | ||
- repo: https://github.com/keith/pre-commit-buildifier | ||
rev: 4.0.1.1 | ||
hooks: | ||
- id: buildifier | ||
- id: buildifier-lint | ||
# Enforce that commit messages allow for later changelog generation | ||
- repo: https://github.com/commitizen-tools/commitizen | ||
rev: v2.18.0 | ||
hooks: | ||
# Requires that commitizen is already installed | ||
- id: commitizen | ||
stages: [commit-msg] | ||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: "v2.4.0" | ||
hooks: | ||
- id: prettier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
load("@rules_pkg//:pkg.bzl", "pkg_tar") | ||
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary") | ||
|
||
gazelle_binary( | ||
name = "gazelle_bin", | ||
languages = ["@bazel_skylib//gazelle/bzl"], | ||
) | ||
|
||
gazelle( | ||
name = "gazelle", | ||
gazelle = "gazelle_bin", | ||
) | ||
|
||
# This declares the release artifact users | ||
pkg_tar( | ||
name = "slamdev_rules_helmdiff", | ||
srcs = [ | ||
"LICENSE", | ||
"README.md", | ||
"//helmdiff:package_content", | ||
], | ||
extension = "tar.gz", | ||
# It is all source code, so make it read-only. | ||
mode = "0444", | ||
# Make it owned by root so it does not have the uid of the CI robot. | ||
owner = "0.0", | ||
strip_prefix = ".", | ||
) | ||
|
||
bzl_library( | ||
name = "internal_deps", | ||
srcs = ["internal_deps.bzl"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@bazel_tools//tools/build_defs/repo:http.bzl", | ||
"@bazel_tools//tools/build_defs/repo:utils.bzl", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# How to Contribute | ||
|
||
## Formatting | ||
|
||
Starlark files should be formatted by buildifier. | ||
We suggest using a pre-commit hook to automate this. | ||
First [install pre-commit](https://pre-commit.com/#installation), | ||
then run | ||
|
||
```shell | ||
pre-commit install | ||
``` | ||
|
||
Otherwise later tooling on CI may yell at you about formatting/linting violations. | ||
|
||
## Updating BUILD files | ||
|
||
Some targets are generated from sources. | ||
Currently this is just the `bzl_library` targets. | ||
Run `bazel run //:gazelle` to keep them up-to-date. | ||
|
||
## Using this as a development dependency of other rules | ||
|
||
You'll commonly find that you develop in another WORKSPACE, such as | ||
some other ruleset that depends on rules_helmdiff, or in a nested | ||
WORKSPACE in the integration_tests folder. | ||
|
||
To always tell Bazel to use this directory rather than some release | ||
artifact or a version fetched from the internet, run this from this | ||
directory: | ||
|
||
```sh | ||
OVERRIDE="--override_repository=rules_helmdiff=$(pwd)/rules_helmdiff" | ||
echo "build $OVERRIDE" >> ~/.bazelrc | ||
echo "query $OVERRIDE" >> ~/.bazelrc | ||
``` | ||
|
||
This means that any usage of `@rules_helmdiff` on your system will point to this folder. |
Oops, something went wrong.