-
Notifications
You must be signed in to change notification settings - Fork 2
130 lines (117 loc) · 4.52 KB
/
Copy pathpresubmit.yml
File metadata and controls
130 lines (117 loc) · 4.52 KB
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: presubmit
run-name: Presubmit run triggered by ${{ github.actor }}
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
bazel-build-test:
name: Bazel Telemetry Checks
runs-on: ubuntu-latest
# Define environment variables from secrets at the job level
env:
POSTGRES_USER: ${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
ELECTRIC_PWD: ${{ secrets.ELECTRIC_PWD }}
GRAFANA_PWD: ${{ secrets.GRAFANA_PWD }}
ANALYSIS_PWD: ${{ secrets.ANALYSIS_PWD }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Get Bazel
uses: bazel-contrib/setup-bazel@0.8.1
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}
# Share repository cache between workflows.
repository-cache: true
# Docker setup for integration tests
- name: Create Docker network and volumes
run: |
docker network create telemetry_network || true
docker volume create grafana_storage || true
docker volume create telemetry_db || true
docker volume create kafka_data || true
- name: Create .env file for Docker
run: |
cat > telemtry/.env << EOF
POSTGRES_USER=${{ secrets.POSTGRES_USER }}
POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}
ELECTRIC_PWD=${{ secrets.ELECTRIC_PWD }}
GRAFANA_PWD=${{ secrets.GRAFANA_PWD }}
ANALYSIS_PWD=${{ secrets.ANALYSIS_PWD }}
EOF
- name: Start Kafka services
working-directory: telemtry/stack/kafka
run: docker compose up -d --build --wait
- name: Start Ingest services
working-directory: telemtry/stack/ingest
run: docker compose up -d --build --wait
- name: Wait for services to be healthy
run: |
echo "Waiting for services to be ready..."
sleep 10
docker ps
- name: Run Integration Tests
run: |
bazel test //telemtry/... \
--test_output=errors \
--config=ci \
--remote_header=x-buildbuddy-api-key=${{ secrets.BUILD_BUDDY_API_KEY }} \
--test_tag_filters=integration \
--test_env=POSTGRES_USER \
--test_env=POSTGRES_PASSWORD \
--test_env=ELECTRIC_PWD \
--test_env=GRAFANA_PWD \
--test_env=ANALYSIS_PWD
- name: Teardown Docker services
if: always()
run: |
cd telemtry/stack/ingest && docker compose down -v --remove-orphans || true
cd telemtry/stack/kafka && docker compose down -v --remove-orphans || true
docker network rm telemetry_network || true
rm -f telemtry/.env || true
check-runner:
runs-on: ubuntu-latest
outputs:
runner-label: ${{ steps.set-runner.outputs.runner-label }}
steps:
- name: Set runner
id: set-runner
run: |
runners=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ secrets.REPO_ACCESS_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/runners")
available=$(echo "$runners" | jq '.runners[] | select(.status == "online" and .busy == false and .labels[] .name == "self-hosted")')
if [ -n "$available" ]; then
echo "runner-label=self-hosted" >> $GITHUB_OUTPUT
else
echo "runner-label=ubuntu-latest" >> $GITHUB_OUTPUT
fi
bazel-firmware-checks:
name: Bazel Firmware Checks
needs: check-runner
runs-on: ${{ needs.check-runner.outputs.runner-label }}
permissions:
actions: read
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Bazel
uses: bazel-contrib/setup-bazel@0.8.1
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
- name: Build All
run: bazel build //... --build_tag_filters=stm32_firmware --config=ci --remote_header=x-buildbuddy-api-key=${{secrets.BUILD_BUDDY_API_KEY}}
- name: Run Unit Tests (no Docker required)
run: |
bazel test //... \
--config=ci \
--remote_header=x-buildbuddy-api-key=${{ secrets.BUILD_BUDDY_API_KEY }} \
--test_output=errors \
--test_tag_filters=-integration,-docker,-requirements