Skip to content
Open
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
211 changes: 211 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
name: CI

on:
push:
branches:
- master
tags:
- '*'
pull_request:
branches:
- master

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up JDK 8
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
cache: 'maven'

- name: Build with Maven
run: mvn clean install -Dgpg.skip -Dmaven.javadoc.skip=true -B -V

- name: Upload build artifacts
if: success()
uses: actions/upload-artifact@v4
with:
name: haystack-agent-jar
path: bundlers/haystack-agent/target/haystack-agent-*.jar
retention-days: 7

deploy:
name: Deploy to Maven Central and Docker Hub
runs-on: ubuntu-latest
needs: build
# Only deploy on master branch (non-PR) or on tags
if: |
(github.ref == 'refs/heads/master' && github.event_name == 'push') ||
startsWith(github.ref, 'refs/tags/')

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up JDK 8
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
cache: 'maven'

- name: Import GPG key
if: env.GPG_SECRET_KEYS != ''
env:
GPG_SECRET_KEYS: ${{ secrets.GPG_SECRET_KEYS }}
GPG_OWNERTRUST: ${{ secrets.GPG_OWNERTRUST }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
if [ ! -z "$GPG_SECRET_KEYS" ]; then
echo "$GPG_SECRET_KEYS" | base64 --decode | gpg --batch --import
fi
if [ ! -z "$GPG_OWNERTRUST" ]; then
echo "$GPG_OWNERTRUST" | base64 --decode | gpg --batch --import-ownertrust
fi

- name: Create Maven settings.xml
run: |
mkdir -p ~/.m2
cat > ~/.m2/settings.xml << 'EOF'
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>ossrh</id>
<username>${env.SONATYPE_USERNAME}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
</servers>
<profiles>
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
</properties>
</profile>
</profiles>
</settings>
EOF

- name: Determine version and GPG settings
id: version
run: |
if [ ! -z "${{ github.ref_name }}" ] && [[ "${{ github.ref }}" == refs/tags/* ]]; then
# This is a tag release
VERSION=${{ github.ref_name }}
echo "AGENT_JAR_VERSION=$VERSION" >> $GITHUB_ENV
echo "SKIP_GPG_SIGN=false" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Travis tag is set -> updating pom.xml <version> attribute to $VERSION"
mvn org.codehaus.mojo:versions-maven-plugin:2.1:set -DnewVersion=$VERSION -q
else
# This is a snapshot build
VERSION=$(cat pom.xml | sed -n -e 's/.*<version>\(.*\)<\/version>.*/\1/p' | head -1)
echo "AGENT_JAR_VERSION=$VERSION" >> $GITHUB_ENV
echo "SKIP_GPG_SIGN=true" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "No tag set, hence keeping the snapshot version in pom.xml: $VERSION"
fi

- name: Deploy to Maven Central
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
if [ -z "$SONATYPE_USERNAME" ]; then
echo "ERROR! Please set SONATYPE_USERNAME secret"
exit 1
fi
if [ -z "$SONATYPE_PASSWORD" ]; then
echo "ERROR! Please set SONATYPE_PASSWORD secret"
exit 1
fi

mvn clean deploy -Dgpg.skip=$SKIP_GPG_SIGN -DskipTests=true -B -U
echo "Successfully deployed the jars to Nexus"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Prepare Docker build
run: |
cp bundlers/haystack-agent/target/haystack-agent-${AGENT_JAR_VERSION}.jar bundlers/haystack-agent/target/haystack-agent.jar

- name: Extract Docker metadata
id: meta
run: |
DOCKER_ORG=expediadotcom
DOCKER_IMAGE_NAME=haystack-agent
VERSION=${{ env.AGENT_JAR_VERSION }}

echo "DOCKER_ORG=$DOCKER_ORG" >> $GITHUB_ENV
echo "DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME" >> $GITHUB_ENV
echo "QUALIFIED_IMAGE=$DOCKER_ORG/$DOCKER_IMAGE_NAME" >> $GITHUB_ENV

# Determine tags based on version
TAGS=""
if [[ $VERSION =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
# Release version - create multiple tags
MAJOR="${BASH_REMATCH[1]}"
MINOR="${BASH_REMATCH[2]}"
PATCH="${BASH_REMATCH[3]}"

TAGS="$DOCKER_ORG/$DOCKER_IMAGE_NAME:$MAJOR"
TAGS="$TAGS,$DOCKER_ORG/$DOCKER_IMAGE_NAME:$MAJOR.$MINOR"
TAGS="$TAGS,$DOCKER_ORG/$DOCKER_IMAGE_NAME:$MAJOR.$MINOR.$PATCH"
TAGS="$TAGS,$DOCKER_ORG/$DOCKER_IMAGE_NAME:latest"
echo "Pushing released version to Docker Hub with tags: $TAGS"
else
# Snapshot version
TAGS="$DOCKER_ORG/$DOCKER_IMAGE_NAME:$VERSION"
echo "Pushing snapshot version to Docker Hub with tag: $TAGS"
fi

echo "tags=$TAGS" >> $GITHUB_OUTPUT

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max

notify:
name: Send notifications
runs-on: ubuntu-latest
needs: [build, deploy]
if: failure() && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))

steps:
- name: Notify on failure
run: |
echo "Build or deployment failed. In Travis CI, this would send email to haystack-notifications@expedia.com"
echo "Consider setting up GitHub Actions email notifications or Slack webhooks."
2 changes: 1 addition & 1 deletion agent-dispatchers/kinesis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<artifactId>haystack-agent-kinesis-dispatcher</artifactId>

<properties>
<aws.kinesis.producer.lib.version>0.14.0</aws.kinesis.producer.lib.version>
<aws.kinesis.producer.lib.version>0.15.12</aws.kinesis.producer.lib.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.typesafe.config.Config;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
Expand Down Expand Up @@ -194,7 +195,7 @@ public void onFailure(final Throwable throwable) {
formatAttempts(result.getAttempts()), e);
}
}
});
}, MoreExecutors.directExecutor());
}

