From 9bc39634d2ffd25d8f640ebea0f6b3839b09f41c Mon Sep 17 00:00:00 2001 From: Rob Anderson Date: Fri, 19 Jan 2024 09:10:38 -0800 Subject: [PATCH] convert circleci workflows to github actions (#533) Summary: Pull Request resolved: https://github.com/facebook/buck2/pull/533 Test Plan: https://github.com/robandpdx-org/buck2/actions/runs/7585649935 Reviewed By: ndmitchell Differential Revision: D52910227 Pulled By: shayne-fletcher fbshipit-source-id: f2a8964cc2d92614fb3cf77b7792223e308db13e --- .github/actions/build_bootstrap/action.yml | 7 +++ .github/actions/build_debug/action.yml | 10 ++++ .../actions/build_example_conan/action.yml | 14 ++++++ .../build_example_no_prelude/action.yml | 9 ++++ .github/actions/build_release/action.yml | 10 ++++ .github/actions/init_opam/action.yml | 13 +++++ .github/actions/print_versions/action.yml | 12 +++++ .github/actions/run_test_py/action.yml | 7 +++ .github/actions/setup_linux_env/action.yml | 24 ++++++++++ .github/actions/setup_macos_env/action.yml | 15 ++++++ .github/actions/setup_reindeer/action.yml | 9 ++++ .github/actions/setup_windows_env/action.yml | 27 +++++++++++ .github/workflows/build-and-test.yml | 47 +++++++++++++++++++ 13 files changed, 204 insertions(+) create mode 100644 .github/actions/build_bootstrap/action.yml create mode 100644 .github/actions/build_debug/action.yml create mode 100644 .github/actions/build_example_conan/action.yml create mode 100644 .github/actions/build_example_no_prelude/action.yml create mode 100644 .github/actions/build_release/action.yml create mode 100644 .github/actions/init_opam/action.yml create mode 100644 .github/actions/print_versions/action.yml create mode 100644 .github/actions/run_test_py/action.yml create mode 100644 .github/actions/setup_linux_env/action.yml create mode 100644 .github/actions/setup_macos_env/action.yml create mode 100644 .github/actions/setup_reindeer/action.yml create mode 100644 .github/actions/setup_windows_env/action.yml create mode 100644 .github/workflows/build-and-test.yml diff --git a/.github/actions/build_bootstrap/action.yml b/.github/actions/build_bootstrap/action.yml new file mode 100644 index 0000000000000..0b2bb0e600458 --- /dev/null +++ b/.github/actions/build_bootstrap/action.yml @@ -0,0 +1,7 @@ +name: build_bootstrap +runs: + using: composite + steps: + - name: Build `buck2` with `buck2` + run: "$RUNNER_TEMP/artifacts/buck2 build :buck2 -v 2" + shell: bash \ No newline at end of file diff --git a/.github/actions/build_debug/action.yml b/.github/actions/build_debug/action.yml new file mode 100644 index 0000000000000..5504a83550bbe --- /dev/null +++ b/.github/actions/build_debug/action.yml @@ -0,0 +1,10 @@ +name: build_debug +description: Build buck2 binary (debug) +runs: + using: composite + steps: + - name: Build buck2 binary (debug) + run: |- + mkdir $RUNNER_TEMP/artifacts + cargo build --bin=buck2 -Z unstable-options --out-dir=$RUNNER_TEMP/artifacts + shell: bash \ No newline at end of file diff --git a/.github/actions/build_example_conan/action.yml b/.github/actions/build_example_conan/action.yml new file mode 100644 index 0000000000000..6213ab4a5176f --- /dev/null +++ b/.github/actions/build_example_conan/action.yml @@ -0,0 +1,14 @@ +name: build_example_conan +runs: + using: composite + steps: + - name: Build examples/toolchains/conan_toolchain + run: |- + cd examples/toolchains/conan_toolchain + $RUNNER_TEMP/artifacts/buck2 init + cp -r ../../../prelude prelude + # Generate Conan imports. TODO[AH] Make that unnecessary. + PATH="$RUNNER_TEMP/artifacts:$PATH" $RUNNER_TEMP/artifacts/buck2 run //cpp/conan:update -v 2 + $RUNNER_TEMP/artifacts/buck2 build //... -v 2 + $RUNNER_TEMP/artifacts/buck2 test //... -v 2 + shell: bash diff --git a/.github/actions/build_example_no_prelude/action.yml b/.github/actions/build_example_no_prelude/action.yml new file mode 100644 index 0000000000000..7f3e09a5effa8 --- /dev/null +++ b/.github/actions/build_example_no_prelude/action.yml @@ -0,0 +1,9 @@ +name: build_example_no_prelude +runs: + using: composite + steps: + - name: Build example/no_prelude directory + run: |- + cd examples/no_prelude + $RUNNER_TEMP/artifacts/buck2 build //... -v 2 + shell: bash diff --git a/.github/actions/build_release/action.yml b/.github/actions/build_release/action.yml new file mode 100644 index 0000000000000..9a79c966dd956 --- /dev/null +++ b/.github/actions/build_release/action.yml @@ -0,0 +1,10 @@ +name: build_release +description: Build buck2 binary (release) +runs: + using: composite + steps: + - name: Build buck2 binary (release) + run: |- + mkdir $RUNNER_TEMP/artifacts + cargo build --bin=buck2 --release -Z unstable-options --out-dir=$RUNNER_TEMP/artifacts + shell: bash \ No newline at end of file diff --git a/.github/actions/init_opam/action.yml b/.github/actions/init_opam/action.yml new file mode 100644 index 0000000000000..30f3424627073 --- /dev/null +++ b/.github/actions/init_opam/action.yml @@ -0,0 +1,13 @@ +name: init_opam +description: Setup OPAM +runs: + using: composite + steps: + - name: Initialize OPAM + run: | + opam init --compiler=5.1.1 --disable-sandboxing -y + echo 'eval $(opam env)' >> ~/.bashrc + shell: bash + - name: Install OPAM packages + run: opam install menhir ppxlib -y + shell: bash diff --git a/.github/actions/print_versions/action.yml b/.github/actions/print_versions/action.yml new file mode 100644 index 0000000000000..85efed99928b9 --- /dev/null +++ b/.github/actions/print_versions/action.yml @@ -0,0 +1,12 @@ +name: print_versions +runs: + using: composite + steps: + - name: Version Info + run: |- + rustup show + rustc --version + cargo --version + rustup --version + python3 --version + shell: bash \ No newline at end of file diff --git a/.github/actions/run_test_py/action.yml b/.github/actions/run_test_py/action.yml new file mode 100644 index 0000000000000..18019ca6d4738 --- /dev/null +++ b/.github/actions/run_test_py/action.yml @@ -0,0 +1,7 @@ +name: run_test_py +runs: + using: composite + steps: + - name: Run test.py + run: python3 test.py --ci --git --buck2=$RUNNER_TEMP/artifacts/buck2 + shell: bash \ No newline at end of file diff --git a/.github/actions/setup_linux_env/action.yml b/.github/actions/setup_linux_env/action.yml new file mode 100644 index 0000000000000..e490aff68b091 --- /dev/null +++ b/.github/actions/setup_linux_env/action.yml @@ -0,0 +1,24 @@ +name: Setup Linux environment +description: Setup Linux environment +runs: + using: composite + steps: + - 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 }} + components: clippy + - uses: Swatinem/rust-cache@v2 + with: + prefix-key: buck2-upload + - run: sudo apt-get update + shell: bash + - run: sudo apt-get install opam libzstd-dev python3-pip ghc + shell: bash + - name: Install conan + run: sudo pip3 install conan==1.* + shell: bash diff --git a/.github/actions/setup_macos_env/action.yml b/.github/actions/setup_macos_env/action.yml new file mode 100644 index 0000000000000..a0a9007b4b924 --- /dev/null +++ b/.github/actions/setup_macos_env/action.yml @@ -0,0 +1,15 @@ +name: setup_macos_env +description: Setup macOS environment +runs: + using: composite + steps: + - name: Install Rustup + run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=none + shell: bash + - name: Brew install + run: brew install cmake python3 coreutils opam llvm protobuf zstd ghc + shell: bash + - name: Install conan + run: sudo pip3 install conan==1.* + shell: bash + - uses: "./.github/actions/print_versions" diff --git a/.github/actions/setup_reindeer/action.yml b/.github/actions/setup_reindeer/action.yml new file mode 100644 index 0000000000000..3ab40cd942a40 --- /dev/null +++ b/.github/actions/setup_reindeer/action.yml @@ -0,0 +1,9 @@ +name: setup_reindeer +runs: + using: composite + steps: + - name: Install Reindeer + run: |- + cargo install --locked --git https://github.com/facebookincubator/reindeer reindeer + reindeer --third-party-dir shim/third-party/rust buckify + shell: bash \ No newline at end of file diff --git a/.github/actions/setup_windows_env/action.yml b/.github/actions/setup_windows_env/action.yml new file mode 100644 index 0000000000000..926c350a60cdc --- /dev/null +++ b/.github/actions/setup_windows_env/action.yml @@ -0,0 +1,27 @@ +name: setup_windows_env +description: Setup Windows environment for building and testing +runs: + using: composite + steps: + - name: Install Rustup + run: |- + choco install -y rustup.install + write-output "[net]`ngit-fetch-with-cli = true" | out-file -append -encoding utf8 $Env:USERPROFILE/.cargo/config.toml + type $Env:USERPROFILE/.cargo/config.toml + shell: pwsh + - name: Create python3 symlink + run: New-Item -ItemType SymbolicLink -Path C:\ProgramData\chocolatey\bin\python3.exe -Target $(Get-Command python).Source + shell: pwsh + - name: Write Powershell profile + run: |- + $psProfileContent = @' + $vsPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.VisualStudio.Component.VC.Llvm.Clang -property installationPath + $llvmPath = Join-Path $vsPath "VC\Tools\Llvm\x64\bin" + $env:PATH = "$env:USERPROFILE\.cargo\bin;$llvmPath;" + $env:PATH + $env:TEMP = "$env:USERPROFILE\temp" + $env:TMP = $env:TEMP + '@ + Add-Content "$PsHome\profile.ps1" $psProfileContent + New-Item -ItemType Directory -Path "$env:USERPROFILE\temp" + shell: pwsh + - uses: "./.github/actions/print_versions" \ No newline at end of file diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000000000..826b6dd4dc109 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,47 @@ +name: Build and test +on: + push: + pull_request: +jobs: + macos-build-examples: + runs-on: macos-latest + steps: + - uses: maxim-lobanov/setup-xcode@v1.6.0 + with: + xcode-version: 14.2.0 + - uses: actions/checkout@v4.1.0 + - uses: ./.github/actions/setup_macos_env + - uses: ./.github/actions/init_opam + - uses: ./.github/actions/build_release + - name: Build example/prelude directory + run: |- + eval $(opam env) + cd examples/with_prelude + $RUNNER_TEMP/artifacts/buck2 init + cp -r ../../prelude prelude + source ./ocaml-setup.sh + $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 + steps: + - uses: actions/checkout@v4.1.0 + - uses: ./.github/actions/setup_linux_env + - uses: ./.github/actions/init_opam + - uses: ./.github/actions/build_release + - name: Build example/prelude directory + run: |- + eval $(opam env) + cd examples/with_prelude + $RUNNER_TEMP/artifacts/buck2 init + cp -r ../../prelude prelude + source ./ocaml-setup.sh + $RUNNER_TEMP/artifacts/buck2 build //... -v 2 + $RUNNER_TEMP/artifacts/buck2 test //... -v 2 + - uses: ./.github/actions/build_example_conan + - uses: ./.github/actions/build_example_no_prelude + - uses: ./.github/actions/setup_reindeer + - uses: ./.github/actions/build_bootstrap