Skip to content

Commit

Permalink
Merge branch 'master' of github.com:oracle/opengrok into lucene-9.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tarzanek committed Oct 23, 2024
2 parents 160984e + 785896c commit 08d62e7
Show file tree
Hide file tree
Showing 78 changed files with 1,610 additions and 785 deletions.
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ jobs:
- name: Install Universal ctags (Windows)
if: runner.os == 'Windows'
run: choco install universal-ctags
- name: Before build actions (Unix)
if: runner.os == 'Linux' || runner.os == 'macOS'
- name: Before build actions
shell: bash
run: ./dev/before
- name: Maven build
shell: bash
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
name: Build Docker image

on: [push, pull_request]
on:
push:
pull_request:
release:
types: [created]

jobs:
ubuntu:
runs-on: ubuntu-latest
steps:
- name: Print environment
shell: bash
run: env
- name: Checkout master branch
uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -31,15 +38,13 @@ jobs:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
OPENGROK_REPO_SLUG: ${{ github.repository }}
OPENGROK_PULL_REQUEST: ${{ github.head_ref }}
OPENGROK_REF: ${{ github.ref }}
run: ./dev/docker.sh
- name: Install Python pre-requisites
run: python3 -m pip install requests
- name: Optionally update README on Docker hub
env:
OPENGROK_REPO_SLUG: ${{ github.repository }}
OPENGROK_PULL_REQUEST: ${{ github.head_ref }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: ./dev/dockerhub_readme.py
20 changes: 7 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ name: Release

# TODO: run this only for the oracle/opengrok repository
on:
push:
tags:
- '[1-9]+.[0-9]+.[0-9]+'
release:
types: [created]

jobs:
get_tag:
Expand Down Expand Up @@ -48,23 +47,18 @@ jobs:
run: ./dev/before
- name: Build
run: ./mvnw -DskipTests=true -Dmaven.javadoc.skip=false -B -V package
- name: Create Release
id: create_release
uses: actions/create-release@v1
- name: Get upload URL
id: get_upload_url
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
OPENGROK_TAG: ${{ needs.get_tag.outputs.tag }}
run: dev/get_upload_url.sh
- name: Upload release tarball
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
upload_url: ${{ steps.get_upload_url.outputs.upload_url }}
asset_path: ./distribution/target/opengrok-${{ needs.get_tag.outputs.tag }}.tar.gz
asset_name: opengrok-${{ needs.get_tag.outputs.tag }}.tar.gz
asset_content_type: application/octet-stream
18 changes: 9 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ RUN cp `ls -t distribution/target/*.tar.gz | head -1` /opengrok.tar.gz
# Store the version in a file so that the tools can report it.
RUN /mvn/mvnw help:evaluate -Dexpression=project.version -q -DforceStdout > /mvn/VERSION

FROM tomcat:10.1.19-jdk17
FROM tomcat:10.1.30-jdk17
LABEL maintainer="https://github.com/oracle/opengrok"
LABEL org.opencontainers.image.source="https://github.com/oracle/opengrok"
LABEL org.opencontainers.image.description="OpenGrok code search"

# Add Perforce apt source.
# hadolint ignore=DL3008,DL3009
Expand All @@ -64,11 +66,11 @@ RUN apt-get update && \
# hadolint ignore=DL3008,DL3059
RUN architecture=$(uname -m) && if [[ "$architecture" == "aarch64" ]]; then \
echo "aarch64: do not install helix-p4d."; else \
apt-get install --no-install-recommends -y helix-p4d; fi
apt-get install --no-install-recommends -y helix-p4d || echo "Failed to install Perforce"; fi

# compile and install universal-ctags
# hadolint ignore=DL3003,DL3008
RUN apt-get install --no-install-recommends -y pkg-config automake build-essential && \
RUN apt-get install --no-install-recommends -y pkg-config automake build-essential libxml2-dev && \
git clone https://github.com/universal-ctags/ctags /root/ctags && \
cd /root/ctags && ./autogen.sh && ./configure && make && make install && \
apt-get remove -y automake build-essential && \
Expand All @@ -77,19 +79,17 @@ RUN apt-get install --no-install-recommends -y pkg-config automake build-essenti
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Update the Python tooling in order to successfully install the opengrok-tools package.
# hadolint ignore=DL3013
RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools

# prepare OpenGrok binaries and directories
# hadolint ignore=DL3010
COPY --from=build opengrok.tar.gz /opengrok.tar.gz
# hadolint ignore=DL3013
RUN mkdir -p /opengrok /opengrok/etc /opengrok/data /opengrok/src && \
tar -zxvf /opengrok.tar.gz -C /opengrok --strip-components 1 && \
rm -f /opengrok.tar.gz && \
python3 -m pip install --no-cache-dir /opengrok/tools/opengrok-tools.tar.gz && \
python3 -m pip install --no-cache-dir Flask Flask-HTTPAuth waitress # for /reindex REST endpoint handled by start.py
python3 -m venv /venv
ENV PATH=/venv/bin:$PATH
RUN /venv/bin/python3 -m pip install --no-cache-dir /opengrok/tools/opengrok-tools.tar.gz && \
/venv/bin/python3 -m pip install --no-cache-dir Flask Flask-HTTPAuth waitress # for /reindex REST endpoint handled by start.py

COPY --from=build /mvn/VERSION /opengrok/VERSION

Expand Down
15 changes: 0 additions & 15 deletions dev/before_install
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ if [[ "$RUNNER_OS" == "Linux" ]]; then
# Bitkeeper install failure is not critical, so exit code is not checked.
sudo ./dev/install-bitkeeper.sh

sudo -H ./dev/install-python-packages.sh
if [[ $? != 0 ]]; then
echo "cannot install Python packages"
exit 1
fi

sudo ./dev/install-universal_ctags.sh
if [[ $? != 0 ]]; then
echo "cannot install Universal ctags"
Expand All @@ -49,15 +43,6 @@ elif [[ "$RUNNER_OS" == "macOS" ]]; then
exit 1
fi

brew install python3
brew upgrade python

./dev/install-python-packages.sh
if [[ $? != 0 ]]; then
echo "cannot install Python packages"
exit 1
fi

sudo ./dev/install-universal_ctags.sh
if [[ $? != 0 ]]; then
echo "cannot install Universal ctags"
Expand Down
6 changes: 3 additions & 3 deletions dev/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ docker run -d $IMAGE
docker ps -a

# This can only work on home repository since it needs encrypted variables.
if [[ -n "$OPENGROK_PULL_REQUEST" ]]; then
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
echo "Not pushing Docker image for pull requests"
exit 0
fi
Expand All @@ -75,12 +75,12 @@ fi

if [[ -z $DOCKER_USERNAME ]]; then
echo "DOCKER_USERNAME is empty, exiting"
exit 0
exit 1
fi

if [[ -z $DOCKER_PASSWORD ]]; then
echo "DOCKER_PASSWORD is empty, exiting"
exit 0
exit 1
fi

# Publish the image to Docker hub.
Expand Down
4 changes: 2 additions & 2 deletions dev/dockerhub_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def check_push_env():
logger.info("Not updating Docker hub README for non main repo")
sys.exit(0)

pull_request = os.environ.get("OPENGROK_PULL_REQUEST")
if pull_request and len(pull_request) > 0:
event_type = os.environ.get("GITHUB_EVENT_NAME")
if event_type and event_type == "pull_request":
logger.info("Not updating Docker hub README for pull requests")
sys.exit(0)

Expand Down
14 changes: 14 additions & 0 deletions dev/get_upload_url.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
#
# The purpose of this script is to retrieve upload URL for OpenGrok release given by the tag
# stored in the OPENGROK_TAG environment variable.
# The value is stored in a special file consumed by Github action so that it can be used
# to upload assets to the related OpenGrok release on Github.
#

echo "Getting upload URL for $OPENGROK_TAG"
upload_url=$( curl -s https://api.github.com/repos/oracle/opengrok/releases/tags/$OPENGROK_TAG | jq -r .upload_url )
echo "Got '$upload_url'"
if [[ -n $GITHUB_OUTPUT ]]; then
echo "upload_url=$upload_url" >> $GITHUB_OUTPUT
fi
2 changes: 1 addition & 1 deletion dev/ref2tag.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

tag=${OPENGROK_REF#"refs/tags/"}
echo "::set-output name=tag::$tag"
echo "tag=$tag" >> $GITHUB_OUTPUT
13 changes: 8 additions & 5 deletions dev/release.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
#
# Trigger new release creation on Github.
# Assumes working Maven + Git.
#
# Query current release or trigger new release creation on Github.
# For the latter, it merely kick-starts the creation of new Release on Github,
# see https://github.com/oracle/opengrok/wiki/Release-process
#
# Assumes working Maven + Git.
#

set -e

Expand Down Expand Up @@ -43,8 +44,10 @@ if [[ $ver == $VERSION ]]; then
fi

git pull --ff-only
git switch -c "release_${VERSION}"
./mvnw versions:set -DgenerateBackupPoms=false "-DnewVersion=$VERSION"
git commit pom.xml '**/pom.xml' -m "$VERSION"
git push
git tag "$VERSION"
git push origin tag "$VERSION"
echo
echo "Create PR with the changes. Once it is merged in, create new release."
echo
8 changes: 4 additions & 4 deletions distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.opengrok</groupId>
<artifactId>opengrok-top</artifactId>
<version>1.13.7</version>
<version>1.13.23</version>
</parent>

<artifactId>opengrok-dist</artifactId>
Expand All @@ -28,20 +28,20 @@
<dependency>
<groupId>org.opengrok</groupId>
<artifactId>opengrok</artifactId>
<version>1.13.7</version>
<version>1.13.23</version>
</dependency>

<dependency>
<groupId>org.opengrok</groupId>
<artifactId>opengrok-web</artifactId>
<version>1.13.7</version>
<version>1.13.23</version>
<type>war</type>
</dependency>

<dependency>
<groupId>org.opengrok</groupId>
<artifactId>tools</artifactId>
<version>1.13.7</version>
<version>1.13.23</version>
<type>pom</type>
</dependency>
</dependencies>
Expand Down
3 changes: 2 additions & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ The image contains these directories:
| ----------------------- | ------------- | ----------- |
`SYNC_PERIOD_MINUTES` | 10 | Period of automatic synchronization (i.e. mirroring + reindexing) in minutes. Setting to `0` will disable periodic syncing (the sync after container startup will still be done).
`INDEXER_OPT` | empty | pass **extra** options to OpenGrok Indexer. For example, `-i d:vendor` will remove all the `*/vendor/*` files from the index. You can check the indexer options on https://github.com/oracle/opengrok/wiki/Python-scripts-transition-guide. The default set of indexer options is: `--remote on -P -H -W`. Do not add `-R` as it is used internally. Rather, see below for the `READONLY_CONFIG_FILE` environment variable.
`INDEXER_JAVA_OPTS` | empty | pass **extra** Java options to OpenGrok Indexer.
`NOMIRROR` | empty | To avoid the mirroring step, set the variable to non-empty value.
`URL_ROOT` | `/` | Override the sub-URL that OpenGrok should run on.
`WORKERS` | number of CPUs in the container | number of workers to use for syncing (applies only to setup with projects enabled)
Expand Down Expand Up @@ -168,7 +169,7 @@ If you want to do your own development, you can build the image yourself:

git clone https://github.com/oracle/opengrok.git
cd opengrok
docker build -t opengrok-dev .
docker buildx build -t opengrok-dev .

Then run the container:

Expand Down
32 changes: 29 additions & 3 deletions docker/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ def indexer_no_projects(logger, uri, config_path, extra_indexer_options):
Project less indexer
"""

indexer_java_opts = os.environ.get("INDEXER_JAVA_OPTS")
if indexer_java_opts:
indexer_java_opts = indexer_java_opts.split()

wait_for_tomcat(logger, uri)

while True:
Expand All @@ -347,7 +351,11 @@ def indexer_no_projects(logger, uri, config_path, extra_indexer_options):
)
indexer_options.extend(extra_indexer_options.split())
indexer = Indexer(
indexer_options, logger=logger, jar=OPENGROK_JAR, doprint=True
indexer_options,
java_opts=indexer_java_opts,
logger=logger,
jar=OPENGROK_JAR,
doprint=True,
)
indexer.execute()

Expand Down Expand Up @@ -421,6 +429,10 @@ def create_bare_config(logger, use_projects, extra_indexer_options=None):
Create bare configuration file with a few basic settings.
"""

indexer_java_opts = os.environ.get("INDEXER_JAVA_OPTS")
if indexer_java_opts:
indexer_java_opts = indexer_java_opts.split()

logger.info("Creating bare configuration in {}".format(OPENGROK_CONFIG_FILE))
indexer_options = [
"-s",
Expand All @@ -444,7 +456,13 @@ def create_bare_config(logger, use_projects, extra_indexer_options=None):
indexer_options.extend(extra_indexer_options)
if use_projects:
indexer_options.append("-P")
indexer = Indexer(indexer_options, jar=OPENGROK_JAR, logger=logger, doprint=True)
indexer = Indexer(
indexer_options,
java_opts=indexer_java_opts,
jar=OPENGROK_JAR,
logger=logger,
doprint=True,
)
indexer.execute()
ret = indexer.getretcode()
if ret != SUCCESS_EXITVAL:
Expand Down Expand Up @@ -473,12 +491,20 @@ def check_index_and_wipe_out(logger):
currently running version and the CHECK_INDEX environment variable
is non-empty, wipe out the directories under data root.
"""
indexer_java_opts = os.environ.get("INDEXER_JAVA_OPTS")
if indexer_java_opts:
indexer_java_opts = indexer_java_opts.split()

check_index = os.environ.get("CHECK_INDEX")
if check_index and os.path.exists(OPENGROK_CONFIG_FILE):
logger.info("Checking if index matches current version")
indexer_options = ["-R", OPENGROK_CONFIG_FILE, "--checkIndex", "version"]
indexer = Indexer(
indexer_options, logger=logger, jar=OPENGROK_JAR, doprint=True
indexer_options,
java_opts=indexer_java_opts,
logger=logger,
jar=OPENGROK_JAR,
doprint=True,
)
indexer.execute()
if indexer.getretcode() == 1:
Expand Down
Loading

0 comments on commit 08d62e7

Please sign in to comment.