diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 0000000000..47b322c971 --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +3.4.1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 20f4f16576..6a59408993 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,10 +19,17 @@ jobs: architecture: 'x64' # defaults to 'x64' - name: install requirements run: sudo apt-get install ca-certificates-java expect - - name: Setup Bazel - uses: abhinavsingh/setup-bazel@v3 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 with: - version: 3.3.0 + python-version: 3.8 + - name: Set up Node + uses: actions/setup-node@v1 + with: + node-version: '12' + - name: Install dependencies + run: | + npm install --global @bazel/bazelisk - name: cache maven artifacts uses: actions/cache@v1 with: @@ -60,10 +67,17 @@ jobs: architecture: 'x64' # defaults to 'x64' - name: install requirements run: sudo apt-get install ca-certificates-java expect - - name: Setup Bazel - uses: abhinavsingh/setup-bazel@v3 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 with: - version: 3.3.0 + python-version: 3.8 + - name: Set up Node + uses: actions/setup-node@v1 + with: + node-version: '12' + - name: Install dependencies + run: | + npm install --global @bazel/bazelisk - name: cache maven artifacts uses: actions/cache@v1 with: @@ -105,10 +119,20 @@ jobs: architecture: 'x64' # defaults to 'x64' - name: install requirements run: sudo apt-get install ca-certificates-java expect - - name: Setup Bazel - uses: abhinavsingh/setup-bazel@v3 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Set up Node + uses: actions/setup-node@v1 with: - version: 3.3.0 + node-version: '12' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r docs/requirements.txt + npm install --global typedoc + npm install --global @bazel/bazelisk - name: cache maven artifacts uses: actions/cache@v1 with: @@ -150,10 +174,17 @@ jobs: architecture: 'x64' # defaults to 'x64' - name: install requirements run: sudo apt-get install ca-certificates-java expect - - name: Setup Bazel - uses: abhinavsingh/setup-bazel@v3 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Set up Node + uses: actions/setup-node@v1 with: - version: 3.3.0 + node-version: '12' + - name: Install dependencies + run: | + npm install --global @bazel/bazelisk - name: cache maven artifacts uses: actions/cache@v1 with: @@ -195,10 +226,17 @@ jobs: architecture: 'x64' # defaults to 'x64' - name: install requirements run: sudo apt-get install ca-certificates-java expect - - name: Setup Bazel - uses: abhinavsingh/setup-bazel@v3 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Set up Node + uses: actions/setup-node@v1 with: - version: 3.3.0 + node-version: '12' + - name: Install dependencies + run: | + npm install --global @bazel/bazelisk - name: cache maven artifacts uses: actions/cache@v1 with: @@ -244,6 +282,7 @@ jobs: python -m pip install --upgrade pip pip install -r docs/requirements.txt npm install --global typedoc + npm install --global @bazel/bazelisk sudo apt-get install graphviz - name: Disk Free run: | @@ -280,10 +319,6 @@ jobs: architecture: 'x64' # defaults to 'x64' - name: install requirements run: sudo apt-get install ca-certificates-java expect - - name: Setup Bazel - uses: abhinavsingh/setup-bazel@v3 - with: - version: 3.3.0 - name: Set up Python 3.8 uses: actions/setup-python@v2 with: @@ -297,6 +332,7 @@ jobs: python -m pip install --upgrade pip pip install -r docs/requirements.txt npm install --global typedoc + npm install --global @bazel/bazelisk sudo apt-get install graphviz - name: cache maven artifacts uses: actions/cache@v1 diff --git a/README.md b/README.md index 6389a63d9f..489751e6bc 100644 --- a/README.md +++ b/README.md @@ -75,10 +75,14 @@ export JAVA_HOME=`/usr/libexec/java_home -v 11` To install, follow these steps: ``` -$ brew install bazel -$ brew upgrade bazel +$ npm install -g @bazel/bazelisk ``` +This will install [bazelisk](https://github.com/bazelbuild/bazelisk) which is +a wrapper to the `bazel` binary. It will, when `bazel` is run on the command line, +automatically install the supported Bazel version, defined in the `.bazelversion` +file in the root of the `knora-api` repository. + ### For building the documentation See [docs/Readme.md](docs/Readme.md). diff --git a/WORKSPACE b/WORKSPACE index 60792c237f..4fe0edf6e3 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -178,10 +178,10 @@ go_rules_dependencies() go_register_toolchains() # -# Download the rules_docker repository at release v0.12.0 +# Download the rules_docker repository at release v0.14.4 # -rules_docker_version="0.13.0" -rules_docker_version_sha256="df13123c44b4a4ff2c2f337b906763879d94871d16411bf82dcfeba892b58607" +rules_docker_version="0.14.4" +rules_docker_version_sha256="4521794f0fba2e20f3bf15846ab5e01d5332e587e9ce81629c7f96c793bb7036" http_archive( name = "io_bazel_rules_docker", sha256 = rules_docker_version_sha256, @@ -189,22 +189,36 @@ http_archive( url = "https://github.com/bazelbuild/rules_docker/releases/download/v%s/rules_docker-v%s.tar.gz" % (rules_docker_version, rules_docker_version), ) -# load rules_docker repositories load( "@io_bazel_rules_docker//repositories:repositories.bzl", container_repositories = "repositories", ) container_repositories() -# load further dependencies of this rule load("@io_bazel_rules_docker//repositories:deps.bzl", container_deps = "deps") + container_deps() +load("@io_bazel_rules_docker//repositories:pip_repositories.bzl", "pip_deps") + +pip_deps() + # load container_pull method load( "@io_bazel_rules_docker//container:container.bzl", - "container_pull" + "container_pull", ) + +# get distroless java +container_pull( + name = "java_base", + registry = "gcr.io", + repository = "distroless/java", + # 'tag' is also supported, but digest is encouraged for reproducibility. + digest = "sha256:deadbeef", +) + +# get openjdk container_pull( name = "openjdk11", registry = "docker.io", @@ -213,6 +227,7 @@ container_pull( digest = "sha256:0e51b455654bd162c485a6a6b5b120cc82db453d9265cc90f0c4fb5d14e2f62e", ) +# get sipi load("//third_party:versions.bzl", "SIPI_REPOSITORY", "SIPI_TAG") container_pull( name = "sipi", @@ -222,6 +237,7 @@ container_pull( digest = "sha256:7b7abd324d0887f3ff46de7d7f066dd699b3acd96b94177f153f750f7572031c", ) +# get fuseki load("//third_party:versions.bzl", "FUSEKI_REPOSITORY", "FUSEKI_TAG") container_pull( name = "jenafuseki", diff --git a/docker/knora-salsah1/BUILD.bazel b/docker/knora-salsah1/BUILD.bazel index 05370cfbae..aef858bab5 100644 --- a/docker/knora-salsah1/BUILD.bazel +++ b/docker/knora-salsah1/BUILD.bazel @@ -34,7 +34,7 @@ container_push( name = "push", image = ":image", format = "Docker", - registry = "docker.io", + registry = "index.docker.io", repository = "daschswiss/knora-salsah1", tag = "{BUILD_SCM_TAG}" ) diff --git a/docs/05-internals/development/bazel.md b/docs/05-internals/development/bazel.md index 1459161406..c7f469ba36 100644 --- a/docs/05-internals/development/bazel.md +++ b/docs/05-internals/development/bazel.md @@ -4,7 +4,16 @@ The following section discusses on how to build and run tests for Knora-API with [Bazel](https://bazel.build). ## Prerequisites -To install Bazel on macOS, run `brew install bazel`. +To install the Bazel build tool, follow these steps: + +``` +$ npm install -g @bazel/bazelisk +``` + +This will install [bazelisk](https://github.com/bazelbuild/bazelisk) which is +a wrapper to the `bazel` binary. It will, when the `bazel` command ir run, +automatically install the supported Bazel version, defined in the `.bazelversion` +file in the root of the `knora-api` repository. ## Commands @@ -12,13 +21,10 @@ Build `webapi`: ``` # build webapi -$ bazel build //webapi - -# run api (webapi) -$ bazel run //:api +$ bazel build //webapi/... -# run all tests -$ bazel test //... +# run all webapi tests +$ bazel test //webapi//... ``` ## Build Structure