From ffc5a7bfa12aaa41b28058294024fbfe15ec0a80 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Mon, 13 May 2024 23:51:10 -0700 Subject: [PATCH] chore: align ci patterns (#843) --- .aspect/bazelrc/.gitignore | 1 + .aspect/workflows/config.yaml | 47 ++++-- .bazelrc | 1 + .circleci/config.yml | 149 +++++++++++++++-- .github/workflows/ci.bazelrc | 17 +- .github/workflows/ci.yaml | 174 ++++++++++---------- .github/workflows/release.yml | 2 +- .gitignore | 21 ++- .pre-commit-config.yaml | 2 +- WORKSPACE | 3 - e2e/copy_action/.bazelrc | 15 ++ e2e/copy_action/MODULE.bazel | 10 +- e2e/copy_to_directory/.bazelrc | 15 ++ e2e/copy_to_directory/MODULE.bazel | 11 +- e2e/coreutils/.bazelrc | 15 ++ e2e/coreutils/MODULE.bazel | 10 +- e2e/external_copy_to_directory/.bazelrc | 15 ++ e2e/external_copy_to_directory/MODULE.bazel | 11 +- e2e/smoke/.bazelrc | 20 ++- e2e/smoke/MODULE.bazel | 11 +- e2e/write_source_files/.bazelrc | 15 ++ e2e/write_source_files/MODULE.bazel | 10 +- tools/format/BUILD.bazel | 12 -- 23 files changed, 387 insertions(+), 200 deletions(-) create mode 100644 .aspect/bazelrc/.gitignore diff --git a/.aspect/bazelrc/.gitignore b/.aspect/bazelrc/.gitignore new file mode 100644 index 0000000..74824b0 --- /dev/null +++ b/.aspect/bazelrc/.gitignore @@ -0,0 +1 @@ +user.bazelrc diff --git a/.aspect/workflows/config.yaml b/.aspect/workflows/config.yaml index 148a8f4..e406bca 100644 --- a/.aspect/workflows/config.yaml +++ b/.aspect/workflows/config.yaml @@ -4,22 +4,7 @@ workspaces: .: tasks: - test: - e2e/smoke: - icon: bazel - tasks: - - test: - queue: bazel-lib-small - - format: - without: true - - gazelle: - without: true - - configure: - without: true - - buildifier: - without: true - - delivery: - without: true - e2e/coreutils: + e2e/copy_action: icon: bazel tasks: - test: @@ -49,6 +34,21 @@ workspaces: without: true - delivery: without: true + e2e/coreutils: + icon: bazel + tasks: + - test: + queue: bazel-lib-small + - format: + without: true + - gazelle: + without: true + - configure: + without: true + - buildifier: + without: true + - delivery: + without: true e2e/external_copy_to_directory: icon: bazel tasks: @@ -64,6 +64,21 @@ workspaces: without: true - delivery: without: true + e2e/smoke: + icon: bazel + tasks: + - test: + queue: bazel-lib-small + - format: + without: true + - gazelle: + without: true + - configure: + without: true + - buildifier: + without: true + - delivery: + without: true tasks: - test: hooks: diff --git a/.bazelrc b/.bazelrc index 40793ae..185842a 100644 --- a/.bazelrc +++ b/.bazelrc @@ -11,6 +11,7 @@ import %workspace%/.aspect/bazelrc/performance.bazelrc # For testing our --stamp behavior. # Normally users would use a --workspace_status_command with a script that calls `git describe`. build --embed_label=v1.2.3 + # Mock versioning command to test the --stamp behavior build --workspace_status_command="echo BUILD_SCM_VERSION 1.2.3" diff --git a/.circleci/config.yml b/.circleci/config.yml index 411ea2b..4b14e9d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -35,6 +35,19 @@ workflows: equal: - scheduled_pipeline - << pipeline.trigger_source >> + aspect-workflows-e2e-copy_action: + jobs: + - aw-e2e_copy_action_test: + context: [] + delivery_manifest: false + workspace: e2e/copy_action + when: + and: + - not: << pipeline.parameters.perform_delivery >> + - not: + equal: + - scheduled_pipeline + - << pipeline.trigger_source >> aspect-workflows-e2e-copy_to_directory: jobs: - aw-e2e_copy_to_directory_test: @@ -321,6 +334,105 @@ jobs: no_output_timeout: 10m when: always working_directory: /mnt/ephemeral/workdir + aw-e2e_copy_action_test: + environment: + ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml + ASPECT_WORKFLOWS_WORKSPACE: << parameters.workspace >> + XDG_CACHE_HOME: /mnt/ephemeral/caches + machine: true + parameters: + delivery_manifest: + default: true + type: boolean + workspace: + type: string + resource_class: aspect-build/bazel-lib-small + steps: + - run: + command: /etc/aspect/workflows/bin/configure_workflows_env + environment: + ASPECT_WORKFLOWS_CIRCLE_PIPELINE_NUMBER: << pipeline.number >> + ASPECT_WORKFLOWS_CIRCLE_PIPELINE_PROJECT_TYPE: << pipeline.project.type + >> + ASPECT_WORKFLOWS_CIRCLE_WORKFLOW_BASE_NAME: aspect-workflows + ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml + XDG_CACHE_HOME: /mnt/ephemeral/caches + name: Configure Workflows + - checkout + - run: + command: rm -rf /workflows/artifacts /workflows/testlogs + environment: + ASPECT_WORKFLOWS_CIRCLE_PIPELINE_NUMBER: << pipeline.number >> + ASPECT_WORKFLOWS_CIRCLE_PIPELINE_PROJECT_TYPE: << pipeline.project.type + >> + ASPECT_WORKFLOWS_CIRCLE_WORKFLOW_BASE_NAME: aspect-workflows + ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml + XDG_CACHE_HOME: /mnt/ephemeral/caches + name: Prepare archive directories + - run: + command: /etc/aspect/workflows/bin/agent_health_check + environment: + ASPECT_WORKFLOWS_CIRCLE_PIPELINE_NUMBER: << pipeline.number >> + ASPECT_WORKFLOWS_CIRCLE_PIPELINE_PROJECT_TYPE: << pipeline.project.type + >> + ASPECT_WORKFLOWS_CIRCLE_WORKFLOW_BASE_NAME: aspect-workflows + ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml + XDG_CACHE_HOME: /mnt/ephemeral/caches + name: Agent health checks + no_output_timeout: 180m + - run: + command: rosetta run test --workspace << parameters.workspace >> + environment: + ASPECT_WORKFLOWS_CIRCLE_PIPELINE_NUMBER: << pipeline.number >> + ASPECT_WORKFLOWS_CIRCLE_PIPELINE_PROJECT_TYPE: << pipeline.project.type + >> + ASPECT_WORKFLOWS_CIRCLE_WORKFLOW_BASE_NAME: aspect-workflows + ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml + XDG_CACHE_HOME: /mnt/ephemeral/caches + name: Test + no_output_timeout: 180m + - store_test_results: + path: /workflows/testlogs + - when: + condition: + and: + - <> + - or: + - matches: + pattern: ^main$ + value: << pipeline.git.branch >> + steps: + - run: + command: rosetta run delivery_manifest --workspace << parameters.workspace + >> --data TARGETS_SOURCE=test + environment: + ASPECT_WORKFLOWS_CIRCLE_PIPELINE_NUMBER: << pipeline.number >> + ASPECT_WORKFLOWS_CIRCLE_PIPELINE_PROJECT_TYPE: << pipeline.project.type + >> + ASPECT_WORKFLOWS_CIRCLE_WORKFLOW_BASE_NAME: aspect-workflows + ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml + XDG_CACHE_HOME: /mnt/ephemeral/caches + name: Delivery Manifest + no_output_timeout: 180m + - store_artifacts: + path: /workflows/testlogs + - store_artifacts: + path: /workflows/artifacts + - store_artifacts: + path: vmstat.out + - run: + command: rosetta run finalization + environment: + ASPECT_WORKFLOWS_CIRCLE_PIPELINE_NUMBER: << pipeline.number >> + ASPECT_WORKFLOWS_CIRCLE_PIPELINE_PROJECT_TYPE: << pipeline.project.type + >> + ASPECT_WORKFLOWS_CIRCLE_WORKFLOW_BASE_NAME: aspect-workflows + ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml + XDG_CACHE_HOME: /mnt/ephemeral/caches + name: Finalization + no_output_timeout: 10m + when: always + working_directory: /mnt/ephemeral/workdir aw-e2e_copy_to_directory_test: environment: ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml @@ -1041,6 +1153,17 @@ jobs: XDG_CACHE_HOME: /mnt/ephemeral/caches name: Agent health checks no_output_timeout: 180m + - run: + command: rosetta run warming --workspace e2e/smoke + environment: + ASPECT_WORKFLOWS_CIRCLE_PIPELINE_NUMBER: << pipeline.number >> + ASPECT_WORKFLOWS_CIRCLE_PIPELINE_PROJECT_TYPE: << pipeline.project.type + >> + ASPECT_WORKFLOWS_CIRCLE_WORKFLOW_BASE_NAME: aspect-workflows + ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml + XDG_CACHE_HOME: /mnt/ephemeral/caches + name: Create warming archive for e2e/smoke + no_output_timeout: 180m - run: command: rosetta run warming --workspace e2e/external_copy_to_directory environment: @@ -1052,17 +1175,6 @@ jobs: XDG_CACHE_HOME: /mnt/ephemeral/caches name: Create warming archive for e2e/external_copy_to_directory no_output_timeout: 180m - - run: - command: rosetta run warming --workspace e2e/copy_to_directory - environment: - ASPECT_WORKFLOWS_CIRCLE_PIPELINE_NUMBER: << pipeline.number >> - ASPECT_WORKFLOWS_CIRCLE_PIPELINE_PROJECT_TYPE: << pipeline.project.type - >> - ASPECT_WORKFLOWS_CIRCLE_WORKFLOW_BASE_NAME: aspect-workflows - ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml - XDG_CACHE_HOME: /mnt/ephemeral/caches - name: Create warming archive for e2e/copy_to_directory - no_output_timeout: 180m - run: command: rosetta run warming --workspace e2e/coreutils environment: @@ -1075,7 +1187,7 @@ jobs: name: Create warming archive for e2e/coreutils no_output_timeout: 180m - run: - command: rosetta run warming --workspace e2e/smoke + command: rosetta run warming --workspace e2e/copy_to_directory environment: ASPECT_WORKFLOWS_CIRCLE_PIPELINE_NUMBER: << pipeline.number >> ASPECT_WORKFLOWS_CIRCLE_PIPELINE_PROJECT_TYPE: << pipeline.project.type @@ -1083,7 +1195,18 @@ jobs: ASPECT_WORKFLOWS_CIRCLE_WORKFLOW_BASE_NAME: aspect-workflows ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml XDG_CACHE_HOME: /mnt/ephemeral/caches - name: Create warming archive for e2e/smoke + name: Create warming archive for e2e/copy_to_directory + no_output_timeout: 180m + - run: + command: rosetta run warming --workspace e2e/copy_action + environment: + ASPECT_WORKFLOWS_CIRCLE_PIPELINE_NUMBER: << pipeline.number >> + ASPECT_WORKFLOWS_CIRCLE_PIPELINE_PROJECT_TYPE: << pipeline.project.type + >> + ASPECT_WORKFLOWS_CIRCLE_WORKFLOW_BASE_NAME: aspect-workflows + ASPECT_WORKFLOWS_CONFIG: .aspect/workflows/config.yaml + XDG_CACHE_HOME: /mnt/ephemeral/caches + name: Create warming archive for e2e/copy_action no_output_timeout: 180m - run: command: rosetta run warming --workspace . diff --git a/.github/workflows/ci.bazelrc b/.github/workflows/ci.bazelrc index 22c878a..d7622d3 100644 --- a/.github/workflows/ci.bazelrc +++ b/.github/workflows/ci.bazelrc @@ -1,21 +1,20 @@ -# Bazel options included on CI using the --bazelrc Bazel flag +# Directories caches by GitHub actions +common:local --disk_cache=~/.cache/bazel-disk-cache +common --repository_cache=~/.cache/bazel-repository-cache -# CI specific caching options -build --repository_cache=~/.cache/bazel-repo -test --test_env=XDG_CACHE_HOME +# Debug where options came from +common --announce_rc -# When no remote cache, use a local one -build:local --disk_cache=~/.cache/bazel +# Allows tests to run bazelisk-in-bazel, since this is the cache folder used +common --test_env=XDG_CACHE_HOME # Remote build execution build:rbe --extra_execution_platforms=@aspect_bazel_lib//platforms:x86_64_linux_remote +build:rbe --genrule_strategy=remote build:rbe --host_platform=@aspect_bazel_lib//platforms:x86_64_linux_remote build:rbe --jobs=32 # BuildBuddy remote exec build:rbe --bes_results_url=https://app.buildbuddy.io/invocation/ build:rbe --bes_backend=grpcs://remote.buildbuddy.io -build:rbe --remote_timeout=3600 build:rbe --remote_executor=grpcs://remote.buildbuddy.io - -test --test_output=errors diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 733d31b..37d5b8d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,78 +18,66 @@ concurrency: cancel-in-progress: ${{ github.ref_name != 'main' }} jobs: - # matrix-prep-* steps dynamically generate a bit of JSON depending on whether our action has - # access to repository secrets. When running on a pull_request from a fork, the author is - # untrusted so the secret will be absent. Insanely complex for how simple this requirement is... - # inspired from - # https://stackoverflow.com/questions/65384420/how-to-make-a-github-action-matrix-element-conditional - - matrix-prep-config: - # Prepares the 'config' axis of the test matrix - runs-on: ubuntu-latest - env: - BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }} - steps: - - id: local - run: echo "config=local" >> $GITHUB_OUTPUT - - id: rbe - run: echo "config=rbe" >> $GITHUB_OUTPUT - # Don't run RBE if there is no API key which is the case on forks - if: ${{ env.BUILDBUDDY_API_KEY != '' }} - outputs: - # Will look like '["local", "rbe"]' - configs: ${{ toJSON(steps.*.outputs.config) }} - - matrix-prep-bazelversion: - # Prepares the 'bazelversion' axis of the test matrix + # Prepares dynamic test matrix values + matrix-prep: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - id: bazel_7 - run: echo "bazelversion=$(head -n 1 .bazelversion)" >> $GITHUB_OUTPUT - - id: bazel_6 - run: echo "bazelversion=6.5.0" >> $GITHUB_OUTPUT - outputs: - # Will look like '["", ...]' - bazelversions: ${{ toJSON(steps.*.outputs.bazelversion) }} - - matrix-prep-os: - # Prepares the 'os' axis of the test matrix - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - id: linux - run: echo "os=ubuntu-latest" >> $GITHUB_OUTPUT - - id: macos - run: echo "os=macos-latest" >> $GITHUB_OUTPUT - # Only run on main branch (or PR branches that contain 'macos') to minimize macOS minutes (billed at 10X) + - id: bazel-version + name: Prepare 'bazel-version' matrix axis + run: | + v=$(head -n 1 .bazelversion) + m=${v::1} + a=( + "major:$m, version:\"$v\"" + "major:6, version:\"6.5.0\"" + ) + printf -v j '{%s},' "${a[@]}" + echo "res=[${j%,}]" | tee -a $GITHUB_OUTPUT + - id: config + name: Prepare 'config' matrix axis + # Don't run RBE if there is no API key which is the case on forks. + run: | + a=( local ) + if [[ "${{ github.ref_name }}" == "main" ]] || [[ "${{ github.head_ref }}" == *"rbe"* ]]; then + if [[ "${{ env.BUILDBUDDY_API_KEY }}" ]]; then + a+=( rbe ) + fi + fi + printf -v j '"%s",' "${a[@]}" + echo "res=[${j%,}]" | tee -a $GITHUB_OUTPUT + env: + BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }} + - id: os + name: Prepare 'os' matrix axis + # Only run MacOS and Windows on main branch (not PRs) to minimize minutes (billed at 10X and 2X respectively) # https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#included-storage-and-minutes - if: ${{ github.ref == 'refs/heads/main' || contains(github.head_ref, 'macos') }} - - id: windows - run: echo "os=windows-latest" >> $GITHUB_OUTPUT - # Only run on main branch (or PR branches that contain 'windows') to minimize Windows minutes (billed at 2X) - # https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#included-storage-and-minutes - if: ${{ github.ref == 'refs/heads/main' || contains(github.head_ref, 'windows') }} + run: | + a=( ubuntu ) + if [[ "${{ github.ref_name }}" == "main" ]] || [[ "${{ github.head_ref }}" == *"macos"* ]]; then + a+=( macos ) + fi + if [[ "${{ github.ref_name }}" == "main" ]] || [[ "${{ github.head_ref }}" == *"windows"* ]]; then + a+=( windows ) + fi + printf -v j '"%s",' "${a[@]}" + echo "res=[${j%,}]" | tee -a $GITHUB_OUTPUT outputs: - # Will look like ["ubuntu-latest", "macos-latest", "windows-latest"] - os: ${{ toJSON(steps.*.outputs.os) }} + bazel-version: ${{ steps.bazel-version.outputs.res }} + config: ${{ steps.config.outputs.res }} + os: ${{ steps.os.outputs.res }} test: - # The type of runner that the job will run on - runs-on: ${{ matrix.os }} - + runs-on: ${{ matrix.os }}-latest needs: - - matrix-prep-config - - matrix-prep-bazelversion - - matrix-prep-os - + - matrix-prep strategy: fail-fast: false matrix: - config: ${{ fromJSON(needs.matrix-prep-config.outputs.configs) }} - bazelversion: ${{ fromJSON(needs.matrix-prep-bazelversion.outputs.bazelversions) }} - os: ${{ fromJSON(needs.matrix-prep-os.outputs.os) }} + bazel-version: ${{ fromJSON(needs.matrix-prep.outputs.bazel-version) }} bzlmod: [1, 0] + os: ${{ fromJSON(needs.matrix-prep.outputs.os) }} + config: ${{ fromJSON(needs.matrix-prep.outputs.config) }} folder: - "." - "e2e/copy_action" @@ -99,23 +87,33 @@ jobs: - "e2e/smoke" - "e2e/write_source_files" exclude: - # Don't test MacOS with RBE to minimize MacOS minutes (billed at 10X) - - config: rbe - os: macos-latest - # Don't test MacOS with Bazel 6 to minimize MacOS minutes (billed at 10X) - - bazelversion: 6.5.0 - os: macos-latest - # Don't test Windows with RBE to minimize Windows minutes (billed at 2X) - - config: rbe - os: windows-latest - # Don't test Windows with Bazel 6 to minimize Windows minutes (billed at 2X) - - bazelversion: 6.5.0 - os: windows-latest + # Don't test MacOS and Windows against secondary bazel version to minimize minutes (billed at 10X and 2X respectively) + # https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#included-storage-and-minutes + - os: macos + bazel-version: + major: 6 + - os: windows + bazel-version: + major: 6 + # Don't run RBE tests with Bazel 6 to reduce the size of the test matrix + - bazel-version: + major: 6 + config: rbe + # Don't run bzlmod tests with Bazel 6 to reduce the size of the test matrix + - bazel-version: + major: 6 + bzlmod: 1 + # Don't test RBE with on MacOS (not configured) + - os: macos + config: rbe + # Don't test RBE with on Windows (not configured) + - os: windows + config: rbe # TODO: green up root Workspace on MacOS & Windows - folder: . - os: macos-latest + os: macos - folder: . - os: windows-latest + os: windows steps: - uses: actions/checkout@v4 @@ -124,10 +122,11 @@ jobs: uses: actions/cache@v4 with: path: | - ~/.cache/bazel - ~/.cache/bazel-repo - key: bazel-cache-${{ matrix.os }}-${{ matrix.bazelversion }}-${{ matrix.folder }}-${{ matrix.bzlmodEnabled }}-${{ matrix.config }}-${{ hashFiles('.bazelrc', '.bazelversion', '.bazeliskrc', '**/BUILD', '**/BUILD.bazel', '**/*.bzl', 'WORKSPACE', 'WORKSPACE.bazel', 'WORKSPACE.bzlmod', 'MODULE.bazel', 'MODULE.bazel.lock') }} - restore-keys: bazel-cache-${{ matrix.os }}-${{ matrix.bazelversion }}-${{ matrix.folder }}-${{ matrix.bzlmodEnabled }}-${{ matrix.config }}- + ~/.cache/bazel-disk-cache + ~/.cache/bazel-repository-cache + ~/.cache/xdg-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 }} @@ -136,7 +135,7 @@ jobs: # Overwrite the .bazelversion instead of using USE_BAZEL_VERSION so that Bazelisk # still bootstraps Aspect CLI from configuration in .bazeliskrc. Aspect CLI will # then use .bazelversion to determine which Bazel version to use. - echo "${{ matrix.bazelversion }}" > .bazelversion + echo "${{ matrix.bazel-version.version }}" > .bazelversion # Delete all the version specific bazelrc files that are used for local development # since the version we're testing against is dynamic. These are just symlinks and the # root .bazelrc brings these in with try-imports. In this CI workflows, we explicitly @@ -155,7 +154,7 @@ jobs: # TODO: remove this block once we have Aspect CLI Windows releases - name: Don't use Aspect CLI on Windows - if: matrix.os == 'windows-latest' + if: matrix.os == 'windows' working-directory: ${{ matrix.folder }} shell: bash run: rm -f .bazeliskrc @@ -164,26 +163,25 @@ jobs: working-directory: ${{ matrix.folder }} shell: bash run: | - BAZEL_VERSION=${{ matrix.bazelversion }} bazel \ - --bazelrc=${GITHUB_WORKSPACE//\\/\/}/.aspect/bazelrc/bazel${BAZEL_VERSION::1}.bazelrc \ + --bazelrc=${GITHUB_WORKSPACE//\\/\/}/.aspect/bazelrc/bazel${{ matrix.bazel-version.major }}.bazelrc \ --bazelrc=${GITHUB_WORKSPACE//\\/\/}/.aspect/bazelrc/ci.bazelrc \ --bazelrc=${GITHUB_WORKSPACE//\\/\/}/.github/workflows/ci.bazelrc \ test \ --config=${{ matrix.config }} \ - --test_tag_filters=-skip-on-bazel${BAZEL_VERSION::1} \ - --build_tag_filters=-skip-on-bazel${BAZEL_VERSION::1} \ + --test_tag_filters=-skip-on-bazel${{ matrix.bazel-version.major }} \ + --build_tag_filters=-skip-on-bazel${{ matrix.bazel-version.major }} \ --enable_bzlmod=${{ matrix.bzlmod }} \ //... env: XDG_CACHE_HOME: ~/.cache/xdg-cache # bazelisk will download bazel to here - - name: integration tests + - 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-latest' && matrix.bazelversion != '6.5.0' + 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.bzlmod == '1' && matrix.os == 'ubuntu-latest' + - 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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8deb8d9..afbea14 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: path: | ~/.cache/bazel ~/.cache/bazel-repo - key: bazel-cache-release-${{ hashFiles('.bazelrc', '.bazelversion', '.bazeliskrc', '**/BUILD', '**/BUILD.bazel', '**/*.bzl', 'WORKSPACE', 'WORKSPACE.bazel', 'WORKSPACE.bzlmod', 'MODULE.bazel', 'MODULE.bazel.lock') }} + key: bazel-cache-release-${{ hashFiles('.bazelrc', '.bazelversion', '.bazeliskrc', '**/BUILD', '**/BUILD.bazel', '**/*.bzl', 'WORKSPACE', 'WORKSPACE.bazel', 'WORKSPACE.bzlmod', 'MODULE.bazel') }} restore-keys: bazel-cache-release- - name: bazel test //... (release) env: diff --git a/.gitignore b/.gitignore index 3c894b7..dc82b29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,18 @@ bazel-* -**/.terraform/* +.bazelrc.user + test-out/ + +.idea/ +.ijwb/ +.vscode .DS_Store -# Don't commit lockfile for now as it is unstable. Do allow for it to be -# created, however, since it gives a performance boost for local development. -# https://github.com/bazelbuild/bazel/issues/19026 -# https://github.com/bazelbuild/bazel/issues/19621 -# https://github.com/bazelbuild/bazel/issues/19971 -# https://github.com/bazelbuild/bazel/issues/20272 -# https://github.com/bazelbuild/bazel/issues/20369 +# Bazel's MODULE lockfile isn't ready to check in yet as of Bazel 7.1. +# Do allow for it to be created, however, since it gives a performance boost for local development. +# [Store resolved repository attributes in the Bzlmod lockfile](https://github.com/bazelbuild/bazel/issues/19026) +# [MODULE.bazel.lock file contains user specific paths](https://github.com/bazelbuild/bazel/issues/19621) +# [Consider skipping bazel_tools@_ from lockfile](https://github.com/bazelbuild/bazel/issues/19971) +# [MODULE.bazel.lock file "reads through" already-locked package manager](https://github.com/bazelbuild/bazel/issues/20272) +# [moduleFileHash in MODULE.bazel.lock causes frequent Git merge conflicts](https://github.com/bazelbuild/bazel/issues/20369) MODULE.bazel.lock diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6ddd66c..d210d6e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: buildifier-lint # Enforce that commit messages allow for later changelog generation - repo: https://github.com/commitizen-tools/commitizen - rev: v3.13.0 + rev: v3.24.0 hooks: # Requires that commitizen is already installed - id: commitizen diff --git a/WORKSPACE b/WORKSPACE index 7a51d40..9ae3a8d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -75,13 +75,10 @@ buildifier_prebuilt_register_toolchains() load( "@aspect_rules_lint//format:repositories.bzl", "fetch_shfmt", - "fetch_terraform", ) fetch_shfmt() -fetch_terraform() - load("//.aspect/workflows:deps.bzl", "fetch_workflows_deps") fetch_workflows_deps() diff --git a/e2e/copy_action/.bazelrc b/e2e/copy_action/.bazelrc index e69de29..e1b3ea1 100644 --- a/e2e/copy_action/.bazelrc +++ b/e2e/copy_action/.bazelrc @@ -0,0 +1,15 @@ +# Import Aspect bazelrc presets +try-import %workspace%/../../.aspect/bazelrc/local/bazel7.bazelrc +import %workspace%/../../.aspect/bazelrc/convenience.bazelrc +import %workspace%/../../.aspect/bazelrc/correctness.bazelrc +import %workspace%/../../.aspect/bazelrc/debug.bazelrc +import %workspace%/../../.aspect/bazelrc/javascript.bazelrc +import %workspace%/../../.aspect/bazelrc/performance.bazelrc + +### YOUR PROJECT SPECIFIC OPTIONS GO HERE ### + +# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`. +# This file should appear in `.gitignore` so that settings are not shared with team members. This +# should be last statement in this config so the user configuration is able to overwrite flags from +# this file. See https://bazel.build/configure/best-practices#bazelrc-file. +try-import %workspace%/../../.aspect/bazelrc/user.bazelrc diff --git a/e2e/copy_action/MODULE.bazel b/e2e/copy_action/MODULE.bazel index 9c1659a..4588746 100644 --- a/e2e/copy_action/MODULE.bazel +++ b/e2e/copy_action/MODULE.bazel @@ -1,11 +1,7 @@ -module( - version = "0.0.0", - compatibility_level = 1, -) - -bazel_dep(name = "bazel_skylib", version = "1.5.0") -bazel_dep(name = "aspect_bazel_lib", version = "0.0.0") +bazel_dep(name = "aspect_bazel_lib", version = "0.0.0", dev_dependency = True) local_path_override( module_name = "aspect_bazel_lib", path = "../..", ) + +bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True) diff --git a/e2e/copy_to_directory/.bazelrc b/e2e/copy_to_directory/.bazelrc index e69de29..e1b3ea1 100644 --- a/e2e/copy_to_directory/.bazelrc +++ b/e2e/copy_to_directory/.bazelrc @@ -0,0 +1,15 @@ +# Import Aspect bazelrc presets +try-import %workspace%/../../.aspect/bazelrc/local/bazel7.bazelrc +import %workspace%/../../.aspect/bazelrc/convenience.bazelrc +import %workspace%/../../.aspect/bazelrc/correctness.bazelrc +import %workspace%/../../.aspect/bazelrc/debug.bazelrc +import %workspace%/../../.aspect/bazelrc/javascript.bazelrc +import %workspace%/../../.aspect/bazelrc/performance.bazelrc + +### YOUR PROJECT SPECIFIC OPTIONS GO HERE ### + +# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`. +# This file should appear in `.gitignore` so that settings are not shared with team members. This +# should be last statement in this config so the user configuration is able to overwrite flags from +# this file. See https://bazel.build/configure/best-practices#bazelrc-file. +try-import %workspace%/../../.aspect/bazelrc/user.bazelrc diff --git a/e2e/copy_to_directory/MODULE.bazel b/e2e/copy_to_directory/MODULE.bazel index eaed508..4588746 100644 --- a/e2e/copy_to_directory/MODULE.bazel +++ b/e2e/copy_to_directory/MODULE.bazel @@ -1,12 +1,7 @@ -module( - name = "copy_to_directory", - version = "0.0.0", - compatibility_level = 1, -) - -bazel_dep(name = "bazel_skylib", version = "1.5.0") -bazel_dep(name = "aspect_bazel_lib", version = "0.0.0") +bazel_dep(name = "aspect_bazel_lib", version = "0.0.0", dev_dependency = True) local_path_override( module_name = "aspect_bazel_lib", path = "../..", ) + +bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True) diff --git a/e2e/coreutils/.bazelrc b/e2e/coreutils/.bazelrc index e69de29..e1b3ea1 100644 --- a/e2e/coreutils/.bazelrc +++ b/e2e/coreutils/.bazelrc @@ -0,0 +1,15 @@ +# Import Aspect bazelrc presets +try-import %workspace%/../../.aspect/bazelrc/local/bazel7.bazelrc +import %workspace%/../../.aspect/bazelrc/convenience.bazelrc +import %workspace%/../../.aspect/bazelrc/correctness.bazelrc +import %workspace%/../../.aspect/bazelrc/debug.bazelrc +import %workspace%/../../.aspect/bazelrc/javascript.bazelrc +import %workspace%/../../.aspect/bazelrc/performance.bazelrc + +### YOUR PROJECT SPECIFIC OPTIONS GO HERE ### + +# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`. +# This file should appear in `.gitignore` so that settings are not shared with team members. This +# should be last statement in this config so the user configuration is able to overwrite flags from +# this file. See https://bazel.build/configure/best-practices#bazelrc-file. +try-import %workspace%/../../.aspect/bazelrc/user.bazelrc diff --git a/e2e/coreutils/MODULE.bazel b/e2e/coreutils/MODULE.bazel index abba355..3f2c110 100644 --- a/e2e/coreutils/MODULE.bazel +++ b/e2e/coreutils/MODULE.bazel @@ -1,14 +1,8 @@ -module( - name = "coreutils", - version = "0.0.0", - compatibility_level = 1, -) - -bazel_dep(name = "aspect_bazel_lib", version = "0.0.0") +bazel_dep(name = "aspect_bazel_lib", version = "0.0.0", dev_dependency = True) local_path_override( module_name = "aspect_bazel_lib", path = "../..", ) -bazel_lib_toolchains = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "toolchains") +bazel_lib_toolchains = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "toolchains", dev_dependency = True) use_repo(bazel_lib_toolchains, "coreutils_toolchains") diff --git a/e2e/external_copy_to_directory/.bazelrc b/e2e/external_copy_to_directory/.bazelrc index e69de29..e1b3ea1 100644 --- a/e2e/external_copy_to_directory/.bazelrc +++ b/e2e/external_copy_to_directory/.bazelrc @@ -0,0 +1,15 @@ +# Import Aspect bazelrc presets +try-import %workspace%/../../.aspect/bazelrc/local/bazel7.bazelrc +import %workspace%/../../.aspect/bazelrc/convenience.bazelrc +import %workspace%/../../.aspect/bazelrc/correctness.bazelrc +import %workspace%/../../.aspect/bazelrc/debug.bazelrc +import %workspace%/../../.aspect/bazelrc/javascript.bazelrc +import %workspace%/../../.aspect/bazelrc/performance.bazelrc + +### YOUR PROJECT SPECIFIC OPTIONS GO HERE ### + +# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`. +# This file should appear in `.gitignore` so that settings are not shared with team members. This +# should be last statement in this config so the user configuration is able to overwrite flags from +# this file. See https://bazel.build/configure/best-practices#bazelrc-file. +try-import %workspace%/../../.aspect/bazelrc/user.bazelrc diff --git a/e2e/external_copy_to_directory/MODULE.bazel b/e2e/external_copy_to_directory/MODULE.bazel index 1231b00..4588746 100644 --- a/e2e/external_copy_to_directory/MODULE.bazel +++ b/e2e/external_copy_to_directory/MODULE.bazel @@ -1,12 +1,7 @@ -module( - name = "external_copy_to_directory", - version = "0.0.0", - compatibility_level = 1, -) - -bazel_dep(name = "bazel_skylib", version = "1.5.0") -bazel_dep(name = "aspect_bazel_lib", version = "0.0.0") +bazel_dep(name = "aspect_bazel_lib", version = "0.0.0", dev_dependency = True) local_path_override( module_name = "aspect_bazel_lib", path = "../..", ) + +bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True) diff --git a/e2e/smoke/.bazelrc b/e2e/smoke/.bazelrc index b48a27a..3cc9865 100644 --- a/e2e/smoke/.bazelrc +++ b/e2e/smoke/.bazelrc @@ -1,2 +1,18 @@ -# for testing expand_template -build --workspace_status_command="echo BUILD_SCM_VERSION 1.2.3" +# Import Aspect bazelrc presets +try-import %workspace%/../../.aspect/bazelrc/local/bazel7.bazelrc +import %workspace%/../../.aspect/bazelrc/convenience.bazelrc +import %workspace%/../../.aspect/bazelrc/correctness.bazelrc +import %workspace%/../../.aspect/bazelrc/debug.bazelrc +import %workspace%/../../.aspect/bazelrc/javascript.bazelrc +import %workspace%/../../.aspect/bazelrc/performance.bazelrc + +### YOUR PROJECT SPECIFIC OPTIONS GO HERE ### + +# For testing expand_template +common --workspace_status_command="echo BUILD_SCM_VERSION 1.2.3" + +# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`. +# This file should appear in `.gitignore` so that settings are not shared with team members. This +# should be last statement in this config so the user configuration is able to overwrite flags from +# this file. See https://bazel.build/configure/best-practices#bazelrc-file. +try-import %workspace%/../../.aspect/bazelrc/user.bazelrc diff --git a/e2e/smoke/MODULE.bazel b/e2e/smoke/MODULE.bazel index fc14b1f..4588746 100644 --- a/e2e/smoke/MODULE.bazel +++ b/e2e/smoke/MODULE.bazel @@ -1,12 +1,7 @@ -module( - name = "smoke", - version = "0.0.0", - compatibility_level = 1, -) - -bazel_dep(name = "bazel_skylib", version = "1.5.0") -bazel_dep(name = "aspect_bazel_lib", version = "0.0.0") +bazel_dep(name = "aspect_bazel_lib", version = "0.0.0", dev_dependency = True) local_path_override( module_name = "aspect_bazel_lib", path = "../..", ) + +bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True) diff --git a/e2e/write_source_files/.bazelrc b/e2e/write_source_files/.bazelrc index e69de29..e1b3ea1 100644 --- a/e2e/write_source_files/.bazelrc +++ b/e2e/write_source_files/.bazelrc @@ -0,0 +1,15 @@ +# Import Aspect bazelrc presets +try-import %workspace%/../../.aspect/bazelrc/local/bazel7.bazelrc +import %workspace%/../../.aspect/bazelrc/convenience.bazelrc +import %workspace%/../../.aspect/bazelrc/correctness.bazelrc +import %workspace%/../../.aspect/bazelrc/debug.bazelrc +import %workspace%/../../.aspect/bazelrc/javascript.bazelrc +import %workspace%/../../.aspect/bazelrc/performance.bazelrc + +### YOUR PROJECT SPECIFIC OPTIONS GO HERE ### + +# Load any settings & overrides specific to the current user from `.aspect/bazelrc/user.bazelrc`. +# This file should appear in `.gitignore` so that settings are not shared with team members. This +# should be last statement in this config so the user configuration is able to overwrite flags from +# this file. See https://bazel.build/configure/best-practices#bazelrc-file. +try-import %workspace%/../../.aspect/bazelrc/user.bazelrc diff --git a/e2e/write_source_files/MODULE.bazel b/e2e/write_source_files/MODULE.bazel index ce99d68..1156adb 100644 --- a/e2e/write_source_files/MODULE.bazel +++ b/e2e/write_source_files/MODULE.bazel @@ -1,14 +1,8 @@ -module( - name = "write_source_files", - version = "0.0.0", - compatibility_level = 1, -) - -bazel_dep(name = "aspect_bazel_lib", version = "0.0.0") +bazel_dep(name = "aspect_bazel_lib", version = "0.0.0", dev_dependency = True) local_path_override( module_name = "aspect_bazel_lib", path = "../..", ) -test_ext = use_extension("//:test_extension.bzl", "test_ext") +test_ext = use_extension("//:test_extension.bzl", "test_ext", dev_dependency = True) use_repo(test_ext, "test") diff --git a/tools/format/BUILD.bazel b/tools/format/BUILD.bazel index f05468b..e66fce3 100644 --- a/tools/format/BUILD.bazel +++ b/tools/format/BUILD.bazel @@ -17,23 +17,11 @@ alias( visibility = ["//:__subpackages__"], ) -alias( - name = "terraform", - actual = select({ - "@bazel_tools//src/conditions:darwin_arm64": "@terraform_macos_aarch64//:terraform", - "@bazel_tools//src/conditions:darwin_x86_64": "@terraform_macos_x86_64//:terraform", - "@bazel_tools//src/conditions:linux": "@terraform_linux_x86_64//:terraform", - "//conditions:default": ":noop", - }), - visibility = ["//:__subpackages__"], -) - multi_formatter_binary( name = "format", go = "@go_sdk//:bin/gofmt", sh = ":shfmt", starlark = "@buildifier_prebuilt//:buildifier", tags = ["manual"], - terraform = ":terraform", visibility = ["//:__subpackages__"], )