From 9523f420a52c7babb5e8c401b75ce1f9fe101260 Mon Sep 17 00:00:00 2001 From: thomasvl Date: Tue, 19 Feb 2019 11:08:16 -0500 Subject: [PATCH 1/7] Simplify the running of buildifier on CI. As of 0.22.0 there are enough improvements in outputs and exit codes that it seems to make more sense to no longer try to pretty the results and just rely on a run and exit status to add a footer telling folks how to fix up things if something is found. RELNOTES: None. PiperOrigin-RevId: 234603600 --- travis_test.sh | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/travis_test.sh b/travis_test.sh index 35142d4..797be36 100755 --- a/travis_test.sh +++ b/travis_test.sh @@ -55,43 +55,30 @@ if [[ -n "${BUILDIFIER:-}" ]]; then # Check for format issues? if [[ "${FORMAT:-yes}" == "yes" ]] ; then - # bazelbuild/buildtools/issues/220 - diff doesn't include the file that needs updating - if ! find . "${FIND_ARGS[@]}" -print | xargs buildifier -d > /dev/null 2>&1 ; then - if [[ "${FOUND_ISSUES}" != "no" ]] ; then - echo "" - fi - echo "ERROR: BUILD/.bzl file formatting issue(s):" - echo "" - # bazelbuild/buildtools/issues/329 - sed out the exit status lines. - find . "${FIND_ARGS[@]}" -print -exec buildifier -v -d {} \; \ - 2>&1 | sed -E -e '/^exit status 1$/d' + echo "buildifier: validating formatting..." + if ! find . "${FIND_ARGS[@]}" -print | xargs buildifier -d ; then echo "" echo "Please download the latest buildifier" echo " https://github.com/bazelbuild/buildtools/releases" echo "and run it over the changed BUILD/.bzl files." + echo "" FOUND_ISSUES="yes" fi fi # Check for lint issues? if [[ "${LINT:-yes}" == "yes" ]] ; then + echo "buildifier: running lint checks..." # NOTE: buildifier defaults to --mode=fix, so these lint runs also # reformat the files. But since this is on travis, that is fine. # https://github.com/bazelbuild/buildtools/issues/453 - if ! find . "${FIND_ARGS[@]}" -print | xargs buildifier --lint=warn > /dev/null 2>&1 ; then - if [[ "${FOUND_ISSUES}" != "no" ]] ; then - echo "" - fi - echo "ERROR: BUILD/.bzl lint issue(s):" - echo "" - # buildifier now exits with error if there are issues, so use `|| true` - # to keep the script running. - find . "${FIND_ARGS[@]}" -print | xargs buildifier --lint=warn || true + if ! find . "${FIND_ARGS[@]}" -print | xargs buildifier --lint=warn ; then echo "" echo "Please download the latest buildifier" echo " https://github.com/bazelbuild/buildtools/releases" echo "and run it with --lint=(warn|fix) over the changed BUILD/.bzl files" echo "and make the edits as needed." + echo "" FOUND_ISSUES="yes" fi fi From dabf718975760b4d45bd7db3e18bc12e7b4ef485 Mon Sep 17 00:00:00 2001 From: thomasvl Date: Wed, 27 Feb 2019 13:20:22 -0500 Subject: [PATCH 2/7] CI config updates: - Expand the buildkite setup to cover released and latest-green. - Enable buildifier on buildkite. - Add a build badge to the README.md. - Drop travis down to just buildifier since it does some things buildkite support doesn't do yet. RELNOTES: None PiperOrigin-RevId: 235943968 --- .bazelci/presubmit.yml | 18 ++++++++++++++++-- .travis.yml | 2 -- README.md | 1 + 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 7c2b0c7..ae5eb2b 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -1,7 +1,21 @@ --- -platforms: - macos: +tasks: + macos_latest: + name: "Latest Bazel" + platform: macos + bazel: latest build_targets: - "//..." test_targets: - "//..." + + macos_last_green: + name: "Last Green Bazel" + platform: macos + bazel: last_green + build_targets: + - "//..." + test_targets: + - "//..." + +buildifier: true diff --git a/.travis.yml b/.travis.yml index 5bd74e4..1044117 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,8 +21,6 @@ matrix: sudo: false language: c++ env: BUILDIFIER=RELEASE - # The normal macOS builds. - - env: BAZEL=HEAD TARGET=//... before_install: diff --git a/README.md b/README.md index d9bd550..ba3d261 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Apple Support for [Bazel](https://bazel.build) [![Build Status](https://travis-ci.org/bazelbuild/apple_support.svg?branch=master)](https://travis-ci.org/bazelbuild/apple_support) +[![Build Status](https://badge.buildkite.com/6739ca70cb485ecec4ec403f4d6775269728aece4bb984127f.svg)](https://buildkite.com/bazel/apple-support-darwin) This repository contains helper methods that support building rules that target Apple platforms. From 0e2d4312b156c8ebec93413f1b25c92ae76da7d2 Mon Sep 17 00:00:00 2001 From: thomasvl Date: Mon, 4 Mar 2019 11:13:39 -0500 Subject: [PATCH 3/7] Travis CI Cleanup. Bazel's BuildKite seems to be fine for the bazel builds, so remove the support for doing bazel builds on Travis. Note: Keeping the matrix as a manual build and some of the conditions in the scripts just to reduce the chances of something not being right, as eventually the BuildKite setup will match the buildifier support and these files will just get dropped. RELNOTES: None PiperOrigin-RevId: 236655099 --- .travis.yml | 14 -------------- travis_install.sh | 42 ------------------------------------------ travis_test.sh | 20 -------------------- 3 files changed, 76 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1044117..e4d141e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,4 @@ -os: osx -# Not really swift, but stops travis from saying it is ruby. -language: swift -# Travis does not use osx_image when it computes the matrix itself, if we want -# to test on multiple versions, then it required manually building the matrix -# to set a different osx_image for each configuration. -osx_image: xcode10.1 - -# Build out the matrix ourselves so we can set multiple variables. -# - `BAZEL`: Used in `before_install` to pick the version of bazel to use, -# "RELEASE" extracts from https://github.com/bazelbuild/bazel/releases/latest, -# otherwise it is the tag to fetch. -# - `TARGET`: Are used in the `script` to issue a build `script` phase will be -# used for `bazel test`. matrix: include: # One build on linux to run buildifier since linux agents are faster on travis. diff --git a/travis_install.sh b/travis_install.sh index bef55ea..e8e0a89 100755 --- a/travis_install.sh +++ b/travis_install.sh @@ -34,47 +34,6 @@ function github_latest_release_tag() { | sed -e 's,https://.*/releases/tag/\(.*\),\1,' } -# ------------------------------------------------------------------------------------------------- -# Helper to get a download url out of bazel build metadata file. -function url_from_bazel_manifest() { - local MANIFEST_URL=$1 - if [[ "${OS}" == "darwin" ]]; then - local JSON_OS="macos" - else - local JSON_OS="ubuntu1404" - fi - wget -O - "${MANIFEST_URL}" \ - | python -c "import json; import sys; print json.load(sys.stdin)['platforms']['${JSON_OS}']['url']" -} - -# ------------------------------------------------------------------------------------------------- -# Helper to install bazel. -function install_bazel() { - local VERSION="${1}" - - if [[ "${VERSION}" == "RELEASE" ]]; then - VERSION="$(github_latest_release_tag bazelbuild/bazel)" - fi - - # macOS and trusty images have jdk8, so install bazel without jdk. - if [[ "${VERSION}" == "HEAD" ]]; then - # bazelbuild/continuous-integration/issues/234 - they don't seem to have an installed - # just raw binaries? - mkdir -p "$HOME/bin" - wget -O "$HOME/bin/bazel" \ - "$(url_from_bazel_manifest https://storage.googleapis.com/bazel-builds/metadata/latest.json)" - chmod +x "$HOME/bin/bazel" - else - wget -O install.sh \ - "https://github.com/bazelbuild/bazel/releases/download/${VERSION}/bazel-${VERSION}-without-jdk-installer-${OS}-x86_64.sh" - chmod +x install.sh - ./install.sh --user - rm -f install.sh - fi - - bazel version -} - # ------------------------------------------------------------------------------------------------- # Helper to install buildifier. function install_buildifier() { @@ -103,5 +62,4 @@ function install_buildifier() { # ------------------------------------------------------------------------------------------------- # Install what is requested. -[[ -z "${BAZEL:-}" ]] || install_bazel "${BAZEL}" [[ -z "${BUILDIFIER:-}" ]] || install_buildifier "${BUILDIFIER}" diff --git a/travis_test.sh b/travis_test.sh index 797be36..1dea1d0 100755 --- a/travis_test.sh +++ b/travis_test.sh @@ -16,26 +16,6 @@ set -eu -# ------------------------------------------------------------------------------------------------- -# Asked to do a bazel build. -if [[ -n "${BAZEL:-}" ]]; then - # - Crank down the progress messages to not flood the travis log, but still - # provide some output so there is an indicator things aren't hung. - # - "--test_output=errors" causes failures to report more completely since - # just getting the log file info isn't that useful on CI. - set -x - TEST_ARGS=( - test - --show_progress_rate_limit=30.0 - --test_output=errors - ) - if [[ -n "${TAGS:-}" ]]; then - TEST_ARGS+=( "--test_tag_filters=${TAGS}") - fi - bazel "${TEST_ARGS[@]}" "${TARGET}" - set +x -fi - # ------------------------------------------------------------------------------------------------- # Asked to do a buildifier run. if [[ -n "${BUILDIFIER:-}" ]]; then From 3f0fe1102af1dcae48a4f7700ed1b6a08d20104d Mon Sep 17 00:00:00 2001 From: Florian Weikert Date: Thu, 7 Mar 2019 10:48:46 -0500 Subject: [PATCH 4/7] Fix Buildifier version "buildifier: true" has been deprecated by https://github.com/bazelbuild/continuous-integration/pull/542 Closes #18. RELNOTES: None. PiperOrigin-RevId: 237246313 --- .bazelci/presubmit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index ae5eb2b..2b1104f 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -18,4 +18,4 @@ tasks: test_targets: - "//..." -buildifier: true +buildifier: latest From 7b1af74aa8ff48d0c4b3399162837f350b333682 Mon Sep 17 00:00:00 2001 From: thomasvl Date: Fri, 8 Mar 2019 17:38:49 -0500 Subject: [PATCH 5/7] Drop travis ci. bazel ci on buildkite is providing everything now. RELNOTES: None. PiperOrigin-RevId: 237521953 --- .travis.yml | 25 ----------------- README.md | 1 - travis_install.sh | 65 ------------------------------------------- travis_test.sh | 70 ----------------------------------------------- 4 files changed, 161 deletions(-) delete mode 100644 .travis.yml delete mode 100755 travis_install.sh delete mode 100755 travis_test.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e4d141e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ - -matrix: - include: - # One build on linux to run buildifier since linux agents are faster on travis. - - os: linux - dist: trusty - sudo: false - language: c++ - env: BUILDIFIER=RELEASE - - -before_install: - - ./travis_install.sh - -script: - - ./travis_test.sh - -notifications: - email: false - -# Don't build the google branch since that is used by the export process and a PR -# will be made after the fact. -branches: - except: - - google diff --git a/README.md b/README.md index ba3d261..804e855 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Apple Support for [Bazel](https://bazel.build) -[![Build Status](https://travis-ci.org/bazelbuild/apple_support.svg?branch=master)](https://travis-ci.org/bazelbuild/apple_support) [![Build Status](https://badge.buildkite.com/6739ca70cb485ecec4ec403f4d6775269728aece4bb984127f.svg)](https://buildkite.com/bazel/apple-support-darwin) This repository contains helper methods that support building rules that target diff --git a/travis_install.sh b/travis_install.sh deleted file mode 100755 index e8e0a89..0000000 --- a/travis_install.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash - -# Copyright 2018 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eux - -if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then - OS=darwin -else - OS=linux -fi - -# ------------------------------------------------------------------------------------------------- -# Helper to use the github redirect to find the latest release. -function github_latest_release_tag() { - local PROJECT=$1 - curl \ - -s \ - -o /dev/null \ - --write-out '%{redirect_url}' \ - "https://github.com/${PROJECT}/releases/latest" \ - | sed -e 's,https://.*/releases/tag/\(.*\),\1,' -} - -# ------------------------------------------------------------------------------------------------- -# Helper to install buildifier. -function install_buildifier() { - local VERSION="${1}" - - if [[ "${VERSION}" == "RELEASE" ]]; then - VERSION="$(github_latest_release_tag bazelbuild/buildtools)" - fi - - if [[ "${VERSION}" == "HEAD" ]]; then - echo "buildifier head is not supported" - exit 1 - fi - - if [[ "${OS}" == "darwin" ]]; then - URL="https://github.com/bazelbuild/buildtools/releases/download/${VERSION}/buildifier.osx" - else - URL="https://github.com/bazelbuild/buildtools/releases/download/${VERSION}/buildifier" - fi - - mkdir -p "$HOME/bin" - wget -O "${HOME}/bin/buildifier" "${URL}" - chmod +x "${HOME}/bin/buildifier" - buildifier --version -} - -# ------------------------------------------------------------------------------------------------- -# Install what is requested. -[[ -z "${BUILDIFIER:-}" ]] || install_buildifier "${BUILDIFIER}" diff --git a/travis_test.sh b/travis_test.sh deleted file mode 100755 index 1dea1d0..0000000 --- a/travis_test.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash - -# Copyright 2018 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -eu - -# ------------------------------------------------------------------------------------------------- -# Asked to do a buildifier run. -if [[ -n "${BUILDIFIER:-}" ]]; then - FOUND_ISSUES="no" - - # buildifier supports BUILD/WORKSPACE/*.bzl files, this provides the args - # to reuse in all the finds. - FIND_ARGS=( - \( - -name BUILD - -o - -name WORKSPACE - -o - -name "*.bzl" - \) - ) - - # Check for format issues? - if [[ "${FORMAT:-yes}" == "yes" ]] ; then - echo "buildifier: validating formatting..." - if ! find . "${FIND_ARGS[@]}" -print | xargs buildifier -d ; then - echo "" - echo "Please download the latest buildifier" - echo " https://github.com/bazelbuild/buildtools/releases" - echo "and run it over the changed BUILD/.bzl files." - echo "" - FOUND_ISSUES="yes" - fi - fi - - # Check for lint issues? - if [[ "${LINT:-yes}" == "yes" ]] ; then - echo "buildifier: running lint checks..." - # NOTE: buildifier defaults to --mode=fix, so these lint runs also - # reformat the files. But since this is on travis, that is fine. - # https://github.com/bazelbuild/buildtools/issues/453 - if ! find . "${FIND_ARGS[@]}" -print | xargs buildifier --lint=warn ; then - echo "" - echo "Please download the latest buildifier" - echo " https://github.com/bazelbuild/buildtools/releases" - echo "and run it with --lint=(warn|fix) over the changed BUILD/.bzl files" - echo "and make the edits as needed." - echo "" - FOUND_ISSUES="yes" - fi - fi - - # Anything? - if [[ "${FOUND_ISSUES}" != "no" ]] ; then - exit 1 - fi -fi From c86bf4ce81f073adea51cdf3333cf32052710573 Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 29 Mar 2019 13:01:23 -0400 Subject: [PATCH 6/7] Clean up framework support This is an NFC, as it supports both the pre- and post- cleanup APIs. RELNOTES: None PiperOrigin-RevId: 240998664 --- lib/framework_migration.bzl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lib/framework_migration.bzl diff --git a/lib/framework_migration.bzl b/lib/framework_migration.bzl new file mode 100644 index 0000000..3aa13e7 --- /dev/null +++ b/lib/framework_migration.bzl @@ -0,0 +1,28 @@ +# Copyright 2019 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Helper functions related to apple framework cleanup migration.""" + +def _is_post_framework_migration(): + """Determine whether bazel is pre- or post- framework infrastructure migration. + + Returns: + Whether bazel has been updated to use the new framework infrastructure. + """ + + return hasattr(apple_common.new_objc_provider(), "static_framework_names") + +framework_migration = struct( + is_post_framework_migration = _is_post_framework_migration, +) From bdcef226ad626bd8b9a4a377347a2f8c1726f3bb Mon Sep 17 00:00:00 2001 From: kaipi Date: Mon, 1 Apr 2019 15:01:41 -0400 Subject: [PATCH 7/7] Update Skylib version to 0.8.0 RELNOTES: None PiperOrigin-RevId: 241371321 --- lib/repositories.bzl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/repositories.bzl b/lib/repositories.bzl index 31f59ee..3ada98c 100644 --- a/lib/repositories.bzl +++ b/lib/repositories.bzl @@ -14,7 +14,7 @@ """Definitions for handling Bazel repositories used by apple_support.""" -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def _maybe(repo_rule, name, **kwargs): """Executes the given repository rule if it hasn't been executed already. @@ -35,8 +35,10 @@ def apple_support_dependencies(): changes to those dependencies. """ _maybe( - git_repository, + http_archive, name = "bazel_skylib", - remote = "https://github.com/bazelbuild/bazel-skylib.git", - tag = "0.7.0", + urls = [ + "https://github.com/bazelbuild/bazel-skylib/releases/download/0.8.0/bazel-skylib.0.8.0.tar.gz", + ], + sha256 = "2ef429f5d7ce7111263289644d233707dba35e39696377ebab8b0bc701f7818e", )