private String formatAttempts(final List<Attempt> attempts) {
Expand Down
10 changes: 10 additions & 0 deletions agent-providers/span/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<relativePath>../../pom.xml</relativePath>
</parent>

<properties>
<okhttp.version>2.7.5</okhttp.version>
</properties>

<dependencies>
<dependency>
<groupId>com.expedia.www</groupId>
Expand All @@ -33,6 +37,12 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
11 changes: 9 additions & 2 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
<groupId>io.grpc</groupId>
<artifactId>grpc-services</artifactId>
</dependency>

<!-- javax.annotation for Java 9+ compatibility -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -60,7 +67,7 @@
<goal>run</goal>
</goals>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.0.0</protocArtifact>
<protocArtifact>com.google.protobuf:protoc:${protobuf.version}</protocArtifact>
<includeDirectories>
<include>${project.basedir}/../haystack-idl/proto</include>
<include>${project.basedir}/../haystack-idl/proto/api</include>
Expand All @@ -75,7 +82,7 @@
</outputTarget>
<outputTarget>
<type>grpc-java</type>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.0.1</pluginArtifact>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.68.2</pluginArtifact>
</outputTarget>
</outputTargets>
</configuration>
Expand Down
12 changes: 12 additions & 0 deletions bundlers/haystack-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,23 @@
<groupId>com.expedia.www</groupId>
<artifactId>blobs-agent-dispatchers</artifactId>
<version>${blobs.version}</version>
<exclusions>
<exclusion>
<groupId>com.expedia.www</groupId>
<artifactId>haystack-agent-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.expedia.www</groupId>
<artifactId>blobs-agent-server</artifactId>
<version>${blobs.version}</version>
<exclusions>
<exclusion>
<groupId>com.expedia.www</groupId>
<artifactId>haystack-agent-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- grpc -->
<dependency>
Expand Down
Loading