diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..c3d823001 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,40 @@ +// see https://aka.ms/devcontainer.json +{ + "name": "Enola.dev's Dev Containers.dev", + + // This is the "fat" container with a lot of ready tools + // from https://github.com/devcontainers/images/tree/main/src/universal + "image": "mcr.microsoft.com/devcontainers/universal:2-linux", + // + // "image": "mcr.microsoft.com/devcontainers/base:bookworm" + // from https://github.com/devcontainers/images/tree/main/src/base-debian + // from https://github.com/devcontainers/templates/tree/main/src/debian + // is very minimal, and we would need to add a lot... + // + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + + // https://containers.dev/implementors/json_reference/#lifecycle-scripts + // is what you want, NOT features' "ghcr.io/devcontainers-contrib/features/bash-command:1" + // (because that doesn't seem to have access to the workspace, whereas this does) + "onCreateCommand": "/workspaces/enola/test.bash", + + // Features to add to the dev container. More info: https://containers.dev/features. + "features": { + "ghcr.io/devcontainers/features/java:1": { + "version": "21", + }, + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" + + "hostRequirements": { + "cpus": 4, + }, +} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c998dd873..f58672df0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -141,7 +141,7 @@ repos: rev: v4.0.0-alpha.8 hooks: - id: prettier - exclude: ^docs/use|core/impl/src/test/resources + exclude: ^docs/use|core/impl/src/test/resources|.devcontainer/devcontainer.json - repo: https://github.com/pre-commit/mirrors-csslint rev: v1.0.5 diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 699f6aff7..ab89ed42a 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,6 @@ { "recommendations": [ + "redhat.java", "sfdc.bazel-vscode-java", "bazelbuild.vscode-bazel", "josevseb.google-java-format-for-vs-code", diff --git a/.vscode/settings.json b/.vscode/settings.json index 550505b7e..3104ce7e2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -86,11 +86,11 @@ "**/CVS": true, "**/.DS_Store": true, "**/Thumbs.db": true, + "**/*.crswap": true, "**/.classpath": true, - "**/.factorypath": true, "**/.project": true, "**/.settings": true, - "**/*.crswap": true, + "**/.factorypath": true, "**/eclipse-bin/": true, "**/eclipse-testbin/": true, "**/.bazeltargets": true, @@ -116,7 +116,8 @@ "web": false, "node_modules": false, ".be": false, - "bin": false + "bin": false, + ".devcontainer": false }, "markdown.validate.ignoredLinks": ["../dev/proto/core#id"], "java.compile.nullAnalysis.mode": "automatic", diff --git a/README.md b/README.md index dc227ed79..fc7a65715 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,5 @@ Enola is a Graph-based analytics system for exploring relationships between comm This project is not an official Google project. It is not supported by Google and Google specifically disclaims all warranties as to its quality, merchantability, or fitness for a particular purpose. ([`LICENSE`](LICENSE)) + +[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/enola-dev/enola?quickstart=1) diff --git a/common/markdown/src/test/java/dev/enola/common/markdown/exec/RunnerTest.java b/common/markdown/src/test/java/dev/enola/common/markdown/exec/RunnerTest.java index 1c91f3e4a..4bb8a3e3f 100644 --- a/common/markdown/src/test/java/dev/enola/common/markdown/exec/RunnerTest.java +++ b/common/markdown/src/test/java/dev/enola/common/markdown/exec/RunnerTest.java @@ -22,6 +22,8 @@ import static java.nio.file.Path.of; import static java.time.Duration.ofSeconds; +import com.google.common.truth.Truth; + import org.junit.Test; public class RunnerTest { @@ -32,7 +34,7 @@ void check(String command, boolean expectNonZeroExitCode, String expectedOutput) throws Exception { var sb = new StringBuffer(); var actualExitCode = runner.bash(expectNonZeroExitCode, of("."), command, sb, ofSeconds(3)); - assertEquals(expectedOutput, sb.toString()); + Truth.assertThat(sb.toString()).contains(expectedOutput); assertEquals(expectNonZeroExitCode, actualExitCode != 0); } @@ -53,6 +55,6 @@ public void testFalse() throws Exception { @Test public void testInexistantCommand() throws Exception { - check("does-not-exist", true, "bash: line 1: does-not-exist: command not found\n"); + check("does-not-exist", true, "does-not-exist: command not found\n"); } } diff --git a/docs/dev/ide.md b/docs/dev/ide.md index 0ea8e5205..6cd5e44d7 100644 --- a/docs/dev/ide.md +++ b/docs/dev/ide.md @@ -18,13 +18,25 @@ # IDE -## Eclipse +## Web IDE -Eclipse is not actively supported by this project as an IDE. +[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/enola-dev/enola?quickstart=1) -It may work using the [Bazel Eclipse Feature](https://github.com/salesforce/bazel-eclipse/blob/main/docs/bef/README.md), but this has not been tested yet. +Web-based IDEs are great to easily work from any computer. -We recommend using VSC. +We recommend you use GitHub Codespaces to contribute to this project by clicking on the button above. + +This project is configured to automatically configure your Codespace with all required tools. If anything doesn't just work "out of the box", please [create an issue](https://github.com/enola-dev/enola/issues). + +While the 32 GB disk space of the Codespace default _Machine Type_ is sufficient, its _2-core • 8 GB RAM_ is too limited for sufficiently efficient building, and at very least the _4-core • 16GB RAM_ (or bigger) is highly recommended. + +If you are missing your fancy custom Shell configuration that you have built over the last 100 years, +you should [set up your dotfiles for Codespaces](https://docs.github.com/en/codespaces/setting-your-user-preferences/personalizing-github-codespaces-for-your-account#dotfiles) +such as [e.g. this dude did in his dotfiles](https://github.com/vorburger/vorburger-dotfiles-bin-etc#github-codespaces). + +Alternatively, you can use [Visual Studio Code for the Web](https://code.visualstudio.com/docs/editor/vscode-web) at +together with a [Remote Tunnel](https://code.visualstudio.com/docs/editor/vscode-web#_use-your-own-compute-with-remote-tunnels) +e.g. to a computer at home, or a VM in the Cloud. ## Visual Studio Code (VSC) @@ -59,13 +71,6 @@ $ sudo apt get install clang-format * [Clang Formatter](https://marketplace.visualstudio.com/items?itemName=Seaube.clangformat) (this requires `clang-package`, see above) for `*.textproto` formatting -## Web IDE - -In order to work on this project with a purely Web-based IDE, which is great to hack from e.g. a Tablet or Work Computer or some such setup, -we recommend you use [Visual Studio Code for the Web](https://code.visualstudio.com/docs/editor/vscode-web) at -together with a [Remote Tunnel](https://code.visualstudio.com/docs/editor/vscode-web#_use-your-own-compute-with-remote-tunnels) -e.g. to a computer at home, or a VM in the Cloud. - ## JetBrains IntelliJ IDEA (IJ) IJ can be used as a complete alternative to VSC, or only for Java coding, with: @@ -78,6 +83,14 @@ IJ can be used as a complete alternative to VSC, or only for Java coding, with: * [Bamboo Soy](https://plugins.jetbrains.com/plugin/9841-bamboo-soy) for `*.soy` templates +## Eclipse + +Eclipse is not actively supported by this project as an IDE. + +It may work using the [Bazel Eclipse Feature](https://github.com/salesforce/bazel-eclipse/blob/main/docs/bef/README.md), but this has not been tested yet. + +We recommend using VSC. + ## Other Some [people prefer coding using 🙊](https://en.wikipedia.org/wiki/Editor_war) `hexedit` or one its derivatives 😈 such as `vi` or `emacs`. diff --git a/test.bash b/test.bash index 4b4378f76..4b307b36d 100755 --- a/test.bash +++ b/test.bash @@ -19,13 +19,31 @@ set -euo pipefail # Same also in the ./enola script: if ! [ -x "$(command -v bazelisk)" ]; then - echo "bazelisk is not installed, please run e.g. 'go install github.com/bazelbuild/bazelisk@latest' " - echo "or an equivalent from https://github.com/bazelbuild/bazelisk#installation or see docs/dev/setup.md" + if [ -x "$(command -v go)" ]; then + echo "go install bazelisk, buildifier, buildozer..." + go install github.com/bazelbuild/bazelisk@latest + go install github.com/bazelbuild/buildtools/buildifier@latest + go install github.com/bazelbuild/buildtools/buildozer@latest + + # Due to https://github.com/salesforce/bazel-vscode-java/issues/88, like in + # https://github.com/vorburger/vorburger-dotfiles-bin-etc/blob/ + # 64d3854b40f57183c81a0c9e054bafcbe3026ff7/all-install.sh#L66 + GO_BIN_PATH=$(go env GOPATH)/bin + ln -s "$GO_BIN_PATH"/bazelisk "$GO_BIN_PATH"/bazel + ln -s "$GO_BIN_PATH"/bazelisk "$GO_BIN_PATH"/b + + echo "b --version" + "$GO_BIN_PATH"/b version + echo + else + echo "Please install Go from https://go.dev/doc/install and re-run this script!" + echo "See also https://docs.enola.dev/dev/setup/" exit 255 + fi fi # Check if https://pre-commit.com is available (and try to install it not) -if ! [ -e "./.venv/bin/pre-commit" ]; then +if ! [ -e ".venv/bin/pre-commit" ]; then echo "https://pre-commit.com is not available..." if ! [ -x "$(command -v python3)" ]; then @@ -55,16 +73,16 @@ echo set +u if [ -z "$CI" ]; then echo "$ pre-commit run (locally, only changed files)" - pre-commit run + .venv/bin/pre-commit run else echo "$ pre-commit run --all-files (on CI)" - pre-commit run --all-files + .venv/bin/pre-commit run --all-files fi set -u # https://github.com/bazelbuild/bazel/issues/4257 echo $ Bazel testing... -bazelisk query //... | xargs bazel test +bazelisk query //... | xargs bazelisk test # Test distros: 1. End-user distributed executable fat über JAR, 2. Container Image tools/distro/test.bash