Skip to content

Commit 0c3b21a

Browse files
author
Mandy Chen
committed
Added github action tests
1 parent 63a19b4 commit 0c3b21a

File tree

14 files changed

+354
-3
lines changed

14 files changed

+354
-3
lines changed

.buildkite/pipeline.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,5 @@ steps:
118118
- docker-compose#v3.0.0:
119119
run: unit-test-docker-sticky-off
120120
config: docker/buildkite/docker-compose.yaml
121+
122+
# TODO: delete this file after migration to github actions

.buildkite/scripts/coverage_metadata.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ set -ex
88
output_path="$1"
99
echo "commit-sha: $(git rev-parse HEAD)" > "$output_path"
1010
echo "timestamp: $(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$output_path"
11-
echo "Coverage metadata written to $output_path"
11+
echo "Coverage metadata written to $output_path"
12+
13+
# TODO: delete this file after migration to github actions

.buildkite/scripts/lint.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ if [ -n "$(git status --porcelain)" ]; then
99
echo "Please rerun the command and commit the changes"
1010
git status --porcelain
1111
exit 1
12-
fi
12+
fi
13+
14+
# TODO: delete this file after migration to github actions

.github/scripts/coverage_metadata.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
set -ex
3+
# This script generates coverage metadata for the coverage report.
4+
# Output is used by SonarQube integration in Uber and not used by OS repo coverage tool itself.
5+
# Example output:
6+
# commit-sha: 6953daa563e8e44512bc349c9608484cfd4ec4ff
7+
# timestamp: 2024-03-04T19:29:16Z
8+
output_path="$1"
9+
echo "commit-sha: $(git rev-parse HEAD)" > "$output_path"
10+
echo "timestamp: $(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$output_path"
11+
echo "Coverage metadata written to $output_path"

.github/scripts/lint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
./gradlew goJF
6+
7+
if [ -n "$(git status --porcelain)" ]; then
8+
echo "There are changes after linting (used goJF) cmd: ./gradlew goJF"
9+
echo "Please rerun the command and commit the changes"
10+
git status --porcelain
11+
exit 1
12+
fi

.github/workflows/ci-checks.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: CI Checks
2+
on:
3+
push:
4+
pull_request:
5+
6+
jobs:
7+
lint-check:
8+
name: Lint Check
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
with:
15+
submodules: true
16+
fetch-depth: 0 # get full history for branch checking
17+
18+
- name: Run lint check
19+
run: docker compose -f docker/github_actions/docker-compose.yml run unit-test-test-service bash -c ".github/scripts/lint.sh"
20+
21+
unit-test-with-test-service:
22+
name: Unit Test with Test Service
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
submodules: true
30+
fetch-depth: 0 # get full history for branch checking
31+
32+
- name: Run unit test with test service
33+
uses: nick-fields/retry@v3
34+
with:
35+
max_attempts: 3
36+
timeout_minutes: 30
37+
command: |
38+
docker compose -f docker/github_actions/docker-compose.yml run unit-test-test-service bash -c "./gradlew --no-daemon test jacocoTestReport && .github/scripts/coverage_metadata.sh build/reports/metadata.txt"
39+
40+
- name: Upload coverage artifacts
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: unit-test-with-test-service-coverage
44+
path: |
45+
build/reports/tests/test/**/*
46+
build/reports/jacoco/test/jacocoTestReport.xml
47+
build/reports/metadata.txt
48+
include-hidden-files: true
49+
50+
unit-test-with-docker-service-sticky-on:
51+
name: Unit Test with Docker Service (Sticky On)
52+
runs-on: ubuntu-latest
53+
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v4
57+
with:
58+
submodules: true
59+
fetch-depth: 0 # get full history for branch checking
60+
61+
- name: Run unit test with docker service (sticky on)
62+
uses: nick-fields/retry@v3
63+
with:
64+
max_attempts: 3
65+
timeout_minutes: 50
66+
command: |
67+
docker compose -f docker/github_actions/docker-compose.yml run unit-test-docker-sticky-on bash -c "./gradlew --no-daemon test"
68+
69+
- name: Upload coverage artifacts
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: unit-test-with-docker-service-sticky-on-coverage
73+
path: |
74+
build/reports/tests/test/**/*
75+
include-hidden-files: true
76+
77+
unit-test-with-docker-service-sticky-off:
78+
name: Unit Test with Docker Service (Sticky Off)
79+
runs-on: ubuntu-latest
80+
81+
steps:
82+
- name: Checkout
83+
uses: actions/checkout@v4
84+
with:
85+
submodules: true
86+
fetch-depth: 0 # get full history for branch checking
87+
88+
- name: Run unit test with docker service (sticky off)
89+
uses: nick-fields/retry@v3
90+
with:
91+
max_attempts: 3
92+
timeout_minutes: 50
93+
command: |
94+
docker compose -f docker/github_actions/docker-compose.yml run unit-test-docker-sticky-off bash -c "./gradlew --no-daemon test"
95+
96+
- name: Upload coverage artifacts
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: unit-test-with-docker-service-sticky-off-coverage
100+
path: |
101+
build/reports/tests/test/**/*
102+
include-hidden-files: true

