Skip to content

Commit

Permalink
Split up build script into ‘check’ and ‘generate’ targets.
Browse files Browse the repository at this point in the history
It doesn’t make sense to generate files in the pre-commit hook or in the
continuous integration pipeline.
  • Loading branch information
phst committed Dec 22, 2021
1 parent cb34dc1 commit a6e8c49
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

./build.py
./build.py check
2 changes: 1 addition & 1 deletion .github/workflows/bazel-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
release: false
if: runner.os == 'Windows'
- name: Run Bazel tests
run: python build.py
run: python build.py check
env:
USE_BAZEL_VERSION: ${{matrix.bazel}}
# https://github.com/bazelbuild/bazelisk/issues/88#issuecomment-625178467
Expand Down
22 changes: 16 additions & 6 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,24 @@ def wrapper() -> None:
@target
def default() -> None:
"""Builds all targets."""
generate()
check()

@target
def check() -> None:
"""Builds and tests the project."""
buildifier()
nogo()
docs()
# Test both default toolchain and versioned toolchains.
check()
test()
versions()
ext()

@target
def generate() -> None:
"""Generates files to be checked in."""
docs()

@target
def buildifier() -> None:
"""Checks that all BUILD files are formatted correctly."""
Expand All @@ -89,17 +99,17 @@ def nogo() -> None:
raise ValueError('unwanted Go targets in {file} found')

@target
def check() -> None:
def test() -> None:
"""Runs the Bazel tests."""
_check()
_test()

@target
def versions() -> None:
"""Runs the Bazel tests for all supported Emacs versions."""
for version in sorted(_versions()):
_check(f'--extra_toolchains=//elisp:emacs_{version}_toolchain')
_test(f'--extra_toolchains=//elisp:emacs_{version}_toolchain')

def _check(*args: str) -> None:
def _test(*args: str) -> None:
_bazel('test', ['//...'], options=['--test_output=errors'],
postfix_options=args)

Expand Down

0 comments on commit a6e8c49

Please sign in to comment.