Skip to content

Commit

Permalink
chore: add pre-commit prettier check
Browse files Browse the repository at this point in the history
This ensures that our markdown is wrapped to 80cols, so that when help topics are presented by the CLI
we don't have to do anything special to wrap them to fit
  • Loading branch information
alexeagle committed Sep 15, 2021
1 parent b38e25b commit 9880c2b
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 115 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: CI

# Controls when the action will run.
# 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 ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down Expand Up @@ -35,4 +35,6 @@ jobs:
env:
# Bazelisk will download bazel to here
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //...
run:
bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test
//...
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ jobs:
env:
# Bazelisk will download bazel to here
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test --config=release //...
run:
bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test
--config=release //...
- name: Release
uses: softprops/action-gh-release@v1
with:
Expand All @@ -28,4 +30,4 @@ jobs:
bazel-out/*-opt-*/bin/cmd/aspect/aspect-linux_arm64
bazel-out/*-opt-*/bin/cmd/aspect/aspect-darwin_amd64
bazel-out/*-opt-*/bin/cmd/aspect/aspect-darwin_arm64
bazel-out/*-opt-*/bin/cmd/aspect/aspect-windows_amd64.exe
bazel-out/*-opt-*/bin/cmd/aspect/aspect-windows_amd64.exe
24 changes: 14 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
# Locally-authored hooks for better hermeticity
- repo: local
- repo: local
hooks:
- id: go-fmt
name: go fmt
description: Runs `go fmt` and asserts no changes are needed.
entry: ./hooks/go-fmt.sh
language: script
files: \.go$
- id: go-fmt
name: go fmt
description: Runs `go fmt` and asserts no changes are needed.
entry: ./hooks/go-fmt.sh
language: script
files: \.go$
- repo: https://github.com/syntaqx/git-hooks
rev: v0.0.17
hooks:
# Requires that shellcheck is already installed
- id: shellcheck
# Requires that shellcheck is already installed
- id: shellcheck
- repo: https://github.com/commitizen-tools/commitizen
rev: v2.18.0
hooks:
Expand All @@ -30,4 +30,8 @@ repos:
args: &args
- --warnings=all
- id: buildifier-lint
args: *args
args: *args
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.4.0"
hooks:
- id: prettier
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# These are generated by cobra
docs/*.md
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
proseWrap: always
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ Want to contribute? Great!

## Formatting/linting

We suggest using a pre-commit hook to automate this.
First [install pre-commit](https://pre-commit.com/#installation),
then run
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
Expand Down
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
# aspect-cli

This is the frontend for the Aspect build tool.
It is currently just a wrapper around bazelisk or bazel, meant to install in tools/bazel.
This is the frontend for the Aspect build tool. It is currently just a wrapper
around bazelisk or bazel, meant to install in tools/bazel.

In the future, we might totally replace the bazel C++ client, and this tool would be a gRPC client of the bazel server.
In the future, we might totally replace the bazel C++ client, and this tool
would be a gRPC client of the bazel server.

## TODOs

- [ ] figure out how to cut and host a release
GH Action to cut/publish release whenever a tag is pushed upstream
- [ ] figure out how to cut and host a release GH Action to cut/publish release
whenever a tag is pushed upstream
- [ ] document lots of ways to install, including a bash one-liner
- [ ] help user ensure bash/zsh completion working
- [ ] warn user if Bazel version is floating
(no bazelisk, or using latest in .bazelversion, or no .bazelversion)
- [ ] warn user if Bazel version is floating (no bazelisk, or using latest in
.bazelversion, or no .bazelversion)

# Use Cases

## When I am confused by bazel

I can find that Aspect is an easier-to-use wrapper and feel motivated and comfortable to try it immediately.
I can find that Aspect is an easier-to-use wrapper and feel motivated and
comfortable to try it immediately.

From aspect.build/install I quickly pick an Installation option, and am guided through to successful install.
From aspect.build/install I quickly pick an Installation option, and am guided
through to successful install.

The first time I run `aspect` in interactive mode,
- I choose whether I want to install for all users of my workspace, in which case a bootstrap bit is added to tools/bazel ensuring that the tool is downloaded and spawned for anyone cloning my repo.

- I choose whether I want to install for all users of my workspace, in which
case a bootstrap bit is added to tools/bazel ensuring that the tool is
downloaded and spawned for anyone cloning my repo.

## When I run bare `bazel`

Expand Down
2 changes: 1 addition & 1 deletion cmd/aspect/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func NewRootCmd(streams ioutils.Streams, defaultInteractive bool) *cobra.Command
cmd.AddCommand(&cobra.Command{
Use: "target-syntax",
Short: "Documentation on Bazel's syntax for targets",
Long: topics.Read("target-syntax"),
Long: topics.Read("target-syntax.md"),
})

return cmd
Expand Down
3 changes: 2 additions & 1 deletion cmd/docgen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ Run `bazel run //cmd/docgen /tmp | less`
Note that piping the command to less is required, so that it's not interactive.
Otherwise we'll turn on coloring and put ANSI escape codes in our markdown.

The github.com/aspect-dev/docs repo will do the work of publishing the outputs of this docgen step.
The github.com/aspect-dev/docs repo will do the work of publishing the outputs
of this docgen step.
2 changes: 1 addition & 1 deletion docs/help/topics/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "topics",
srcs = ["main.go"],
data = ["target-syntax"],
data = ["target-syntax.md"],
importpath = "aspect.build/cli/docs/help/topics",
visibility = ["//visibility:public"],
deps = ["@io_bazel_rules_go//go/tools/bazel:go_default_library"],
Expand Down
83 changes: 0 additions & 83 deletions docs/help/topics/target-syntax

This file was deleted.

73 changes: 73 additions & 0 deletions docs/help/topics/target-syntax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Target pattern syntax

The BUILD file label syntax is used to specify a single target. Target patterns
generalize this syntax to sets of targets, and also support
working-directory-relative forms, recursion, subtraction and filtering.
Examples:

Specifying a single target:

//foo/bar:wiz The single target '//foo/bar:wiz'. foo/bar/wiz Equivalent to:
'//foo/bar/wiz:wiz' if foo/bar/wiz is a package, '//foo/bar:wiz' if foo/bar is a
package, '//foo:bar/wiz' otherwise. //foo/bar Equivalent to '//foo/bar:bar'.

Specifying all rules in a package:

//foo/bar:all Matches all rules in package 'foo/bar'.

Specifying all rules recursively beneath a package:

//foo/...:all Matches all rules in all packages beneath directory 'foo'.
//foo/... (ditto)

By default, directory symlinks are followed when performing this recursive
traversal, except those that point to under the output base (for example, the
convenience symlinks that are created in the root directory of the workspace)
But we understand that your workspace may intentionally contain directories with
weird symlink structures that you don't want consumed. As such, if a directory
has a file named
'DONT_FOLLOW_SYMLINKS_WHEN_TRAVERSING_THIS_DIRECTORY_VIA_A_RECURSIVE_TARGET_PATTERN'
then symlinks in that directory won't be followed when evaluating recursive
target patterns.

Working-directory relative forms: (assume cwd = 'workspace/foo')

Target patterns which do not begin with '//' are taken relative to the working
directory. Patterns which begin with '//' are always absolute.

...:all Equivalent to '//foo/...:all'. ... (ditto)

bar/...:all Equivalent to '//foo/bar/...:all'. bar/... (ditto)

bar:wiz Equivalent to '//foo/bar:wiz'. :foo Equivalent to '//foo:foo'.

bar Equivalent to '//foo/bar:bar'. foo/bar Equivalent to '//foo/foo/bar:bar'.

bar:all Equivalent to '//foo/bar:all'. :all Equivalent to '//foo:all'.

Summary of target wildcards:

:all, Match all rules in the specified packages. :\*, :all-targets Match all
targets (rules and files) in the specified packages, including .par and
\_deploy.jar files.

Subtractive patterns:

Target patterns may be preceded by '-', meaning they should be subtracted from
the set of targets accumulated by preceding patterns. (Note that this means
order matters.) For example:

% bazel build -- foo/... -foo/contrib/...

builds everything in 'foo', except 'contrib'. In case a target not under
'contrib' depends on something under 'contrib' though, in order to build the
former bazel has to build the latter too. As usual, the '--' is required to
prevent '-f' from being interpreted as an option.

When running the test command, test suite expansion is applied to each target
pattern in sequence as the set of targets is evaluated. This means that
individual tests from a test suite can be excluded by a later target pattern. It
also means that an exclusion target pattern which matches a test suite will
exclude all tests which that test suite references. (Targets that would be
matched by the list of target patterns without any test suite expansion are also
built unless --build_tests_only is set.)

0 comments on commit 9880c2b

Please sign in to comment.