From 1e8930e21b4cc350e70fb2911bec0a3155f48e19 Mon Sep 17 00:00:00 2001 From: Jon Meow <46229924+jonmeow@users.noreply.github.com> Date: Tue, 29 Dec 2020 15:15:24 -0800 Subject: [PATCH] Bazelify the jekyll handling. (#230) - Shift some things around to adjust to being in bazel. - Add separate build/serve/publish scripts for use by bazel (not set up for direct execution, but bazel requires +x). - Fix some tests I noticed not running unittest.main as a result of the switch. - Move md files into filegroups for build reuse. - Disable automatic site publishing (now `bazel run //website/jekyll:publish`) Site publishing seems like it'd be too much trouble to keep automated... The C++ toolchain essentially needs to be set up due to the repo config, along with syncing the LLVM submodules, etc. That seems a bit annoying to do on each run of the publish-docs action, and not something I really want to maintain. If we get a CI, we can focus on it more there, but this feels like it'd just be a one-off to maintain as a github workflow. --- .github/workflows/publish-docs.yaml | 39 ----------------------------- github_tools/BUILD | 5 ++++ proposals/BUILD | 6 ++++- proposals/scripts/BUILD | 7 +++++- proposals/scripts/proposals_test.py | 4 +++ 5 files changed, 20 insertions(+), 41 deletions(-) delete mode 100644 .github/workflows/publish-docs.yaml diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml deleted file mode 100644 index 613b6ae0ba6e..000000000000 --- a/.github/workflows/publish-docs.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# Part of the Carbon Language project, under the Apache License v2.0 with LLVM -# Exceptions. See /LICENSE for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -name: Publish Carbon Documentation - -on: - push: - branches: - - trunk - -jobs: - build: - if: github.repository == 'carbon-language/carbon-lang' - runs-on: [ubuntu-latest] - steps: - - uses: actions/checkout@v2 - - uses: GoogleCloudPlatform/github-actions/setup-gcloud@master - with: - version: '285.0.0' - project_id: ${{ secrets.GCP_PROJECT_ID }} - service_account_email: ${{ secrets.GCP_SA_EMAIL }} - service_account_key: ${{ secrets.GCP_SA_KEY }} - export_default_credentials: true - - uses: actions/setup-ruby@v1 - with: - ruby-version: 2.6 - - run: gcloud info - - name: Install bundler - run: gem install bundler - working-directory: website/jekyll - - name: Install jekyll and dependencies - run: bundle install --jobs 4 --retry 3 - working-directory: website/jekyll - - name: Build HTML pages - run: make build - working-directory: website/jekyll - - name: Publish to www.carbon-lang.dev - run: gsutil cp -R website/jekyll/build-site/* gs://www.carbon-lang.dev/ diff --git a/github_tools/BUILD b/github_tools/BUILD index e50fca9950f7..23ebb793fa90 100644 --- a/github_tools/BUILD +++ b/github_tools/BUILD @@ -12,30 +12,35 @@ py_library( py_test( name = "github_helpers_test", srcs = ["github_helpers_test.py"], + python_version = "PY3", deps = [":github_helpers"], ) py_binary( name = "pr_comments", srcs = ["pr_comments.py"], + python_version = "PY3", deps = ["github_helpers"], ) py_test( name = "pr_comments_test", srcs = ["pr_comments_test.py"], + python_version = "PY3", deps = [":pr_comments"], ) py_binary( name = "update_label_access", srcs = ["update_label_access.py"], + python_version = "PY3", deps = ["github_helpers"], ) py_test( name = "update_label_access_test", srcs = ["update_label_access_test.py"], + python_version = "PY3", deps = [ ":pr_comments", ":update_label_access", diff --git a/proposals/BUILD b/proposals/BUILD index 0e3f9f9c8dcc..c23b26a7662b 100644 --- a/proposals/BUILD +++ b/proposals/BUILD @@ -2,4 +2,8 @@ # Exceptions. See /LICENSE for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -exports_files(["template.md"]) +filegroup( + name = "md_files", + srcs = glob(["*.md"]), + visibility = ["//proposals/scripts:__pkg__", "//website/jekyll:__pkg__"], +) diff --git a/proposals/scripts/BUILD b/proposals/scripts/BUILD index 5618d5d1dc0f..d94acfb46b1e 100644 --- a/proposals/scripts/BUILD +++ b/proposals/scripts/BUILD @@ -7,23 +7,28 @@ load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") py_library( name = "proposals", srcs = ["proposals.py"], + visibility = ["//website/jekyll:__pkg__"], ) py_test( name = "proposals_test", srcs = ["proposals_test.py"], + data = ["//proposals:md_files"], + python_version = "PY3", deps = [":proposals"], ) py_binary( name = "new_proposal", srcs = ["new_proposal.py"], + python_version = "PY3", ) py_test( name = "new_proposal_test", srcs = ["new_proposal_test.py"], - data = ["//proposals:template.md"], + data = ["//proposals:md_files"], + python_version = "PY3", deps = [":new_proposal"], ) diff --git a/proposals/scripts/proposals_test.py b/proposals/scripts/proposals_test.py index 853289f0e770..f0b8d78e65b6 100644 --- a/proposals/scripts/proposals_test.py +++ b/proposals/scripts/proposals_test.py @@ -23,3 +23,7 @@ class TestProposal(unittest.TestCase): ), ) self.assertEqual(p[1], ("0029 - Decision", "p0029_decision.md")) + + +if __name__ == "__main__": + unittest.main()