build #357
Workflow file for this run
This file contains hidden or 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: build | |
| on: | |
| push: | |
| tags: | |
| - '*' | |
| jobs: | |
| deploy_to_github: | |
| if: ${{ github.event.repository.private == true }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: coursier/cache-action@v6 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 21 | |
| distribution: 'temurin' | |
| - name: Install sbt | |
| uses: sbt/setup-sbt@v1 | |
| - name: Install Thrift | |
| uses: awalsh128/cache-apt-pkgs-action@latest | |
| with: | |
| packages: libthrift-java thrift-compiler | |
| version: 1.0 | |
| - name: Build artifacts | |
| run: | | |
| sbt 'project kafka' assembly | |
| sbt 'project kinesis' assembly | |
| sbt 'project nsq' assembly | |
| sbt 'project pubsub' assembly | |
| sbt 'project sqs' assembly | |
| sbt 'project stdout' assembly | |
| - name: Get current version | |
| id: ver | |
| run: | | |
| export PROJECT_VERSION=$(sbt "project core" version -Dsbt.log.noformat=true | perl -ne 'print "$1\n" if /info.*(\d+\.\d+\.\d+[^\r\n]*)/' | tail -n 1 | tr -d '\n') | |
| echo "project_version=$PROJECT_VERSION" >> $GITHUB_OUTPUT | |
| - name: Create GitHub release and attach artifacts | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| draft: true | |
| prerelease: true | |
| name: ${{ steps.ver.outputs.project_version }} | |
| tag_name: ${{ steps.ver.outputs.project_version }} | |
| files: | | |
| kafka/target/scala-2.13/snowplow-stream-collector-kafka-${{ steps.ver.outputs.project_version }}.jar | |
| kinesis/target/scala-2.13/snowplow-stream-collector-kinesis-${{ steps.ver.outputs.project_version }}.jar | |
| nsq/target/scala-2.13/snowplow-stream-collector-nsq-${{ steps.ver.outputs.project_version }}.jar | |
| pubsub/target/scala-2.13/snowplow-stream-collector-google-pubsub-${{ steps.ver.outputs.project_version }}.jar | |
| sqs/target/scala-2.13/snowplow-stream-collector-sqs-${{ steps.ver.outputs.project_version }}.jar | |
| stdout/target/scala-2.13/snowplow-stream-collector-stdout-${{ steps.ver.outputs.project_version }}.jar | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| deploy_to_docker: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| platform: | |
| - kinesis | |
| - sqs | |
| - pubsub | |
| - kafka | |
| - nsq | |
| - stdout | |
| include: | |
| - visibility_suffix: ${{ github.event.repository.private == true && '-private' || '' }} | |
| - platform: kinesis | |
| run_snyk: ${{ !contains(github.ref, 'rc') }} | |
| - platform: pubsub | |
| run_snyk: ${{ !contains(github.ref, 'rc') }} | |
| - platform: kafka | |
| run_snyk: ${{ !contains(github.ref, 'rc') }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: coursier/cache-action@v6 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 21 | |
| distribution: 'temurin' | |
| - name: Install sbt | |
| uses: sbt/setup-sbt@v1 | |
| - name: Install Thrift | |
| uses: awalsh128/cache-apt-pkgs-action@latest | |
| with: | |
| packages: libthrift-java thrift-compiler | |
| version: 1.0 | |
| - name: Get current version | |
| id: ver | |
| run: | | |
| export PROJECT_VERSION=$(sbt "project core" version -Dsbt.log.noformat=true | perl -ne 'print "$1\n" if /info.*(\d+\.\d+\.\d+[^\r\n]*)/' | tail -n 1 | tr -d '\n') | |
| echo "project_version=$PROJECT_VERSION" >> $GITHUB_OUTPUT | |
| - name: Stage the Docker build | |
| run: sbt "project ${{ matrix.platform }}" docker:stage | |
| - name: Stage the Docker distroless build | |
| run: sbt "project ${{ matrix.platform }}Distroless" docker:stage | |
| - name: Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v3 | |
| with: | |
| images: snowplow/scala-stream-collector-${{ matrix.platform }}${{ matrix.visibility_suffix }} | |
| tags: | | |
| type=raw,value=latest,enable=${{ !contains(steps.ver.outputs.project_version, 'rc') }} | |
| type=raw,value=latest-focal,enable=${{ !contains(steps.ver.outputs.project_version, 'rc') }} | |
| type=raw,value=${{ steps.ver.outputs.project_version }} | |
| type=raw,value=${{ steps.ver.outputs.project_version }}-focal | |
| flavor: | | |
| latest=false | |
| - name: Docker metadata distroless | |
| id: distroless-meta | |
| uses: docker/metadata-action@v3 | |
| with: | |
| images: snowplow/scala-stream-collector-${{ matrix.platform }}${{ matrix.visibility_suffix }} | |
| tags: | | |
| type=raw,value=latest-distroless,enable=${{ !contains(steps.ver.outputs.project_version, 'rc') }} | |
| type=raw,value=${{ steps.ver.outputs.project_version }}-distroless | |
| flavor: | | |
| latest=false | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v1 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v1 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v1 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Push image | |
| uses: docker/build-push-action@v2 | |
| with: | |
| context: ${{ matrix.platform }}/target/docker/stage | |
| file: ${{ matrix.platform }}/target/docker/stage/Dockerfile | |
| platforms: linux/amd64,linux/arm64/v8 | |
| tags: ${{ steps.meta.outputs.tags }} | |
| push: true | |
| - name: Push distroless image | |
| uses: docker/build-push-action@v2 | |
| with: | |
| context: distroless/${{ matrix.platform }}/target/docker/stage | |
| file: distroless/${{ matrix.platform }}/target/docker/stage/Dockerfile | |
| platforms: linux/amd64,linux/arm64/v8 | |
| tags: ${{ steps.distroless-meta.outputs.tags }} | |
| push: true | |
| - name: Build local distroless image, which is needed to run Snyk | |
| if: matrix.run_snyk | |
| run: sbt "project ${{ matrix.platform }}Distroless" docker:publishLocal | |
| - name: Show local docker images | |
| run: docker images | |
| - name: Run Snyk to check for vulnerabilities | |
| uses: snyk/actions/docker@master | |
| if: matrix.run_snyk | |
| with: | |
| image: "snowplow/scala-stream-collector-${{ matrix.platform }}${{ matrix.visibility_suffix }}:${{ github.ref_name }}-distroless" | |
| args: "--app-vulns --org=data-processing-new" | |
| command: monitor | |
| env: | |
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | |
| snowman-tests: | |
| if: ${{ github.event.repository.private == false }} # Excluded private repo runs because Snowman cannot access private DockerHub repo yet | |
| name: Run Snowman Tests | |
| runs-on: ubuntu-latest | |
| needs: deploy_to_docker | |
| strategy: | |
| matrix: | |
| component: | |
| - collector | |
| test_directory: | |
| - stream_collector | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get version from tag | |
| id: ver | |
| run: | | |
| if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
| VERSION="${GITHUB_REF#refs/tags/}" | |
| echo "Using tag version: $VERSION" | |
| echo "project_version=$VERSION" >> "$GITHUB_ENV" | |
| echo "project_version=$VERSION" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "❌ No tag found. This job expects to run on a tag." | |
| exit 1 | |
| fi | |
| - name: Run Snowman QA Tests | |
| uses: the-actions-org/workflow-dispatch@v4 | |
| with: | |
| workflow: Trigger Snowman Tests | |
| repo: snowplow-devops/snowman | |
| ref: refs/heads/main | |
| token: ${{ secrets.GLOBAL_QA_FRAMEWORK_PAT }} | |
| inputs: >- | |
| { | |
| "test_directory": "${{ matrix.test_directory }}", | |
| "component": "${{ matrix.component }}", | |
| "dry_run": false, | |
| "version": "${{ steps.ver.outputs.project_version }}", | |
| "token": "${{ secrets.GLOBAL_QA_FRAMEWORK_PAT }}" | |
| } | |
| wait-for-completion: true | |
| wait-for-completion-timeout: 240m | |
| display-workflow-run-url: true |