|
1 | 1 | name: Build and test DataSQRL Examples |
| 2 | + |
2 | 3 | on: |
3 | | - workflow_dispatch: |
4 | | - inputs: |
5 | | - repo: |
6 | | - description: Test runner |
7 | | - required: true |
8 | | - default: 'zharec' |
9 | | - type: string |
10 | | - note: |
11 | | - description: Test note |
12 | | - required: true |
13 | | - default: 'Smoke test' |
14 | | - type: string |
15 | | - example: |
16 | | - description: Example to test |
17 | | - required: true |
18 | | - type: choice |
19 | | - default: healthcare |
20 | | - options: |
21 | | - - finance |
22 | | - - healthcare |
23 | | - - logistics |
24 | | - - iot-sensor |
25 | | - - retail |
26 | | - - recommendation |
27 | | - - law |
28 | | - pull_request: |
| 4 | + push: |
| 5 | + branches: [ "main" ] |
| 6 | + pull_request: |
29 | 7 | branches: [ "main" ] |
30 | 8 |
|
31 | 9 | jobs: |
32 | 10 | build: |
33 | 11 | runs-on: ubuntu-latest |
34 | 12 | timeout-minutes: 30 |
| 13 | + |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + include: |
| 18 | + - example: finance |
| 19 | + path: finance-credit-card-chatbot |
| 20 | + test_commands: | |
| 21 | + test -c package-analytics-local.json --snapshot snapshots-analytics |
| 22 | + test -c package-rewards-local.json --snapshot snapshots-rewards |
| 23 | +
|
| 24 | + - example: healthcare |
| 25 | + path: healthcare-study-monitoring |
| 26 | + test_commands: | |
| 27 | + test -c study_analytics_package.json study_analytics.sqrl --snapshot snapshots-study-analytics |
| 28 | + test -c study_api_test_package.json --tests tests-api --snapshot snapshots-study-api |
| 29 | + test -c study_stream_local_package.json study_stream.sqrl --snapshot snapshots-study-stream |
| 30 | + compile study_create_api.sqrl |
| 31 | +
|
| 32 | + - example: logistics |
| 33 | + path: logistics-shipping-geodata |
| 34 | + test_commands: | |
| 35 | + test logistics.sqrl --snapshot snapshots |
| 36 | +
|
| 37 | + # - example: iot-sensor |
| 38 | + # path: iot-sensor-metrics |
| 39 | + # test_commands: | |
| 40 | + # test sensors.sqrl --snapshot snapshots |
| 41 | + |
| 42 | + - example: retail |
| 43 | + path: retail-customer360-nutshop |
| 44 | + test_commands: | |
| 45 | + test customer360.sqrl --snapshot snapshots |
| 46 | +
|
| 47 | + - example: recommendation |
| 48 | + path: clickstream-ai-recommendation |
| 49 | + test_commands: | |
| 50 | + test -c package.json --snapshot snapshots |
| 51 | +
|
| 52 | + - example: law |
| 53 | + path: law-enforcement |
| 54 | + test_commands: | |
| 55 | + test -c baseball-card-local.json --snapshot snapshots |
| 56 | +
|
35 | 57 | env: |
36 | 58 | TZ: 'America/Los_Angeles' |
| 59 | + SQRL_VERSION: 'v0.5.6' |
| 60 | + |
37 | 61 | steps: |
| 62 | + - uses: actions/checkout@v4 |
| 63 | + |
38 | 64 | - name: Setup Timezone |
39 | 65 | uses: szenius/set-timezone@v1.1 |
40 | 66 | with: |
41 | 67 | timezoneLinux: "America/Los_Angeles" |
42 | 68 |
|
43 | 69 | - name: Pull SQRL Docker image |
44 | | - run: docker pull datasqrl/cmd:v0.5.6 |
45 | | - |
46 | | - - name: Run Healthcare Analytics Test |
47 | | - if: ${{ github.event.inputs.example == 'healthcare' }} |
48 | | - working-directory: ./healthcare-study-monitoring |
49 | | - run: | |
50 | | - docker run -i -p 8888:8888 -p 8081:8081 --rm -v $PWD:/build -e LOCAL_WAREHOUSE_DIR=/tmp/warehouse datasqrl/cmd:v0.5.6 test -c study_analytics_package.json study_analytics.sqrl --snapshot snapshots-study-analytics |
51 | | - continue-on-error: false |
| 70 | + run: docker pull datasqrl/cmd:${{ env.SQRL_VERSION }} |
52 | 71 |
|
53 | | - - name: Run Healthcare Study Api Test |
54 | | - if: ${{ github.event.inputs.example == 'healthcare' }} |
55 | | - working-directory: ./healthcare-study-monitoring |
56 | | - run: | |
57 | | - docker run -i -p 8888:8888 -p 8081:8081 --rm -v $PWD:/build datasqrl/cmd:v0.5.6 test -c study_api_test_package.json --tests tests-api --snapshot snapshots-study-api |
58 | | - continue-on-error: false |
59 | | - |
60 | | - - name: Run Healthcare Study Stream Test |
61 | | - if: ${{ github.event.inputs.example == 'healthcare' }} |
62 | | - working-directory: ./healthcare-study-monitoring |
63 | | - run: | |
64 | | - docker run -i -p 8888:8888 -p 8081:8081 --rm -v $PWD:/build datasqrl/cmd:v0.5.6 test -c study_stream_local_package.json study_stream.sqrl --snapshot snapshots-study-stream |
65 | | - continue-on-error: false |
66 | | - |
67 | | - - name: Run Healthcare Create Api Test |
68 | | - if: ${{ github.event.inputs.example == 'healthcare' }} |
69 | | - working-directory: ./healthcare-study-monitoring |
70 | | - run: | |
71 | | - docker run -i -p 8888:8888 -p 8081:8081 --rm -v $PWD:/build datasqrl/cmd:v0.5.6 compile study_create_api.sqrl |
72 | | - continue-on-error: false |
73 | | - |
74 | | - - name: Run Finance Analytics Test |
75 | | - if: ${{ github.event.inputs.example == 'finance' }} |
76 | | - working-directory: ./finance-credit-card-chatbot |
77 | | - run: | |
78 | | - docker run -i -p 8888:8888 -p 8081:8081 --rm -v $PWD:/build datasqrl/cmd:v0.5.6 test -c package-analytics-local.json --snapshot snapshots-analytics |
79 | | - continue-on-error: false |
| 72 | + - name: Set up QEMU |
| 73 | + uses: docker/setup-qemu-action@v2 |
80 | 74 |
|
81 | | - - name: Run Finance Rewards Test |
82 | | - if: ${{ github.event.inputs.example == 'finance' }} |
83 | | - working-directory: ./finance-credit-card-chatbot |
84 | | - run: | |
85 | | - docker run -i -p 8888:8888 -p 8081:8081 --rm -v $PWD:/build datasqrl/cmd:v0.5.6 test test -c package-rewards-local.json --snapshot snapshots-rewards |
86 | | - continue-on-error: false |
| 75 | + - name: Set up Docker Buildx |
| 76 | + uses: docker/setup-buildx-action@v2 |
87 | 77 |
|
88 | | - - name: Run Clickstream Recommendation Test |
89 | | - if: ${{ github.event.inputs.example == 'recommendation' }} |
90 | | - working-directory: ./clickstream-ai-recommendation |
91 | | - run: | |
92 | | - docker run -i -p 8888:8888 -p 8081:8081 -p 9092:9092 --rm -v $PWD:/build datasqrl/cmd:v0.5.6 test test -c package.json --snapshot snapshots |
93 | | - continue-on-error: false |
| 78 | + - name: Login to Docker Hub |
| 79 | + uses: docker/login-action@v2 |
| 80 | + with: |
| 81 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 82 | + password: ${{ secrets.DOCKER_PASSWORD }} |
94 | 83 |
|
95 | | - - name: Run IoT Sensor Test |
96 | | - if: ${{ github.event.inputs.example == 'iot-sensor' }} |
97 | | - working-directory: ./iot-sensor-metrics |
98 | | - run: | |
99 | | - docker run -i -p 8888:8888 -p 8081:8081 -p 9092:9092 --rm -v $PWD:/build datasqrl/cmd:v0.5.6 test sensors.sqrl --snapshot snapshots |
100 | | - continue-on-error: false |
101 | | - |
102 | | - - name: Run Logistics Test |
103 | | - if: ${{ github.event.inputs.example == 'logistics' }} |
104 | | - working-directory: ./logistics-shipping-geodata |
| 84 | + - name: Run ${{ matrix.example }} Tests |
| 85 | + working-directory: ${{ matrix.path }} |
105 | 86 | run: | |
106 | | - docker run -i -p 8888:8888 -p 8081:8081 -p 9092:9092 --rm -v $PWD:/build datasqrl/cmd:v0.5.6 test logistics.sqrl --snapshot snapshots |
107 | | - continue-on-error: false |
| 87 | + while IFS= read -r cmd; do |
| 88 | + echo "Running: $cmd" |
| 89 | + docker run -i -p 8888:8888 -p 8081:8081 -p 9092:9092 --rm -v $PWD:/build datasqrl/cmd:${SQRL_VERSION} $cmd |
| 90 | + done <<< "${{ matrix.test_commands }}" |
108 | 91 |
|
109 | | - - name: Run Retail Test |
110 | | - if: ${{ github.event.inputs.example == 'retail' }} |
111 | | - working-directory: ./retail-customer360-nutshop |
| 92 | + - name: Write Dockerfile |
112 | 93 | run: | |
113 | | - docker run -i -p 8888:8888 -p 8081:8081 -p 9092:9092 --rm -v $PWD:/build datasqrl/cmd:v0.5.6 test customer360.sqrl --snapshot snapshots |
114 | | - continue-on-error: false |
| 94 | + cat <<EOF > ${{ matrix.path }}/Dockerfile |
| 95 | + FROM datasqrl/cmd:${SQRL_VERSION} |
115 | 96 |
|
116 | | - - name: Run Law Enforcement Test |
117 | | - if: ${{ github.event.inputs.example == 'law' }} |
118 | | - working-directory: ./law-enforcement |
119 | | - run: | |
120 | | - docker run -i -p 8888:8888 -p 8081:8081 -p 9092:9092 --rm -v $PWD:/build datasqrl/cmd:v0.5.6 test -c baseball-card-local.json --snapshot snapshots |
121 | | - continue-on-error: false |
| 97 | + ENV TZ="UTC" |
122 | 98 |
|
123 | | - - name: Run anyway |
124 | | - if: ${{ github.event.inputs.example != 'healthcare' }} |
125 | | - run: | |
126 | | - echo "This ran, I guess that is a good thing" |
127 | | - continue-on-error: true |
| 99 | + COPY . /build |
| 100 | + WORKDIR /build |
| 101 | + EOF |
128 | 102 |
|
| 103 | + - name: Publish ${{ matrix.example }} |
| 104 | + uses: docker/build-push-action@v3 |
| 105 | + with: |
| 106 | + context: ./${{ matrix.path }} |
| 107 | + file: ./${{ matrix.path }}/Dockerfile |
| 108 | + push: true |
| 109 | + tags: datasqrl/examples:${{ matrix.example }} |
| 110 | + platforms: linux/amd64,linux/arm64 |
0 commit comments