Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

Commit c662c4f

Browse files
egpastfacebook-github-bot
authored andcommitted
Fix dev branch CircleCI (#2715)
Summary: Currently, all `dev` branch `publish_docs` jobs are failing [the Java 11 requirement](https://github.com/facebook/buck/blob/dev/build.xml#L365-L367). A lot of things need to be changed to pass that requirement: - Install OpenJDK 11 instead of 8 - Install new Android command-line tools. [The old SDK tools don't support JDK 8](https://stackoverflow.com/a/65782803). Oddly, [the *new* tools don't install to the right location](https://stackoverflow.com/a/67413427), so they need to be moved around a little before they'll work. - Install Python 3.9.4 (required by Ant) - Build Buck! Release-branch builds require Java 8, so we can't use those and hope to pass the version check. - Pass down our local Buck executable to `docs/publish.sh` and `docs/soyweb-prod.sh`. Otherwise, these scripts will try to use the Ant-bootstrapped Java 8 Buck instead of our locally built Java 11 Buck. They'll still use `buck` by default, so local usage is unaffected. This has been tested by adding a couple tweaks in [a separate branch](https://github.com/egpast/buck/commits/dev-force-circleci) to force `publish_docs` to run on commits and stop it from actually publishing, and then confirming that [CircleCI passes](https://app.circleci.com/pipelines/github/egpast/buck/25/workflows/b049df7e-9e0c-49a8-95d5-eee82aeb40bc/jobs/17). Pull Request resolved: #2715 Reviewed By: zpao Pulled By: egpast fbshipit-source-id: 8163a70188978814c3726c560653079f43fe901a
1 parent 89425fe commit c662c4f

File tree

3 files changed

+81
-30
lines changed

3 files changed

+81
-30
lines changed

.circleci/config.yml

+46-23
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ version: 2.1
33
orbs:
44
win: circleci/[email protected]
55

6-
install_openjdk8: &install_openjdk8
7-
name: Install OpenJDK8
6+
install_openjdk11: &install_openjdk11
7+
name: Install OpenJDK11
88
command: |
99
if [ "${PLATFORM}" == "linux" ]; then
10-
sudo apt-get update && sudo apt-get install openjdk-8-jdk
11-
sudo update-java-alternatives -s java-1.8.0-openjdk-amd64
10+
sudo apt-get update && sudo apt-get install openjdk-11-jdk
11+
sudo update-java-alternatives -s java-1.11.0-openjdk-amd64
1212
elif [ "${PLATFORM}" == "macos" ]; then
13-
brew cask install adoptopenjdk8
13+
brew install openjdk@11
14+
export PATH="/usr/local/opt/openjdk@11/bin:$PATH"
1415
fi
1516
java -version
1617
@@ -19,14 +20,15 @@ install_android_sdk: &install_android_sdk
1920
command: |
2021
sdk_os="linux"
2122
if [ "${PLATFORM}" == "macos" ]; then
22-
sdk_os="darwin"
23+
sdk_os="mac"
2324
fi
24-
sdk_zip_filename="sdk-tools-${sdk_os}-4333796.zip"
25-
mkdir -p "${ANDROID_SDK}"
26-
cd "${ANDROID_SDK}"
25+
sdk_zip_filename="commandlinetools-${sdk_os}-8512546_latest.zip"
26+
mkdir -p "${ANDROID_SDK}/cmdline-tools"
27+
cd "${ANDROID_SDK}/cmdline-tools"
2728
curl -O "https://dl.google.com/android/repository/${sdk_zip_filename}"
2829
unzip "${sdk_zip_filename}"
29-
export PATH="${ANDROID_SDK}/tools/bin:${PATH}"
30+
mv cmdline-tools latest
31+
export PATH="${ANDROID_SDK}/cmdline-tools/latest/bin:${PATH}"
3032
echo 'y' |sdkmanager --install tools
3133
echo 'y' |sdkmanager --install platform-tools
3234
echo 'y' |sdkmanager --install "build-tools;28.0.0"
@@ -40,24 +42,47 @@ install_android_sdk: &install_android_sdk
4042
fi
4143
4244
install_python: &install_python
43-
name: Install Python 3.6.2
45+
name: Install Python 3.9.4
4446
command: |
4547
if [ "${PLATFORM}" == "macos" ]; then
4648
brew install pyenv
4749
fi
48-
pyenv install -s 3.6.2
49-
pyenv global 3.6.2 system
50+
pyenv install -s 3.9.4
51+
pyenv global 3.9.4 system
5052
export PATH="$(pyenv root)/shims:${PATH}"
5153
python --version
5254
55+
run_ant_build: &run_ant_build
56+
name: Run Ant Build
57+
command: |
58+
if [ "${PLATFORM}" == "macos" ]; then
59+
# The latest ant depends on JDK13, install 1.9 instead.
60+
brew install [email protected]
61+
export PATH="/usr/local/opt/[email protected]/bin:${PATH}"
62+
fi
63+
cd "${BUCKROOT}"
64+
set -ex
65+
export ANT_OPTS='-Xmx1000m'
66+
ant
67+
68+
run_buck_build: &run_buck_build
69+
name: Run Buck Build
70+
command: |
71+
cd "${BUCKROOT}"
72+
echo '-Xmx1024m' > .buckjavaargs.local
73+
export PATH="${ANDROID_SDK}/tools/bin:${PATH}"
74+
export PATH="$(pyenv root)/shims:${PATH}"
75+
set -ex
76+
./bin/buck build buck --out "./${BUCK_PEX_LOCATION}" || { cat "buck-out/log/buck-0.log"; exit 1; }
77+
5378
linux_environment: &linux_environment
5479
# Use string constant for values, no environment variables
5580
PLATFORM: "linux"
5681
BUCKROOT: "/home/circleci/buck"
5782
ANDROID_SDK: "/home/circleci/android-sdk"
5883
TERM: "dumb"
5984
BUCK_NUM_THREADS: 3
60-
BUCK_PEX_LOCATION: "./new_buck.pex"
85+
BUCK_PEX_LOCATION: "new_buck.pex"
6186

6287
jobs:
6388
publish_docs:
@@ -69,26 +94,24 @@ jobs:
6994
steps:
7095
- checkout
7196
- run:
72-
<<: *install_openjdk8
97+
<<: *install_openjdk11
7398
- run:
7499
# android_sdk needed to build java docs.
75100
<<: *install_android_sdk
76101
- run:
77102
<<: *install_python
78103
- run:
79-
# We do not want to build buck, install the latest release instead.
80-
name: Install Buck
81-
command: |
82-
url=`curl -sH "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/facebook/buck/releases/latest |grep "browser_download_url.*deb" |awk '{gsub("\"", "", $2); print $2}'`
83-
curl -L -O $url
84-
filename=`basename ${url}`
85-
sudo dpkg -i ${filename} || echo "Warning: Buck installed without dependencies."
104+
<<: *run_ant_build
105+
- restore_cache:
106+
key: v-{{ .Environment.CACHE_VERSION }}-buck-build-{{ .Branch }}
107+
- run:
108+
<<: *run_buck_build
86109
- run:
87110
name: Publish docs
88111
command: |
89112
export ANDROID_HOME="${ANDROID_SDK}"
90113
cd docs
91-
./publish.sh --start-soyweb
114+
./publish.sh --buck-location "${BUCKROOT}/${BUCK_PEX_LOCATION}" --start-soyweb
92115
93116
workflows:
94117
version: 2.1

docs/publish.sh

+12-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set -e
1818

1919
start_soyweb() {
2020
echo "Starting soyweb-prod.sh" >&2
21-
./soyweb-prod.sh >&2 &
21+
./soyweb-prod.sh --buck-location "${BUCK_LOCATION}" >&2 &
2222
local soyweb_pid=$!
2323
sleep 2
2424
if ! kill -0 "$soyweb_pid" >/dev/null 2>&1; then
@@ -31,23 +31,29 @@ start_soyweb() {
3131

3232
show_help() {
3333
cat <<-EOF
34-
Usage: publish.sh [--start-soyweb] [--keep-files]
35-
--start-soyweb Start soyweb and shut it down when the script is finished
36-
--keep-files Keep temporary files after attempting to publish
37-
--help Show this help
34+
Usage: publish.sh [--buck-location BUCK_LOCATION] [--start-soyweb] [--keep-files]
35+
--buck-location Sets the location of the Buck executable to use
36+
--start-soyweb Start soyweb and shut it down when the script is finished
37+
--keep-files Keep temporary files after attempting to publish
38+
--help Show this help
3839
3940
Set the environment variables GIT_USER and GITHUB_TOKEN if you want to publish using another
4041
GitHub account. These variables are already set in CircleCI to automate publishing.
4142
EOF
4243
exit 1
4344
}
4445

46+
BUCK_LOCATION="buck"
4547
START_SOYWEB=0
4648
KEEP_FILES=0
4749
SOYWEB_PID=0
4850
for arg do
4951
shift
5052
case $arg in
53+
--buck-location)
54+
BUCK_LOCATION="$1"
55+
shift
56+
;;
5157
--start-soyweb) START_SOYWEB=1 ;;
5258
--keep-files) KEEP_FILES=1 ;;
5359
--help) show_help ;;
@@ -66,7 +72,7 @@ STATIC_FILES_DIR=$(mktemp -d)
6672

