Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature (IDE): Support & document GitHub Codespaces! #354

Merged
merged 5 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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,
},
}
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"recommendations": [
"redhat.java",
"sfdc.bazel-vscode-java",
"bazelbuild.vscode-bazel",
"josevseb.google-java-format-for-vs-code",
Expand Down
7 changes: 4 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}

Expand All @@ -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");
}
}
35 changes: 24 additions & 11 deletions docs/dev/ide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://vscode.dev>
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)

Expand Down Expand Up @@ -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 <https://vscode.dev>
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:
Expand All @@ -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`.
Expand Down
30 changes: 24 additions & 6 deletions test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down