|
1 | 1 | #!/bin/bash |
2 | 2 | set -euo pipefail |
3 | 3 |
|
| 4 | +# Uploads Pact contract files generated by running consumer Pact tests |
| 5 | +# These files should be downloaded by the provider for use in provider tests |
| 6 | + |
4 | 7 | script_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; |
5 | 8 |
|
6 | | -consumer_dirs=("consumer" "consumer-2") |
7 | | -pact_dir="pacts" |
| 9 | +consumer_service_dirs=("auth" "core") |
| 10 | +consumer_pact_dir="consumer/pacts" |
8 | 11 |
|
9 | | -VERSION_TAG=${PACT_VERSION:-$(git rev-parse --abbrev-ref HEAD)} |
| 12 | +for consumer in "${consumer_service_dirs[@]}"; do |
| 13 | + source="${script_path}/../tests/${consumer}/${consumer_pact_dir}" |
10 | 14 |
|
11 | | -for consumer in "${consumer_dirs[@]}"; do |
12 | | - consumer_pact_dir=$(realpath "${script_path}/../${consumer}/${pact_dir}") |
| 15 | + if [ -d "${source}" ]; then |
| 16 | + source_dir=$(realpath "${source}") |
13 | 17 |
|
14 | | - echo "Looking for pact files in $consumer_pact_dir..." |
| 18 | + echo "Looking for pact files in $source_dir..." |
15 | 19 |
|
16 | | - for file in "$consumer_pact_dir"/*.json; do |
17 | | - if [[ -f "$file" ]]; then |
18 | | - # Extract consumer and provider names from filename |
19 | | - filename=$(basename "$file") |
20 | | - provider=$(cat $file | jq -r ".provider.name") |
| 20 | + for file in "$source_dir"/*.json; do |
| 21 | + if [[ -f "$file" ]]; then |
| 22 | + filename=$(basename "$file") |
| 23 | + provider=$(cat $file | jq -r ".provider.name") |
21 | 24 |
|
22 | | - # Define S3 target path |
23 | | - targetPath="pacts/$provider/$filename" |
| 25 | + targetPath="pacts/$provider/$filename" |
24 | 26 |
|
25 | | - echo "Uploading to s3://$PACT_BUCKET/$targetPath" |
26 | | - # aws s3 cp "$file" "s3://$PACT_BUCKET/$targetPath" --acl bucket-owner-full-control |
27 | | - fi |
28 | | - done |
| 27 | + aws s3 cp "$file" "s3://$PACT_BUCKET/$targetPath" |
| 28 | + fi |
| 29 | + done |
| 30 | + fi |
29 | 31 | done |
30 | 32 |
|
31 | 33 | echo "All Pact files uploaded successfully." |
0 commit comments