VisualQuery: Aggregations in having #1261
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Grok Connect | |
on: | |
workflow_dispatch: { } | |
push: | |
paths: | |
- 'connectors/**' | |
pull_request: | |
paths: | |
- 'connectors/**' | |
jobs: | |
common-check: | |
name: Common checks | |
uses: ./.github/workflows/common_check.yaml | |
with: | |
run_trigger: ${{ github.event_name }} | |
build: | |
name: Build maven | |
needs: common-check | |
runs-on: ubuntu-latest-m | |
if: needs.common-check.outputs.continue == 'true' | |
permissions: | |
checks: write | |
outputs: | |
version: ${{ steps.get_version.outputs.version }} | |
image_exists: ${{ steps.get_version.outputs.image_exists }} | |
latest: ${{ steps.get_version.outputs.latest }} | |
steps: | |
- name: Set TimeZone | |
uses: szenius/[email protected] | |
with: | |
timezoneLinux: "Europe/Kyiv" | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
sparse-checkout: | | |
./connectors | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '8' | |
distribution: 'adopt' | |
cache: maven | |
- name: Build with Maven | |
working-directory: ./connectors | |
run: mvn --batch-mode -DskipTests package | |
- name: Test | |
working-directory: ./connectors | |
run: mvn -DtestFailureIgnore=true test | |
- name: Test Report | |
uses: dorny/test-reporter@v1 | |
if: success() || failure() | |
with: | |
name: Maven Tests | |
path: /home/runner/work/public/public/connectors/grok_connect/target/surefire-reports/*.xml | |
reporter: java-junit | |
fail-on-error: false | |
- name: Get version | |
id: get_version | |
working-directory: ./connectors | |
run: | | |
current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
echo "version=${current_version}" >> $GITHUB_OUTPUT | |
token=$(curl -sSL "https://auth.docker.io/token?service=registry.docker.io&scope=repository:datagrok/grok_connect:pull" | jq --raw-output .token) | |
image_status=$(curl -LIs -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${token}" "https://registry.hub.docker.com/v2/datagrok/grok_connect/manifests/${current_version}") | |
echo "${image_status}" | |
if [[ "${image_status}" == "404" ]] ; then | |
echo "image_exists=false" >> $GITHUB_OUTPUT | |
else | |
echo "image_exists=true" >> $GITHUB_OUTPUT | |
fi | |
latest_pushed=$(curl --retry 5 -LsS "https://registry.hub.docker.com/v2/repositories/datagrok/grok_connect/tags?page_size=20" | jq -r '[.results[] | select(.name | test("[0-9]+\\.[0-9]+\\.[0-9]+"))] | sort_by(.tag_last_pushed) | reverse[0].name') | |
newest_version=$(echo -e "$latest_pushed\n$current_version" | sort -V | tail -n1) | |
if [[ "${newest_version}" == "${current_version}" ]] ; then | |
echo "latest=true" >> $GITHUB_OUTPUT | |
else | |
echo "latest=false" >> $GITHUB_OUTPUT | |
fi | |
docker: | |
name: Build Docker | |
needs: [ build, common-check ] | |
runs-on: ubuntu-22.04 | |
if: needs.common-check.outputs.continue == 'true' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
sparse-checkout: | | |
./connectors | |
./.github | |
- uses: docker/setup-qemu-action@v2 | |
- uses: docker/setup-buildx-action@v2 | |
- uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set buildx parameters | |
id: param | |
run: | | |
commit_sha=$(echo ${{ github.sha }} | cut -c1-8) | |
branch=$(echo ${GITHUB_REF#refs/heads/}) | |
echo "commit_sha=${commit_sha}" >> $GITHUB_OUTPUT | |
echo "branch=${branch}" >> $GITHUB_OUTPUT | |
if [[ ${{ needs.build.outputs.image_exists }} == 'true' ]]; then | |
platform='linux/amd64' | |
echo "platform=${platform}" >> $GITHUB_OUTPUT | |
tar="grok_connect_${{ needs.build.outputs.version }}-$(echo ${platform#linux/})-${commit_sha}-${{ github.run_id }}-${{ github.run_attempt }}.tar" | |
echo "tar=${tar}" >> $GITHUB_OUTPUT | |
echo "dest=type=docker,dest=/tmp/${tar}" >> $GITHUB_OUTPUT | |
echo "tags=datagrok/grok_connect:${{ needs.build.outputs.version }}-${commit_sha}" >> $GITHUB_OUTPUT | |
else | |
echo "platform=linux/amd64" >> $GITHUB_OUTPUT | |
if [[ ${{ needs.build.outputs.latest }} == 'true' ]]; then | |
echo "cache_to=type=registry,ref=datagrok/grok_connect:cache,mode=max" >> $GITHUB_OUTPUT | |
echo "tags=datagrok/grok_connect:latest,datagrok/grok_connect:${{ needs.build.outputs.version }}" >> $GITHUB_OUTPUT | |
else | |
echo "tags=datagrok/grok_connect:${{ needs.build.outputs.version }}" >> $GITHUB_OUTPUT | |
fi | |
fi | |
- uses: hadolint/[email protected] | |
with: | |
dockerfile: ./connectors/Dockerfile | |
failure-threshold: error | |
- name: Build and push | |
uses: docker/build-push-action@v3 | |
id: build-push | |
with: | |
context: ./connectors | |
platforms: ${{ steps.param.outputs.platform }} | |
push: ${{ (needs.build.outputs.image_exists == 'false') && (github.ref == 'refs/heads/master' || startsWith(github.ref,'refs/heads/release/') == true) }} | |
tags: ${{ steps.param.outputs.tags }} | |
cache-from: type=registry,ref=datagrok/grok_connect:cache | |
cache-to: ${{ steps.param.outputs.cache_to }} | |
outputs: ${{ steps.param.outputs.dest }} | |
build-args: | | |
BRANCH=${{ steps.param.outputs.branch }} | |
COMMIT_PUBLIC=${{ github.sha }} | |
labels: | | |
BRANCH=${{ steps.param.outputs.branch }} | |
COMMIT_PUBLIC=${{ github.sha }} | |
- name: Build and push bleeding-edge | |
if: github.ref == 'refs/heads/master' | |
id: bleeding-edge | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./connectors | |
platforms: ${{ steps.param.outputs.platform }} | |
push: true | |
tags: "datagrok/grok_connect:bleeding-edge" | |
cache-from: type=registry,ref=datagrok/grok_connect:cache | |
cache-to: ${{ steps.param.outputs.cache_to }} | |
build-args: | | |
BRANCH=${{ steps.param.outputs.branch }} | |
COMMIT_PUBLIC=${{ github.sha }} | |
labels: | | |
BRANCH=${{ steps.param.outputs.branch }} | |
COMMIT_PUBLIC=${{ github.sha }} | |
- name: Upload Artifact | |
if: github.ref != 'refs/heads/master' && startsWith(github.ref,'refs/heads/release/') != true | |
id: docker-artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.param.outputs.tar }} | |
path: /tmp/${{ steps.param.outputs.tar }} | |
retention-days: 7 | |
- name: Get actors slack | |
id: actor | |
uses: ./.github/actions/slack-user-action | |
with: | |
slack-token: ${{ secrets.SLACKBOT_TOKEN }} | |
email-mapping: ${{ secrets.EMAIL_SLACK_ID }} | |
- name: Get owners slack | |
id: owner | |
uses: ./.github/actions/slack-user-action | |
with: | |
slack-token: ${{ secrets.SLACKBOT_TOKEN }} | |
emails: "[email protected]" | |
- name: Prepare Slack Message | |
id: slack-prepare | |
if: steps.docker-artifact.outcome == 'skipped' && (steps.build-push.outcome == 'success' || steps.bleeding-edge.outcome == 'success') | |
shell: bash | |
run: | | |
if [[ "${{ steps.bleeding-edge.outcome == 'success' }}" == "true" ]]; then | |
header="*Grok Connect* Docker Image version *bleeding-edge* is published to Docker Hub" | |
echo SLACK_CHANNEL=${{ steps.actor.outputs.user-ids }} >> $GITHUB_ENV | |
else | |
mentions=$(echo -e "${{ steps.actor.outputs.user-ids }}\n${{ steps.owner.outputs.user-ids }}" | sort -u) | |
header="*Grok Connect* Docker Image version *${{ needs.build.outputs.version }}* is published to Docker Hub.\n$(for value in $mentions; do echo -n "<@$value> "; done) FYI" | |
echo SLACK_CHANNEL='#build' >> $GITHUB_ENV | |
fi | |
echo "SLACK_MESSAGE_HEADER=$header" >> $GITHUB_ENV | |
- name: Send to Slack | |
id: slack | |
if: steps.slack-prepare.outcome == 'success' | |
uses: ./.github/actions/slack-post-action | |
with: | |
channel: ${{ env.SLACK_CHANNEL }} | |
slack-token: ${{ secrets.SLACKBOT_TOKEN }} | |
message: ${{ env.SLACK_MESSAGE_HEADER }} |