.github/workflows/codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
with:
1010
submodules: 'true'
1111
- name: Install dependencies, run tests, and collect coverage
12-
run: docker compose -f docker/buildkite/docker-compose.yaml run unit-test-test-service
12+
run: docker compose -f docker/github_actions/docker-compose.yaml run unit-test-test-service
1313
- name: Upload coverage to Codecov
1414
uses: codecov/codecov-action@v4
1515
env:

docker-compose.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
services:
2+
cassandra:
3+
image: cassandra:4.1.1
4+
ports:
5+
- "9042:9042"
6+
environment:
7+
- "MAX_HEAP_SIZE=256M"
8+
- "HEAP_NEWSIZE=128M"
9+
healthcheck:
10+
test: ["CMD", "cqlsh", "-u cassandra", "-p cassandra" ,"-e describe keyspaces"]
11+
interval: 15s
12+
timeout: 30s
13+
retries: 10
14+
prometheus:
15+
image: prom/prometheus:latest
16+
volumes:
17+
- ./prometheus:/etc/prometheus
18+
command:
19+
- '--config.file=/etc/prometheus/prometheus.yml'
20+
ports:
21+
- '9090:9090'
22+
node-exporter:
23+
image: prom/node-exporter
24+
ports:
25+
- '9100:9100'
26+
cadence:
27+
image: ubercadence/server:master-auto-setup
28+
ports:
29+
- "8000:8000"
30+
- "8001:8001"
31+
- "8002:8002"
32+
- "8003:8003"
33+
- "7933:7933"
34+
- "7934:7934"
35+
- "7935:7935"
36+
- "7939:7939"
37+
- "7833:7833"
38+
- "7936:7936"
39+
environment:
40+
- "CASSANDRA_SEEDS=cassandra"
41+
- "PROMETHEUS_ENDPOINT_0=0.0.0.0:8000"
42+
- "PROMETHEUS_ENDPOINT_1=0.0.0.0:8001"
43+
- "PROMETHEUS_ENDPOINT_2=0.0.0.0:8002"
44+
- "PROMETHEUS_ENDPOINT_3=0.0.0.0:8003"
45+
- "DYNAMIC_CONFIG_FILE_PATH=config/dynamicconfig/development.yaml"
46+
- "FRONTEND_PPROF_PORT=7936"
47+
- "LOG_LEVEL=debug"
48+
depends_on:
49+
cassandra:
50+
condition: service_healthy
51+
prometheus:
52+
condition: service_started
53+
cadence-web:
54+
image: ubercadence/web:latest
55+
environment:
56+
- "CADENCE_GRPC_PEERS=cadence:7833"
57+
ports:
58+
- "8088:8088"
59+
depends_on:
60+
- cadence
61+
grafana:
62+
image: grafana/grafana
63+
volumes:
64+
- ./grafana:/etc/grafana
65+
user: "1000"
66+
depends_on:
67+
- prometheus
68+
ports:
69+
- '3000:3000'

docker/buildkite/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ RUN apk del build-dependencies wget && rm -rf /var/cache/apk/*
3333

3434
RUN mkdir /cadence-java-client
3535
WORKDIR /cadence-java-client
36+
37+
# TODO: delete this file after migration to github actions

docker/buildkite/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ And finally make sure to shutdown all docker resources:
1919
```bash
2020
docker-compose down
2121
```
22+
TODO: delete this file after migration to github actions

0 commit comments

Comments
 (0)