From efc1e36f99664705d0a91eb5e9851a5f31c6e874 Mon Sep 17 00:00:00 2001 From: Adam Singer Date: Thu, 25 Jul 2024 08:03:34 +0000 Subject: [PATCH] Updating examples to use nativelink --- .../actions/build_buck2_nativelink/action.yml | 53 ++++ .../build_example_nativelink/action.yml | 39 +++ .../build_example_no_prelude/action.yml | 32 ++- .github/workflows/build-and-test.yml | 130 ++++------ .github/workflows/rebase-upstream-cron.yml | 24 ++ .github/workflows/rebase-upstream-manual.yml | 22 ++ .github/workflows/upload_buck2.yml | 240 ------------------ examples/no_prelude/go/rules.bzl | 2 +- examples/no_prelude/platforms/BUCK | 3 + examples/no_prelude/platforms/defs.bzl | 33 +++ .../no_prelude/toolchains/go_toolchain.bzl | 17 +- .../nativelink/platforms/defs.bzl | 2 +- prelude/platforms/defs.bzl | 14 +- 13 files changed, 269 insertions(+), 342 deletions(-) create mode 100644 .github/actions/build_buck2_nativelink/action.yml create mode 100644 .github/actions/build_example_nativelink/action.yml create mode 100644 .github/workflows/rebase-upstream-cron.yml create mode 100644 .github/workflows/rebase-upstream-manual.yml delete mode 100644 .github/workflows/upload_buck2.yml create mode 100644 examples/no_prelude/platforms/BUCK create mode 100644 examples/no_prelude/platforms/defs.bzl diff --git a/.github/actions/build_buck2_nativelink/action.yml b/.github/actions/build_buck2_nativelink/action.yml new file mode 100644 index 0000000000000..ce6661f31d690 --- /dev/null +++ b/.github/actions/build_buck2_nativelink/action.yml @@ -0,0 +1,53 @@ +name: build_buck2_nativelink +inputs: + NATIVELINK_ENGINE_ADDRESS_SECRET: + description: '' + required: true + NATIVELINK_AC_ADDRESS_SECRET: + description: '' + required: true + NATIVELINK_CAS_ADDRESS_SECRET: + description: '' + required: true + NATIVELINK_HEADER_RW_KEY_SECRET: + description: '' + required: true +runs: + using: composite + steps: + - name: + run: |- + DEBIAN_FRONTEND=noninteractive sudo apt-get install -y clang-format clang-tidy clang-tools clang clangd libc++-dev libc++1 libc++abi-dev libc++abi1 libclang-dev libclang1 liblldb-dev libllvm-ocaml-dev libomp-dev libomp5 lld lldb llvm-dev llvm-runtime llvm python3-clang protobuf-compiler libprotobuf-dev + shell: bash + - name: Build `buck2` with `buck2` using remote execution + run: |- + echo "[buck2_re_client] + engine_address = $NATIVELINK_ENGINE_ADDRESS + action_cache_address = $NATIVELINK_AC_ADDRESS + cas_address = $NATIVELINK_CAS_ADDRESS + http_headers = x-nativelink-api-key:$NATIVELINK_HEADER_RW_KEY + tls = true + instance_name = main + enabled = true + capabilities = true + [build] + execution_platforms = prelude//platforms:default" > .buckconfig.local + cargo install --locked --git https://github.com/facebookincubator/reindeer reindeer + nix develop --impure --command $RUNNER_TEMP/artifacts/buck2 clean + nix develop --impure --command $RUNNER_TEMP/artifacts/buck2 killall + rm -f shim/third-party/rust/Cargo.lock shim/third-party/rust/BUCK + reindeer --third-party-dir shim/third-party/rust buckify + # nix develop --impure --command $RUNNER_TEMP/artifacts/buck2 debug paranoid enable + export BUCK2_RE_DOWNLOAD_CONCURRENCY=5 + nix develop --impure --command $RUNNER_TEMP/artifacts/buck2 build //:buck2 -v 1 --show-simple-output --ui re --ui io --ui dice --ui debugevents --num-threads 5 + env: + NATIVELINK_ENGINE_ADDRESS: ${{ inputs.NATIVELINK_ENGINE_ADDRESS_SECRET }} + NATIVELINK_AC_ADDRESS: ${{ inputs.NATIVELINK_AC_ADDRESS_SECRET }} + NATIVELINK_CAS_ADDRESS: ${{ inputs.NATIVELINK_CAS_ADDRESS_SECRET }} + NATIVELINK_HEADER_RW_KEY: ${{ inputs.NATIVELINK_HEADER_RW_KEY_SECRET }} + shell: bash + - name: Buck2 failure + if: failure() + run: |- + nix develop --impure --command $RUNNER_TEMP/artifacts/buck2 log what-failed -v 4 + shell: bash diff --git a/.github/actions/build_example_nativelink/action.yml b/.github/actions/build_example_nativelink/action.yml new file mode 100644 index 0000000000000..eeaad82a64efa --- /dev/null +++ b/.github/actions/build_example_nativelink/action.yml @@ -0,0 +1,39 @@ +name: build_example_nativelink +inputs: + NATIVELINK_ENGINE_ADDRESS_SECRET: + description: '' + required: true + NATIVELINK_AC_ADDRESS_SECRET: + description: '' + required: true + NATIVELINK_CAS_ADDRESS_SECRET: + description: '' + required: true + NATIVELINK_HEADER_RW_KEY_SECRET: + description: '' + required: true +runs: + using: composite + steps: + - name: Build examples/remote_execution/nativelink directory + run: |- + echo "[buck2_re_client] + engine_address = $NATIVELINK_ENGINE_ADDRESS + action_cache_address = $NATIVELINK_AC_ADDRESS + cas_address = $NATIVELINK_CAS_ADDRESS + http_headers = x-nativelink-api-key:$NATIVELINK_HEADER_RW_KEY + tls = true + instance_name = main + enabled = true + capabilities = true + [build] + execution_platforms = root//platforms:platforms" > examples/remote_execution/nativelink/.buckconfig.local + cd examples/remote_execution/nativelink + export BUCK2_RE_DOWNLOAD_CONCURRENCY=25 + $RUNNER_TEMP/artifacts/buck2 build //... -v 1 --show-simple-output --ui re --ui io --ui dice --ui debugevents --num-threads 10 + env: + NATIVELINK_ENGINE_ADDRESS: ${{ inputs.NATIVELINK_ENGINE_ADDRESS_SECRET }} + NATIVELINK_AC_ADDRESS: ${{ inputs.NATIVELINK_AC_ADDRESS_SECRET }} + NATIVELINK_CAS_ADDRESS: ${{ inputs.NATIVELINK_CAS_ADDRESS_SECRET }} + NATIVELINK_HEADER_RW_KEY: ${{ inputs.NATIVELINK_HEADER_RW_KEY_SECRET }} + shell: bash diff --git a/.github/actions/build_example_no_prelude/action.yml b/.github/actions/build_example_no_prelude/action.yml index 7f3e09a5effa8..8edd6bbaf72f6 100644 --- a/.github/actions/build_example_no_prelude/action.yml +++ b/.github/actions/build_example_no_prelude/action.yml @@ -1,9 +1,39 @@ name: build_example_no_prelude +inputs: + NATIVELINK_ENGINE_ADDRESS_SECRET: + description: '' + required: true + NATIVELINK_AC_ADDRESS_SECRET: + description: '' + required: true + NATIVELINK_CAS_ADDRESS_SECRET: + description: '' + required: true + NATIVELINK_HEADER_RW_KEY_SECRET: + description: '' + required: true runs: using: composite steps: - name: Build example/no_prelude directory run: |- + echo "[buck2_re_client] + engine_address = $NATIVELINK_ENGINE_ADDRESS + action_cache_address = $NATIVELINK_AC_ADDRESS + cas_address = $NATIVELINK_CAS_ADDRESS + http_headers = x-nativelink-api-key:$NATIVELINK_HEADER_RW_KEY + tls = true + instance_name = main + enabled = true + capabilities = true + [build] + execution_platforms = root//platforms:platforms" > examples/no_prelude/.buckconfig.local cd examples/no_prelude - $RUNNER_TEMP/artifacts/buck2 build //... -v 2 + export BUCK2_RE_DOWNLOAD_CONCURRENCY=25 + $RUNNER_TEMP/artifacts/buck2 build //... -v 1 --show-simple-output --ui re --ui io --ui dice --ui debugevents --num-threads 10 + env: + NATIVELINK_ENGINE_ADDRESS: ${{ inputs.NATIVELINK_ENGINE_ADDRESS_SECRET }} + NATIVELINK_AC_ADDRESS: ${{ inputs.NATIVELINK_AC_ADDRESS_SECRET }} + NATIVELINK_CAS_ADDRESS: ${{ inputs.NATIVELINK_CAS_ADDRESS_SECRET }} + NATIVELINK_HEADER_RW_KEY: ${{ inputs.NATIVELINK_HEADER_RW_KEY_SECRET }} shell: bash diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 568e8535542ae..611b281dbe772 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -1,93 +1,57 @@ -name: Build and test +name: Build and test nativelink on: push: - pull_request: + workflow_dispatch: + workflow_call: + workflow_run: + workflows: ["rebase upstream manual", "rebase upstream cron"] + types: + - completed jobs: - linux-build-and-test: - runs-on: 4-core-ubuntu - steps: - - uses: actions/checkout@v4.1.0 - - uses: ./.github/actions/setup_linux_env - - uses: ./.github/actions/build_debug - - uses: ./.github/actions/run_test_py - macos-build-and-test: - runs-on: macos-latest - steps: - - uses: maxim-lobanov/setup-xcode@v1.6.0 - with: - xcode-version: 15.3.0 - - uses: actions/checkout@v4.1.0 - - uses: ./.github/actions/setup_macos_env - - uses: ./.github/actions/build_debug - - uses: ./.github/actions/run_test_py - windows-build-and-test: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4.1.0 - - uses: ./.github/actions/setup_windows_env - - uses: ./.github/actions/build_debug - - uses: ./.github/actions/run_test_py - macos-build-examples: - runs-on: macos-latest - steps: - - uses: maxim-lobanov/setup-xcode@v1.6.0 - with: - xcode-version: 15.3.0 - - uses: actions/checkout@v4.1.0 - - uses: ./.github/actions/setup_macos_env - - uses: ./.github/actions/init_opam - - uses: ./.github/actions/build_release - - name: Setup the 'example/with_prelude' project - run: |- - cd examples/with_prelude - ./haskell-setup.sh - ./ocaml-setup.sh - - name: Build the 'example/with_prelude' project - run: |- - cd examples/with_prelude - $RUNNER_TEMP/artifacts/buck2 build //... -v 2 - $RUNNER_TEMP/artifacts/buck2 test //... -v 2 - - uses: ./.github/actions/build_example_no_prelude - - uses: ./.github/actions/setup_reindeer - - uses: ./.github/actions/build_bootstrap linux-build-examples: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4.1.0 - uses: ./.github/actions/setup_linux_env - uses: ./.github/actions/init_opam - - uses: ./.github/actions/build_release - - name: Setup the 'example/with_prelude' project - run: |- - cd examples/with_prelude - ./haskell-setup.sh - ./ocaml-setup.sh - - name: Build the 'example/with_prelude' project - run: |- - cd examples/with_prelude - $RUNNER_TEMP/artifacts/buck2 build //... -v 2 - $RUNNER_TEMP/artifacts/buck2 test //... -v 2 - - uses: ./.github/actions/build_example_conan + - uses: ./.github/actions/build_debug + - uses: ./.github/actions/build_example_nativelink + with: + NATIVELINK_ENGINE_ADDRESS_SECRET: ${{ secrets.NATIVELINK_ENGINE_ADDRESS_SECRET }} + NATIVELINK_AC_ADDRESS_SECRET: ${{ secrets.NATIVELINK_AC_ADDRESS_SECRET }} + NATIVELINK_CAS_ADDRESS_SECRET: ${{ secrets.NATIVELINK_CAS_ADDRESS_SECRET }} + NATIVELINK_HEADER_RW_KEY_SECRET: ${{ secrets.NATIVELINK_HEADER_RW_KEY_SECRET }} - uses: ./.github/actions/build_example_no_prelude + with: + NATIVELINK_ENGINE_ADDRESS_SECRET: ${{ secrets.NATIVELINK_ENGINE_ADDRESS_SECRET }} + NATIVELINK_AC_ADDRESS_SECRET: ${{ secrets.NATIVELINK_AC_ADDRESS_SECRET }} + NATIVELINK_CAS_ADDRESS_SECRET: ${{ secrets.NATIVELINK_CAS_ADDRESS_SECRET }} + NATIVELINK_HEADER_RW_KEY_SECRET: ${{ secrets.NATIVELINK_HEADER_RW_KEY_SECRET }} - uses: ./.github/actions/setup_reindeer - - uses: ./.github/actions/build_bootstrap - windows-build-examples: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4.1.0 - - uses: ./.github/actions/setup_windows_env - - uses: ./.github/actions/build_release - - name: Build example/prelude directory - run: |- - cd examples/with_prelude - & $Env:RUNNER_TEMP/artifacts/buck2 build //... -v 2 - & $Env:RUNNER_TEMP/artifacts/buck2 test //... -v 2 - - uses: ./.github/actions/build_example_no_prelude - - name: Configure CARGO_HOME - run: |- - echo CARGO_HOME=$GITHUB_WORKSPACE/.cargo >> $GITHUB_ENV - echo $GITHUB_WORKSPACE/.cargo/bin >> $GITHUB_PATH - shell: - bash - - uses: ./.github/actions/setup_reindeer - - uses: ./.github/actions/build_bootstrap + #- uses: ./.github/actions/build_bootstrap + - uses: DeterminateSystems/nix-installer-action@de22e16c4711fca50c816cc9081563429d1cf563 + name: Install Nix + - uses: endersonmenezes/free-disk-space@3f9ec39ebae520864ac93467ee395f5237585c21 + name: Free disk space + with: + remove_android: true + remove_dotnet: true + remove_haskell: true + remove_tool_cache: false + - uses: DeterminateSystems/magic-nix-cache-action@fc6aaceb40b9845a02b91e059ec147e78d1b4e41 + name: Cache Nix derivations + # Required due to the mismatch of protoc and nix prebuild bins + # - name: Install Protoc + # uses: arduino/setup-protoc@v3 + # with: + # version: "21.4" + - uses: ./.github/actions/build_buck2_nativelink + with: + NATIVELINK_ENGINE_ADDRESS_SECRET: ${{ secrets.NATIVELINK_ENGINE_ADDRESS_SECRET }} + NATIVELINK_AC_ADDRESS_SECRET: ${{ secrets.NATIVELINK_AC_ADDRESS_SECRET }} + NATIVELINK_CAS_ADDRESS_SECRET: ${{ secrets.NATIVELINK_CAS_ADDRESS_SECRET }} + NATIVELINK_HEADER_RW_KEY_SECRET: ${{ secrets.NATIVELINK_HEADER_RW_KEY_SECRET }} + # - name: what-ran + # run: |- + # $RUNNER_TEMP/artifacts/buck2 log what-ran --format json | jq . + # shell: bash \ No newline at end of file diff --git a/.github/workflows/rebase-upstream-cron.yml b/.github/workflows/rebase-upstream-cron.yml new file mode 100644 index 0000000000000..76bb7b5ba9b3a --- /dev/null +++ b/.github/workflows/rebase-upstream-cron.yml @@ -0,0 +1,24 @@ +name: rebase upstream cron +on: + schedule: + - cron: '0 15 * * *' +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Rebase + run: | + git config --local user.email "github-actions@users.noreply.github.com" + git config --local user.name "github-actions" + git remote add upstream http://github.com/facebook/buck2.git + git fetch upstream + git rebase upstream/main + - name: Push changes + uses: ad-m/github-push-action@master + with: + force_with_lease: true + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} diff --git a/.github/workflows/rebase-upstream-manual.yml b/.github/workflows/rebase-upstream-manual.yml new file mode 100644 index 0000000000000..d19aa738e1b69 --- /dev/null +++ b/.github/workflows/rebase-upstream-manual.yml @@ -0,0 +1,22 @@ +name: rebase upstream manual +on: workflow_dispatch +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Rebase + run: | + git config --local user.email "github-actions@users.noreply.github.com" + git config --local user.name "github-actions" + git remote add upstream http://github.com/facebook/buck2.git + git fetch upstream + git rebase upstream/main + - name: Push changes + uses: ad-m/github-push-action@master + with: + force_with_lease: true + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} diff --git a/.github/workflows/upload_buck2.yml b/.github/workflows/upload_buck2.yml deleted file mode 100644 index 6bc160e6c1633..0000000000000 --- a/.github/workflows/upload_buck2.yml +++ /dev/null @@ -1,240 +0,0 @@ -name: Build, upload, and tag `buck2` - -on: - push: - branches: - - main - -jobs: - get_prelude_hash: - name: Get the latest prelude hash - runs-on: ubuntu-latest - outputs: - prelude_hash: ${{ steps.get_latest_prelude_hash.outputs.prelude_hash }} - steps: - - name: Shallow clone buck2-prelude - run: git clone --depth=1 https://github.com/facebook/buck2-prelude - - name: Get latest commit hash into prelude_hash - id: get_latest_prelude_hash - run: | - mkdir artifacts/ - cd buck2-prelude/ - git rev-parse HEAD > ../artifacts/prelude_hash - echo "prelude_hash=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" - - name: Upload prelude_hash - uses: actions/upload-artifact@v3 - with: - path: artifacts/prelude_hash - name: prelude_hash - - build: - needs: - - get_prelude_hash - strategy: - fail-fast: false - matrix: - target: - - os: 'ubuntu-22.04' - triple: 'aarch64-unknown-linux-gnu' - cross: true - - os: 'ubuntu-22.04' - triple: 'aarch64-unknown-linux-musl' - cross: true - - os: 'ubuntu-22.04' - triple: 'x86_64-unknown-linux-gnu' - - os: 'ubuntu-22.04' - triple: 'x86_64-unknown-linux-musl' - cross: true - - os: 'macos-12' - triple: 'aarch64-apple-darwin' - cross: true - - os: 'macos-12' - triple: 'x86_64-apple-darwin' - - os: 'windows-2022' - triple: 'x86_64-pc-windows-msvc' - is_windows: true - runs-on: ${{ matrix.target.os }} - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: SebRollen/toml-action@v1.0.2 - id: read_rust_toolchain - with: - file: 'rust-toolchain' - field: 'toolchain.channel' - - uses: dtolnay/rust-toolchain@v1 - with: - toolchain: ${{ steps.read_rust_toolchain.outputs.value }} - targets: ${{ matrix.target.triple }} - - uses: Swatinem/rust-cache@v2 - with: - prefix-key: buck2-upload - key: ${{ matrix.target.triple }} - - uses: actions-rs/install@v0.1 - if: matrix.target.cross - with: - crate: cross - version: latest - - name: Set variables - id: set_variables - shell: bash - run: | - if [ -n "${{ matrix.target.is_windows }}" ]; then - echo "cargo_out=target/${{ matrix.target.triple }}/release/buck2.exe" >> "$GITHUB_OUTPUT" - echo "buck2_zst=artifacts/buck2-${{ matrix.target.triple }}.exe.zst" >> "$GITHUB_OUTPUT" - else - echo "cargo_out=target/${{ matrix.target.triple }}/release/buck2" >> "$GITHUB_OUTPUT" - echo "buck2_zst=artifacts/buck2-${{ matrix.target.triple }}.zst" >> "$GITHUB_OUTPUT" - fi - - name: Build - shell: bash - env: - RUSTFLAGS: "-C strip=debuginfo -C codegen-units=1" - run: | - # aarch64-linux builds need JEMALLOC_SYS_WITH_LG_PAGE=16 - # this is for e.g. linux running on apple silicon with native 16k pages - if [[ "${{ matrix.target.triple }}" == aarch64-unknown-linux* ]]; then - export JEMALLOC_SYS_WITH_LG_PAGE=16 - fi - - if [ -n "${{ matrix.target.cross }}" ]; then - CARGO=cross - else - CARGO=cargo - fi - $CARGO build --release --bin buck2 --target ${{ matrix.target.triple }} - - name: Sanity check with examples/with_prelude - if: ${{ !matrix.target.cross }} - shell: bash - run: | - BUCK2="$(pwd)/${{ steps.set_variables.outputs.cargo_out }}" - cd examples/with_prelude - "$BUCK2" build //rust/... //cpp/... //python/... -v=2 - - name: Move binary to artifacts/ - shell: bash - run: | - mkdir artifacts - zstd -z ${{ steps.set_variables.outputs.cargo_out }} -o ${{ steps.set_variables.outputs.buck2_zst }} - - name: Upload - uses: actions/upload-artifact@v3 - with: - name: buck2-${{ matrix.target.triple }} - path: ${{ steps.set_variables.outputs.buck2_zst }} - - release_latest: - name: Release `latest` tag - needs: - - build - - get_prelude_hash - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - # Publish a new tag and upload all aritfacts from `build` and `get_prelude_hash` - - uses: ./.github/actions/publish_tag - with: - tag: "latest" - github_token: ${{ secrets.GITHUB_TOKEN }} - - check_for_bi_monthly_release: - name: Check if there's a release for this half of the month already - runs-on: ubuntu-latest - needs: - - build - outputs: - tag: ${{ steps.check_if_we_need_to_tag.outputs.new_tag }} - steps: - - id: get_date - name: Store date information so we stay consistent between the steps - run: | - month=$(date +%Y-%m) - # The math below uses the day number "XX" as a number, but if it has a leading 0 and the - # second digit is larger than 7 this fails as it parses as an octal, so we use `sed` to fix: - day=$(date +%d | sed 's/^0*//') - tag=$(date +%Y-%m-%d) - echo "month=$month" >> "$GITHUB_OUTPUT" - echo "day=$day" >> "$GITHUB_OUTPUT" - echo "tag=$tag" >> "$GITHUB_OUTPUT" - cat "$GITHUB_OUTPUT" - - id: get_tags_count - name: Count the number of tags already published for this month - run: | - # GITHUB_REPOSITORY is used to allow this action to work on forks - url="https://api.github.com/repos/$GITHUB_REPOSITORY/tags" - curl --retry 5 -fsSL "$url" -o tags.txt - tags=$(cat tags.txt | jq -r ".[].name") - tags_count=$(echo "$tags" | grep -c "${{ steps.get_date.outputs.month }}" || true) - echo "tags_count=$tags_count" >> "$GITHUB_OUTPUT" - cat "$GITHUB_OUTPUT" - - id: check_if_we_need_to_tag - name: Check if we should tag - run: | - tags_count=${{ steps.get_tags_count.outputs.tags_count }} - day=${{ steps.get_date.outputs.day }} - tag=${{ steps.get_date.outputs.tag }} - - # If we're in the first half of the month, check if there are no tags for this month yet - if (( day < 15 && tags_count < 1 )); then echo "new_tag=${tag}" >> "$GITHUB_OUTPUT"; fi; - # Otherwise, tag if the count is less than 2. - if (( day >= 15 && tags_count < 2 )); then echo "new_tag=${tag}" >> "$GITHUB_OUTPUT"; fi; - cat $GITHUB_OUTPUT - - release_bi_monthly: - name: Release bi-monthly tag - needs: - - build - - check_for_bi_monthly_release - runs-on: ubuntu-latest - # Only perform this action if check_for_bi_monthly_release set a tag output - if: ${{ needs.check_for_bi_monthly_release.outputs.tag }} - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - # Publish a new tag and upload all aritfacts from `build` and `get_prelude_hash` - - uses: ./.github/actions/publish_tag - with: - tag: ${{ needs.check_for_bi_monthly_release.outputs.tag }} - github_token: ${{ secrets.GITHUB_TOKEN }} - - uses: facebook/dotslash-publish-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - config: .github/dotslash-config.json - tag: ${{ needs.check_for_bi_monthly_release.outputs.tag }} - - build_docs_job: - name: Publish buck2.build - runs-on: ubuntu-latest - needs: - - build - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Download Buck2 - uses: actions/download-artifact@v3 - with: - name: buck2-x86_64-unknown-linux-gnu - path: artifacts - - name: Decompress Buck2 - run: | - zstd -d artifacts/buck2-x86_64-unknown-linux-gnu.zst -o artifacts/buck2-release - chmod +x artifacts/buck2-release - - name: Install dependencies - run: | - sudo apt-get install -y yarn - id: build - - name: Build the Website - run: | - cd website - yarn - BUCK2_BIN="$GITHUB_WORKSPACE/artifacts/buck2-release" yarn build_prebuilt - - name: Deploy - uses: JamesIves/github-pages-deploy-action@releases/v4 - with: - branch: gh-pages # The branch the action should deploy to. - folder: website/build # The folder the action should deploy. - single-commit: true # Discard history for the gh-pages branch. diff --git a/examples/no_prelude/go/rules.bzl b/examples/no_prelude/go/rules.bzl index 0a0b1aeed8843..ec96767127393 100644 --- a/examples/no_prelude/go/rules.bzl +++ b/examples/no_prelude/go/rules.bzl @@ -14,7 +14,7 @@ def _go_binary_impl(ctx: AnalysisContext) -> list[Provider]: cmd = cmd_args([ctx.attrs.toolchain[GoCompilerInfo].compiler_path, "build", "-o", out.as_output()] + sources) - ctx.actions.run(cmd, category = "compile") + ctx.actions.run(cmd, env = {"GOCACHE":ctx.attrs.toolchain[GoCompilerInfo].GOCACHE}, category = "compile") return [ DefaultInfo(default_output = out), diff --git a/examples/no_prelude/platforms/BUCK b/examples/no_prelude/platforms/BUCK new file mode 100644 index 0000000000000..63f852afecbda --- /dev/null +++ b/examples/no_prelude/platforms/BUCK @@ -0,0 +1,3 @@ +load(":defs.bzl", "platforms") + +platforms(name = "platforms") diff --git a/examples/no_prelude/platforms/defs.bzl b/examples/no_prelude/platforms/defs.bzl new file mode 100644 index 0000000000000..bbe85a699b1cb --- /dev/null +++ b/examples/no_prelude/platforms/defs.bzl @@ -0,0 +1,33 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + +def _platforms(ctx): + configuration = ConfigurationInfo( + constraints = {}, + values = {}, + ) + + platform = ExecutionPlatformInfo( + label = ctx.label.raw_target(), + configuration = configuration, + executor_config = CommandExecutorConfig( + local_enabled = True, + remote_enabled = True, + use_limited_hybrid = True, + # Set those up based on what workers you've registered with NativeLink. + remote_execution_properties = { + "OSFamily": "linux", + "container-image": "docker://nativelink-toolchain-buck2:latest", + }, + remote_execution_use_case = "buck2-default", + remote_output_paths = "output_paths", + ), + ) + + return [DefaultInfo(), ExecutionPlatformRegistrationInfo(platforms = [platform])] + +platforms = rule(attrs = {}, impl = _platforms) diff --git a/examples/no_prelude/toolchains/go_toolchain.bzl b/examples/no_prelude/toolchains/go_toolchain.bzl index 6d921aed9d9f9..f5acb2ffd4519 100644 --- a/examples/no_prelude/toolchains/go_toolchain.bzl +++ b/examples/no_prelude/toolchains/go_toolchain.bzl @@ -7,24 +7,11 @@ GoCompilerInfo = provider( doc = "Information about how to invoke the go compiler.", - fields = ["compiler_path", "GOROOT"], + fields = ["compiler_path", "GOROOT", "GOCACHE"], ) def _go_toolchain_impl(ctx): - download = _download_toolchain(ctx) - - compiler_dst = ctx.actions.declare_output("compiler.exe" if host_info().os.is_windows else "compiler") - - cmd = cmd_args() - if host_info().os.is_windows: - compiler_src = cmd_args(download, format = "{}\\go\\bin\\go.exe", relative_to = (compiler_dst, 1)) - cmd.add([ctx.attrs._symlink_bat, compiler_dst.as_output(), compiler_src]) - else: - compiler_src = cmd_args(download, format = "{}/go/bin/go", relative_to = (compiler_dst, 1)) - cmd.add(["ln", "-sf", compiler_src, compiler_dst.as_output()]) - - ctx.actions.run(cmd, category = "cp_compiler") - return [DefaultInfo(default_output = download), GoCompilerInfo(compiler_path = compiler_dst, GOROOT = "")] + return [DefaultInfo(), GoCompilerInfo(compiler_path = "go", GOROOT = "", GOCACHE="/tmp/gocache")] go_toolchain = rule( impl = _go_toolchain_impl, diff --git a/examples/remote_execution/nativelink/platforms/defs.bzl b/examples/remote_execution/nativelink/platforms/defs.bzl index 754201cbbeea8..bbe85a699b1cb 100644 --- a/examples/remote_execution/nativelink/platforms/defs.bzl +++ b/examples/remote_execution/nativelink/platforms/defs.bzl @@ -21,7 +21,7 @@ def _platforms(ctx): # Set those up based on what workers you've registered with NativeLink. remote_execution_properties = { "OSFamily": "linux", - "container-image": "docker://ghcr.io/catthehacker/ubuntu:act-22.04@sha256:5f9c35c25db1d51a8ddaae5c0ba8d3c163c5e9a4a6cc97acd409ac7eae239448", + "container-image": "docker://nativelink-toolchain-buck2:latest", }, remote_execution_use_case = "buck2-default", remote_output_paths = "output_paths", diff --git a/prelude/platforms/defs.bzl b/prelude/platforms/defs.bzl index ca6710bbc19d5..a6d251eb7d927 100644 --- a/prelude/platforms/defs.bzl +++ b/prelude/platforms/defs.bzl @@ -17,7 +17,19 @@ def _execution_platform_impl(ctx: AnalysisContext) -> list[Provider]: configuration = cfg, executor_config = CommandExecutorConfig( local_enabled = True, - remote_enabled = False, + remote_enabled = True, + use_limited_hybrid = True, + allow_limited_hybrid_fallbacks = False, + allow_hybrid_fallbacks_on_failure = False, + experimental_low_pass_filter = False, + remote_cache_enabled = True, + remote_execution_properties = { + "OSFamily": "linux", + "container-image": "docker://nativelink-toolchain-buck2:latest", + # "container-image": "docker://test:latest", + }, + remote_execution_use_case = "buck2-default", + remote_output_paths = "output_paths", use_windows_path_separators = ctx.attrs.use_windows_path_separators, ), )