6773
# Always run this from the the docs dir
6874
cd "$DOCS_DIR"
69-
buck run //docs:generate_buckconfig_aliases
75+
"${BUCK_LOCATION}" run //docs:generate_buckconfig_aliases
7076

7177
if ( [[ -n $IS_GIT ]] && ! git diff --quiet ) || hg status | grep -q .; then
7278
echo "Repository is not clean; refusing to publish"

docs/soyweb-prod.sh

+23-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,28 @@
2020
# Remove any residual files that could derail build and publication.
2121
#
2222

23+
show_help() {
24+
cat <<-EOF
25+
Usage: soyweb-prod.sh [--buck-location BUCK_LOCATION]
26+
--buck-location Sets the location of the Buck executable to use
27+
--help Show this help
28+
EOF
29+
exit 1
30+
}
31+
32+
BUCK_LOCATION="buck"
33+
for arg do
34+
shift
35+
case $arg in
36+
--buck-location)
37+
BUCK_LOCATION="$1"
38+
shift
39+
;;
40+
--help) show_help ;;
41+
*) set -- "$@" "$arg" ;;
42+
esac
43+
done
44+
2345
DOCS_DIR=$(dirname "$0")
2446
BUCK_DIR=$(realpath "$DOCS_DIR/..")
2547
DOCS_DIR=$(realpath "$DOCS_DIR")
@@ -28,6 +50,6 @@ cd "$BUCK_DIR" || exit
2850
ant clean
2951

3052
cd "$BUCK_DIR/docs" || exit
31-
buck run //docs:generate_buckconfig_aliases
53+
"${BUCK_LOCATION}" run //docs:generate_buckconfig_aliases
3254
exec java -jar plovr-81ed862.jar soyweb --port 9814 --dir . --globals globals.json
3355

0 commit comments

Comments
 (0)