|
| 1 | +name: Build and test DataSQRL Examples |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main" ] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +jobs: |
| 9 | + build-v5: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + timeout-minutes: 30 |
| 12 | + |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + include: |
| 17 | + - example: retail |
| 18 | + path: retail-customer360-nutshop |
| 19 | + test_commands: | |
| 20 | + test customer360.sqrl --snapshot snapshots |
| 21 | +
|
| 22 | + - example: recommendation |
| 23 | + path: clickstream-ai-recommendation |
| 24 | + test_commands: | |
| 25 | + test -c package.json --snapshot snapshots |
| 26 | +
|
| 27 | + env: |
| 28 | + TZ: 'America/Los_Angeles' |
| 29 | + SQRL_VERSION: 'v0.5.10' |
| 30 | + |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Setup Timezone |
| 35 | + uses: szenius/set-timezone@v1.1 |
| 36 | + with: |
| 37 | + timezoneLinux: "America/Los_Angeles" |
| 38 | + |
| 39 | + - name: Pull SQRL Docker image |
| 40 | + run: docker pull datasqrl/cmd:${{ env.SQRL_VERSION }} |
| 41 | + |
| 42 | + - name: Set up QEMU |
| 43 | + uses: docker/setup-qemu-action@v2 |
| 44 | + |
| 45 | + - name: Set up Docker Buildx |
| 46 | + uses: docker/setup-buildx-action@v2 |
| 47 | + |
| 48 | + - name: Login to Docker Hub |
| 49 | + uses: docker/login-action@v2 |
| 50 | + with: |
| 51 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 52 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 53 | + |
| 54 | + - name: Run ${{ matrix.example }} Tests |
| 55 | + working-directory: ${{ matrix.path }} |
| 56 | + run: | |
| 57 | + if [ -z "${{ matrix.test_commands }}" ]; then |
| 58 | + echo "No test commands specified for ${{ matrix.example }}" |
| 59 | + exit 1 |
| 60 | + fi |
| 61 | +
|
| 62 | + while IFS= read -r cmd; do |
| 63 | + echo "Running: $cmd" |
| 64 | + docker run -i -p 8888:8888 -p 8081:8081 -p 9092:9092 --rm -v $PWD:/build datasqrl/cmd:${SQRL_VERSION} $cmd |
| 65 | + done <<< "${{ matrix.test_commands }}" |
| 66 | +
|
| 67 | + - name: Write Dockerfile |
| 68 | + run: | |
| 69 | + cat <<EOF > ${{ matrix.path }}/Dockerfile |
| 70 | + FROM datasqrl/cmd:${SQRL_VERSION} |
| 71 | +
|
| 72 | + ENV TZ="UTC" |
| 73 | +
|
| 74 | + COPY . /build |
| 75 | + WORKDIR /build |
| 76 | + EOF |
| 77 | +
|
| 78 | + - name: Publish ${{ matrix.example }} |
| 79 | + uses: docker/build-push-action@v3 |
| 80 | + with: |
| 81 | + context: ./${{ matrix.path }} |
| 82 | + file: ./${{ matrix.path }}/Dockerfile |
| 83 | + push: true |
| 84 | + tags: datasqrl/examples:${{ matrix.example }} |
| 85 | + platforms: linux/amd64,linux/arm64 |
0 commit comments