-
Notifications
You must be signed in to change notification settings - Fork 3
113 lines (106 loc) · 4.91 KB
/
deploy-changed-samples.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
name: Deploy Changed Samples
on:
pull_request:
paths:
- 'samples/**'
permissions:
contents: read
id-token: write
jobs:
deploy_changed_samples:
runs-on: ubuntu-latest
concurrency:
group: deploy_samples-group
environment: deploy-changed-samples
timeout-minutes: 90
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Identify changed samples
run: |
git fetch origin main
LAST_ANCESTOR=$(git merge-base HEAD origin/main)
git diff --name-only HEAD $LAST_ANCESTOR \
| grep '^samples/' \
| awk -F'/' '{print $1"/"$2}' \
| sort \
| uniq > changed_samples.txt
if [ -s changed_samples.txt ]; then
echo "should_continue=true" >> $GITHUB_ENV
echo "The following samples have changed:"
cat changed_samples.txt
else
echo "should_continue=false" >> $GITHUB_ENV
echo "No samples have changed. Exiting..."
fi
- name: Install Golang
uses: actions/setup-go@v5
with:
go-version-file: tools/testing/go.mod
cache-dependency-path: |
tools/testing/go.sum
if: env.should_continue == 'true'
- name: Build the test tool using Go
run: |
go mod tidy
go build ./cmd/loadtest
working-directory: tools/testing/
if: env.should_continue == 'true'
- name: Install Defang
run: |
eval "$(curl -fsSL s.defang.io/install)"
if: env.should_continue == 'true'
- name: Run tests
id: run-tests
shell: bash # implies set -o pipefail, so pipe below will keep the exit code from loadtest
if: env.should_continue == 'true'
env:
FIXED_VERIFIER_PK: ${{ secrets.FIXED_VERIFIER_PK }}
TEST_AWS_ACCESS_KEY: ${{ secrets.TEST_AWS_ACCESS_KEY }}
TEST_AWS_SECRET_KEY: ${{ secrets.TEST_AWS_SECRET_KEY }}
TEST_BOARD_PASSWORD: ${{ secrets.TEST_BOARD_PASSWORD }}
TEST_DATABASE_HOST: ${{ secrets.TEST_DATABASE_HOST }}
TEST_DATABASE_NAME: ${{ secrets.TEST_DATABASE_NAME }}
TEST_DATABASE_PASSWORD: ${{ secrets.TEST_DATABASE_PASSWORD }}
TEST_DATABASE_URL: ${{ secrets.TEST_DATABASE_URL }}
TEST_DATABASE_USERNAME: ${{ secrets.TEST_DATABASE_USERNAME }}
TEST_HASURA_GRAPHQL_ADMIN_SECRET: ${{ secrets.TEST_HASURA_GRAPHQL_ADMIN_SECRET }}
TEST_HASURA_GRAPHQL_DATABASE_URL: ${{ secrets.TEST_HASURA_GRAPHQL_DATABASE_URL }}
TEST_HF_TOKEN: ${{ secrets.TEST_HF_TOKEN }}
TEST_MB_DB_DBNAME: ${{ secrets.TEST_MB_DB_DBNAME }}
TEST_MB_DB_HOST: ${{ secrets.TEST_MB_DB_HOST }}
TEST_MB_DB_PASS: ${{ secrets.TEST_MB_DB_PASS }}
TEST_MB_DB_PORT: ${{ secrets.TEST_MB_DB_PORT }}
TEST_MB_DB_USER: ${{ secrets.TEST_MB_DB_USER }}
TEST_MONGO_INITDB_ROOT_USERNAME: ${{ secrets.TEST_MONGO_INITDB_ROOT_USERNAME }}
TEST_MONGO_INITDB_ROOT_PASSWORD: ${{ secrets.TEST_MONGO_INITDB_ROOT_PASSWORD }}
TEST_NC_DB: ${{ secrets.TEST_NC_DB }}
TEST_NC_S3_ENDPOINT: ${{ secrets.TEST_NC_S3_ENDPOINT }}
TEST_NC_S3_BUCKET_NAME: ${{ secrets.TEST_NC_S3_BUCKET_NAME }}
TEST_NC_S3_REGION: ${{ secrets.TEST_NC_S3_REGION }}
TEST_NC_S3_ACCESS_KEY: ${{ secrets.TEST_NC_S3_ACCESS_KEY }}
TEST_NC_S3_ACCESS_SECRET: ${{ secrets.TEST_NC_S3_ACCESS_SECRET }}
TEST_OPENAI_KEY: ${{ secrets.TEST_OPENAI_KEY }}
TEST_POSTGRES_PASSWORD: ${{ secrets.TEST_POSTGRES_PASSWORD }}
TEST_QUEUE: ${{ secrets.TEST_QUEUE }}
TEST_SECRET_KEY: ${{ secrets.TEST_SECRET_KEY }}
TEST_SECRET_KEY_BASE: ${{ secrets.TEST_SECRET_KEY_BASE }}
TEST_SESSION_SECRET: ${{ secrets.TEST_SESSION_SECRET }}
TEST_SLACK_CHANNEL_ID: ${{ secrets.TEST_SLACK_CHANNEL_ID }}
TEST_SLACK_TOKEN: ${{ secrets.TEST_SLACK_TOKEN }}
run: |
SAMPLES=$(sed 's|^samples/||' changed_samples.txt | paste -s -d ',' -)
echo "Running tests for samples: $SAMPLES"
mkdir output
# concurrency is set to 10 to avoid exhausting our fargate vCPU limits when running
# kaniko builds, which consume 4 vCPUs each. the limit is currently set to 60--6.5 of
# which are used to run the staging stack. So floor((60-6.5)/4) = 13 is our upper limit
./tools/testing/loadtest -c fabric-staging.defang.dev:443 --timeout=15m --concurrency=10 -s $SAMPLES -o output --markdown=true | tee output/summary.log | grep -v '^\s*[-*]' # removes load sample log lines
- name: Upload Output as Artifact
uses: actions/upload-artifact@v4
if: env.should_continue == 'true' && (success() || steps.run-tests.outcome == 'failure') # Always upload result unless cancelled
with:
name: program-output
path: output/**