-
Notifications
You must be signed in to change notification settings - Fork 4
130 lines (123 loc) · 5.18 KB
/
examples-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Test Examples
on:
push:
branches: ["**"] # https://stackoverflow.com/a/64635612/14658879
jobs:
build-release:
# we cannot assume that pushes by humans to prs are recompiled, so to save ci cycles, we only
# run these tests on pushes to prs by elebot (which we know are recompiled). we also test on
# all pushes to main, since we know that the content is recompiled there as well.
if: (github.ref != 'refs/heads/main' && github.actor == 'ecoscope-elebot') || (github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install pixi
run: curl -fsSL https://pixi.sh/install.sh | bash && echo "$HOME/.pixi/bin" >> $GITHUB_PATH
- name: Build release
run: pixi run --manifest-path pixi.toml build-release
- name: Upload conda channel
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: |
/tmp/ecoscope-workflows/release/artifacts/
!/tmp/ecoscope-workflows/release/artifacts/bld
!/tmp/ecoscope-workflows/release/artifacts/src_cache
if-no-files-found: error
compression-level: 0
check-all-recompiled:
# we trust elebot, but having broken examples is a big deal, so we run this additional check
# before running the tests on the examples. this is to ensure that the examples are recompiled.
needs: build-release
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
example: [
"events",
"patrols",
"subject-tracking",
]
steps:
- uses: actions/checkout@v4
- name: Download conda channel
uses: actions/download-artifact@v4
with:
name: release-artifacts
path: /tmp/ecoscope-workflows/release/artifacts
- name: Log conda channel contents
run: ls -lR /tmp/ecoscope-workflows/release/artifacts
- name: Install pixi
run: curl -fsSL https://pixi.sh/install.sh | bash && echo "$HOME/.pixi/bin" >> $GITHUB_PATH
- name: Check all recompiled
run: |
pixi run -e compile \
python3 dev/check-all-recompiled.py examples/${{ matrix.example }}/spec.yaml \
examples/${{ matrix.example }}/ecoscope-workflows-${{ matrix.example }}-workflow
test-examples-params:
needs: check-all-recompiled # only run if all examples recompiles are up to date
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
example: [
"events",
"patrols",
"subject-tracking",
]
steps:
- uses: actions/checkout@v4
- name: Download conda channel
uses: actions/download-artifact@v4
with:
name: release-artifacts
path: /tmp/ecoscope-workflows/release/artifacts
- name: Log conda channel contents
run: ls -lR /tmp/ecoscope-workflows/release/artifacts
- name: Install pixi
run: curl -fsSL https://pixi.sh/install.sh | bash && echo "$HOME/.pixi/bin" >> $GITHUB_PATH
- name: Test
run: pixi run --manifest-path pixi.toml -e default pytest-${{ matrix.example }}-params
test-examples-run:
needs: check-all-recompiled # only run if all examples recompiles are up to date
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
example: ["events", "patrols", "subject-tracking"]
deployment: ["local", "docker"]
api: ["app", "cli"]
execution-mode: ["async", "sequential"]
exclude:
# at this point, the docker container we are building runs the app only (not the cli)
# if we want to build a version of the container that runs the cli at a later point,
# we can do that, but for now, we are only testing the app in the container
- deployment: "docker"
api: "cli"
steps:
- uses: actions/checkout@v4
- name: Download conda channel
uses: actions/download-artifact@v4
with:
name: release-artifacts
path: /tmp/ecoscope-workflows/release/artifacts
- name: Log conda channel contents
run: ls -lR /tmp/ecoscope-workflows/release/artifacts
- name: Install pixi
run: curl -fsSL https://pixi.sh/install.sh | bash && echo "$HOME/.pixi/bin" >> $GITHUB_PATH
# 'local' deployment test -------------------------------------------------------------------
- name: Test
if: matrix.deployment == 'local'
run: pixi run --manifest-path pixi.toml -e default pytest-${{ matrix.example }}-${{ matrix.api }} ${{ matrix.execution-mode }}
# 'docker' deployment test ------------------------------------------------------------------
- name: Docker build + run
if: matrix.deployment == 'docker'
run: |
pixi run --manifest-path pixi.toml docker-build-${{ matrix.example }}
pixi run --manifest-path pixi.toml docker-run-${{ matrix.example }}
sleep 5
docker ps
docker logs ${{ matrix.example }}
- name: Invoke container with curl
if: matrix.deployment == 'docker'
run: pixi run --manifest-path pixi.toml curl-invoke-${{ matrix.example }} ${{ matrix.execution-mode }}