Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
Initial commit of Kafka provider (#259)
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Hoffman <[email protected]>
  • Loading branch information
autodidaddict authored Aug 8, 2023
1 parent 6a181d3 commit ace8064
Show file tree
Hide file tree
Showing 8 changed files with 3,753 additions and 0 deletions.
167 changes: 167 additions & 0 deletions .github/workflows/kafka.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
name: messaging-kafka

on:
push:
branches: [main]
paths:
- "messaging-kafka/**"
tags:
- "messaging-kafka-v*"
pull_request:
branches: [main]
paths:
- "messaging-kafka/**"

env:
CARGO_TERM_COLOR: always
working-directory: ./messaging-kafka
WASH_ISSUER_KEY: ${{ secrets.WASMCLOUD_ACCOUNT_OFFICIAL }}
WASH_SUBJECT_KEY: ${{ secrets.WASMCLOUD_MESSAGING_KAFKA }}

jobs:
rust_check:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
# If your integration tests require nats or redis, run them here
- id: rust-check-action
uses: wasmcloud/common-actions/rust-check@main
with:
working-directory: ${{ env.working-directory }}

install_cross:
if: startswith(github.ref, 'refs/tags/') # Only run on tag push
runs-on: ubuntu-20.04
steps:
- uses: wasmcloud/common-actions/install-cross@main
- name: Upload cross binary
uses: actions/upload-artifact@v3
with:
name: cross
path: ~/.cargo/bin/cross

build_artifact:
needs: install_cross
if: startswith(github.ref, 'refs/tags/') # Only run on tag push
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-apple-darwin
- aarch64-unknown-linux-gnu
- aarch64-apple-darwin
- armv7-unknown-linux-gnueabihf
- x86_64-pc-windows-gnu
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Download cross binary
uses: actions/download-artifact@v3
with:
name: cross
path: ~/.cargo/bin

- name: Determine artifact name
run: |
echo "artifact-name=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].targets[0].name')" >> $GITHUB_ENV
working-directory: ${{ env.working-directory }}

- name: Build native executable
run: |
chmod +x ~/.cargo/bin/cross
cross build --release --target ${{ matrix.target }}
working-directory: ${{ env.working-directory }}

- name: Upload executable to GH Actions
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
if-no-files-found: error
path: |
${{ env.working-directory }}/target/${{ matrix.target }}/release/${{ env.artifact-name }}
${{ env.working-directory }}/target/${{ matrix.target }}/release/${{ env.artifact-name }}.exe
assemble_provider_archive:
needs: [build_artifact]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: wasmcloud/common-actions/install-wash@main
# Downloads all artifacts
- uses: actions/download-artifact@v3
with:
path: ${{ env.working-directory }}

- name: Determine artifact name
run: |
echo "artifact-name=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].targets[0].name')" >> $GITHUB_ENV
working-directory: ${{ env.working-directory }}

- name: Create provider archive
working-directory: ${{ env.working-directory }}
run: |
mkdir -p target/release
mv x86_64-unknown-linux-gnu/${{ env.artifact-name }} target/release/
make par
- name: Insert provider archive targets
working-directory: ${{ env.working-directory }}
run: |
wash par insert --arch x86_64-macos --binary x86_64-apple-darwin/${{ env.artifact-name }} build/${{ env.artifact-name }}.par.gz
wash par insert --arch aarch64-linux --binary aarch64-unknown-linux-gnu/${{ env.artifact-name }} build/${{ env.artifact-name }}.par.gz
wash par insert --arch aarch64-macos --binary aarch64-apple-darwin/${{ env.artifact-name }} build/${{ env.artifact-name }}.par.gz
wash par insert --arch armv7-linux --binary armv7-unknown-linux-gnueabihf/${{ env.artifact-name }} build/${{ env.artifact-name }}.par.gz
wash par insert --arch x86_64-windows --binary x86_64-pc-windows-gnu/${{ env.artifact-name }}.exe build/${{ env.artifact-name }}.par.gz
- name: Upload provider archive to GH Actions
uses: actions/upload-artifact@v2
with:
name: provider-archive
path: ${{ env.working-directory }}/build/${{ env.artifact-name }}.par.gz

github_release:
if: startswith(github.ref, 'refs/tags/') # Only run on tag push
needs: [rust_check, assemble_provider_archive]
runs-on: ubuntu-20.04
steps:
- name: Download provider archive
uses: actions/download-artifact@v3
with:
name: provider-archive
path: ${{ env.working-directory }}/build

- name: Release
uses: softprops/action-gh-release@v1
with:
files: ${{ env.working-directory }}/build/*.par.gz
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: true
draft: false

artifact_release:
needs: [rust_check, assemble_provider_archive]
if: startswith(github.ref, 'refs/tags/') # Only run on tag push
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Download provider archive
uses: actions/download-artifact@v3
with:
name: provider-archive
path: ${{ env.working-directory }}/build

- name: Determine artifact metadata
run: |
echo "oci-repository=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].name' | sed 's/wasmcloud-provider-//')" >> $GITHUB_ENV
echo "oci-version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[].version')" >> $GITHUB_ENV
working-directory: ${{ env.working-directory }}

- name: Push provider archive to AzureCR
uses: wasmcloud/common-actions/oci-artifact-release@main
with:
artifact-path: ${{ env.working-directory }}/build/${{ env.oci-repository }}.par.gz
oci-url: ${{ secrets.AZURECR_PUSH_URL }}
oci-repository: ${{ env.oci-repository }}
oci-version: ${{ env.oci-version }}
oci-username: ${{ secrets.AZURECR_PUSH_USER }}
oci-password: ${{ secrets.AZURECR_PUSH_PASSWORD }}
2 changes: 2 additions & 0 deletions messaging-kafka/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build
/target
Loading

0 comments on commit ace8064

Please sign in to comment.