chore: enable go, shell, yaml formatters and bazel run //:format (#917)

This commit is contained in:
Greg Magolan 2024-08-20 14:56:40 -04:00 committed by GitHub
parent cccf5ac1b8
commit 11aacaf5df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 36 additions and 56 deletions

View File

@ -1,4 +1,3 @@
---
queue: bazel-lib-default
workspaces:
.:

View File

@ -32,7 +32,6 @@
# `aspect-workflows-` and job names prefixed with `aw-`. Conflicting workflow or
# job names will result in a bad configuration merge.
version: 2.1
jobs:
user-job:
docker:
@ -40,7 +39,6 @@ jobs:
steps:
- checkout
- run: echo "Example user CircleCI job that is not generated by Aspect Workflows."
workflows:
user-workflow:
jobs:

View File

@ -1,5 +1,4 @@
name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
@ -7,16 +6,13 @@ on:
branches: [main, 1.x]
pull_request:
branches: [main, 1.x]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
# Cancel previous actions from the same PR or branch except 'main' branch.
# See https://docs.github.com/en/actions/using-jobs/using-concurrency and https://docs.github.com/en/actions/learn-github-actions/contexts for more info.
group: concurrency-group::${{ github.workflow }}::${{ github.event.pull_request.number > 0 && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}${{ github.ref_name == 'main' && format('::{0}', github.run_id) || ''}}
cancel-in-progress: ${{ github.ref_name != 'main' }}
jobs:
# Prepares dynamic test matrix values
matrix-prep:
@ -66,7 +62,6 @@ jobs:
bazel-version: ${{ steps.bazel-version.outputs.res }}
config: ${{ steps.config.outputs.res }}
os: ${{ steps.os.outputs.res }}
test:
runs-on: ${{ matrix.os }}-latest
needs:
@ -120,10 +115,8 @@ jobs:
os: macos
- folder: .
os: windows
steps:
- uses: actions/checkout@v4
- name: Mount bazel caches
uses: actions/cache@v4
with:
@ -132,7 +125,6 @@ jobs:
~/.cache/bazel-repository-cache
key: bazel-cache-${{ matrix.bazel-version.version }}-${{ matrix.bzlmod }}-${{ matrix.os }}-${{ matrix.folder }}-${{ hashFiles('.bazelrc', '.bazelversion', '.bazeliskrc', '**/BUILD', '**/BUILD.bazel', '**/*.bzl', 'WORKSPACE', 'WORKSPACE.bazel', 'WORKSPACE.bzlmod', 'MODULE.bazel') }}
restore-keys: bazel-cache-${{ matrix.bazel-version.version }}-${{ matrix.bzlmod }}-${{ matrix.os }}-${{ matrix.folder }}-
- name: Configure Bazel version
working-directory: ${{ matrix.folder }}
shell: bash
@ -146,7 +138,6 @@ jobs:
# root .bazelrc brings these in with try-imports. In this CI workflows, we explicitly
# bring in the version specific bazelrc file with --bazelrc when we invoke bazel.
rm ${GITHUB_WORKSPACE//\\/\/}/.aspect/bazelrc/local/*.bazelrc
- name: Write rbe credentials
if: ${{ matrix.config == 'rbe' }}
working-directory: ${{ matrix.folder }}
@ -156,14 +147,12 @@ jobs:
echo "build --remote_header=x-buildbuddy-api-key=$BUILDBUDDY_API_KEY" > $HOME/.bazelrc
env:
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
# TODO: remove this block once we have Aspect CLI Windows releases
- name: Don't use Aspect CLI on Windows
if: matrix.os == 'windows'
working-directory: ${{ matrix.folder }}
shell: bash
run: rm -f .bazeliskrc
- name: bazel test //...
working-directory: ${{ matrix.folder }}
shell: bash
@ -178,13 +167,11 @@ jobs:
--build_tag_filters=-skip-on-bazel${{ matrix.bazel-version.major }} \
--enable_bzlmod=${{ matrix.bzlmod }} \
//...
- name: Integration tests
# Don't run integration tests on Windows since they are bash scripts and Windows runs Powershell
if: matrix.folder == '.' && matrix.os != 'windows' && matrix.bazel-version.major != '6'
# Find all shell scripts within e2e, echo the filename, execute, fail on error
run: find e2e/*.sh -maxdepth 1 -type f -exec sh -c 'echo "\n\n------------------------------- $0 -------------------------------" && BZLMOD_FLAG=${{ steps.set_bzlmod_flag.outputs.bzlmod_flag }} "$0" || kill $PPID' \{\} \;
- name: Verify bcr patches
if: matrix.folder == '.' && matrix.bzlmod == '1' && matrix.os == 'ubuntu' && matrix.bazel-version.major != '6'
run: patch --dry-run -p1 < .bcr/patches/*.patch

View File

@ -1,15 +1,12 @@
name: Verify PR title/description
on:
pull_request_target:
types:
- opened
- edited
- synchronize
permissions:
pull-requests: read
jobs:
check:
runs-on: ubuntu-latest

View File

@ -2,12 +2,10 @@
# 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:
- "v*.*.*"
jobs:
build:
# Go cross-compilation works from linux -> any platform
@ -28,7 +26,6 @@ jobs:
name: artifacts
path: artifacts/
retention-days: 1
release:
needs: build
runs-on: ubuntu-latest
@ -37,10 +34,8 @@ jobs:
# Fetch the built artifacts from build jobs above and extract into
# ${GITHUB_WORKSPACE}/artifacts/*
- uses: actions/download-artifact@v4
- name: Prepare workspace snippet
run: .github/workflows/release_prep.sh > release_notes.txt
- uses: softprops/action-gh-release@v2
with:
# Use GH feature to populate the changelog automatically

View File

@ -5,7 +5,6 @@
# 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

View File

@ -2,7 +2,6 @@ bats_load_library "bats-support"
bats_load_library "bats-assert"
@test 'basic' {
run echo 'have'
assert_output 'have'
run echo 'have'
assert_output 'have'
}

View File

@ -3,6 +3,5 @@ bats_load_library 'bats-assert'
bats_load_library 'bats-custom'
@test 'env' {
run custom_test_fn
run custom_test_fn
}

View File

@ -2,7 +2,6 @@ bats_load_library 'bats-support'
bats_load_library 'bats-assert'
@test 'assert_output() check for existence' {
run echo 'have'
assert_output 'have'
run echo 'have'
assert_output 'have'
}

View File

@ -2,7 +2,6 @@ bats_load_library 'bats-support'
bats_load_library 'bats-assert'
@test 'env' {
run echo $USE_BAZEL_VERSION
assert_output 'latest'
run echo $USE_BAZEL_VERSION
assert_output 'latest'
}

View File

@ -3,8 +3,7 @@ bats_load_library 'bats-assert'
bats_load_library 'bats-file'
@test 'env expansion' {
run echo $DATA_PATH
assert_output 'lib/tests/bats/data.bin'
assert_file_exists 'lib/tests/bats/data.bin'
run echo $DATA_PATH
assert_output 'lib/tests/bats/data.bin'
assert_file_exists 'lib/tests/bats/data.bin'
}

View File

@ -3,8 +3,9 @@
package common
import (
"golang.org/x/sys/unix"
"os"
"golang.org/x/sys/unix"
)
// https://keith.github.io/xcode-man-pages/clonefile.2.html

View File

@ -13,10 +13,12 @@ import (
type pathSet map[string]bool
var srcPaths = pathSet{}
var hardlink = false
var verbose = false
var preserveMTime = false
var (
srcPaths = pathSet{}
hardlink = false
verbose = false
preserveMTime = false
)
type walker struct {
queue chan<- common.CopyOpts

View File

@ -47,11 +47,15 @@ type config struct {
TargetWorkspace *string
}
type copyMap map[string]fileInfo
type pathSet map[string]bool
type (
copyMap map[string]fileInfo
pathSet map[string]bool
)
var copySet = copyMap{}
var mkdirSet = pathSet{}
var (
copySet = copyMap{}
mkdirSet = pathSet{}
)
func parseConfig(configPath string, wkspName *string) (*config, error) {
f, err := os.Open(configPath)

View File

@ -60,9 +60,9 @@ func main() {
content = strings.ReplaceAll(content, key, value)
}
var mode os.FileMode = 0666
var mode os.FileMode = 0o666
if executable {
mode = 0777
mode = 0o777
}
err = os.WriteFile(args[1], []byte(content), mode)
if err != nil {
@ -89,5 +89,4 @@ func parseStatusFile(statusFilePath string) (map[string]string, error) {
}
return results, nil
}

View File

@ -2,11 +2,10 @@ load("@aspect_rules_lint//format:defs.bzl", "format_multirun")
format_multirun(
name = "format",
# TODO: enable formatters in follow-up PR
# go = "@aspect_rules_lint//format:gofumpt",
# shell = "@aspect_rules_lint//format:shfmt",
go = "@aspect_rules_lint//format:gofumpt",
shell = "@aspect_rules_lint//format:shfmt",
starlark = "@buildifier_prebuilt//:buildifier",
tags = ["manual"],
visibility = ["//:__subpackages__"],
# yaml = "@aspect_rules_lint//format:yamlfmt",
yaml = "@aspect_rules_lint//format:yamlfmt",
)

5
yamlfmt.yaml Normal file
View File

@ -0,0 +1,5 @@
gitignore_excludes: true
doublestar: true
exclude:
- .circleci/config.yml
- lib/tests/yq/empty.yaml