@@ -12,51 +12,74 @@ jobs:
12
12
steps :
13
13
- name : Checkout code
14
14
uses : actions/checkout@v3
15
+ with :
16
+ fetch-depth : 0 # Fetch all history for all branches and tags
17
+ ref : ${{ github.head_ref }} # Ensure PR's head is checked out
15
18
- name : Get changed directories
16
19
id : set_changed
17
20
run : |
18
21
echo "::group::Determining Changed Directories"
19
- # List specific directories you want to check
20
22
DIRECTORIES="auth-mailchimp-sync delete-user-data firestore-bigquery-export firestore-counter firestore-send-email firestore-shorten-urls-bitly firestore-translate-text rtdb-limit-child-nodes storage-resize-images"
21
23
22
- # Initialize an empty string to hold the paths of changed directories
23
- CHANGED_EXTENSIONS=""
24
+ # Set commit SHAs for comparison
25
+ BASE_SHA=${{ github.event.pull_request.base.sha }}
26
+ HEAD_SHA=${{ github.event.pull_request.head.sha }}
27
+
28
+ # Initialize an empty JSON array
29
+ CHANGED_EXTENSIONS_JSON="["
24
30
25
- # Loop through each directory and check if there have been any changes
31
+ if ! git diff --name-only $BASE_SHA $HEAD_SHA > /dev/null 2>&1; then
32
+ echo "Error detecting changes using PR base and head SHAs, falling back to default branch comparison."
33
+ git fetch --no-tags --depth=1 origin +refs/heads/next:refs/remotes/origin/next
34
+ BASE_SHA=$(git rev-parse origin/next)
35
+ fi
36
+
37
+ first_entry=true
26
38
for dir in $DIRECTORIES; do
27
- if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -q "^extensions/$dir/"; then
28
- CHANGED_EXTENSIONS+="$dir "
39
+ if git diff --name-only $BASE_SHA $HEAD_SHA | grep -q "^$dir/"; then
40
+ if [ "$first_entry" = true ]; then
41
+ first_entry=false
42
+ else
43
+ CHANGED_EXTENSIONS_JSON+=", "
44
+ fi
45
+ CHANGED_EXTENSIONS_JSON+="\"$dir\""
29
46
fi
30
47
done
31
48
32
- # Trim any trailing whitespace and print the output
33
- CHANGED_EXTENSIONS=$(echo $CHANGED_EXTENSIONS | xargs)
34
- echo "Changed extensions: $CHANGED_EXTENSIONS"
49
+ CHANGED_EXTENSIONS_JSON+="]"
50
+
51
+ # Output the JSON array to the workflow
52
+ echo "changed_extensions=$CHANGED_EXTENSIONS_JSON" >> $GITHUB_OUTPUT
53
+ echo "Changed extensions: $CHANGED_EXTENSIONS_JSON"
35
54
echo "::endgroup::"
36
- echo "::set-output name=changed_extensions::$CHANGED_EXTENSIONS"
37
55
38
56
test_extensions :
39
57
needs : check_changes
40
58
runs-on : ubuntu-latest
41
59
strategy :
60
+ fail-fast : false
42
61
matrix :
43
62
extension :
44
63
${{ fromJson(needs.check_changes.outputs.changed_extensions) }}
45
- defaults :
46
- run :
47
- working-directory : extensions/${{ matrix.extension }}/functions
48
64
steps :
49
- - name : Checkout code
50
- uses : actions/checkout@v3
51
- - name : Setup node
52
- uses : actions/setup-node@v3
65
+ - uses : actions/checkout@v3
66
+ - uses : actions/setup-node@v3
53
67
with :
54
68
node-version : " 18"
55
69
cache : " npm"
56
70
cache-dependency-path : " **/package-lock.json"
57
- - name : Install dependencies
58
- run : npm install
59
- - name : Build
60
- run : npm run build
61
- - name : Run tests
62
- run : npm test
71
+ - name : Install Firebase CLI
72
+ uses : nick-invision/retry@v1
73
+ with :
74
+ timeout_minutes : 10
75
+ retry_wait_seconds : 60
76
+ max_attempts : 3
77
+ command : npm i -g firebase-tools@11
78
+ - name : Setup e2e secrets
79
+ run : |
80
+ echo SMTP_PASSWORD=${{ secrets.SENDGRID_API_KEY }} >> _emulator/extensions/firestore-send-email-sendgrid.secret.local
81
+ - run : |
82
+ echo "Checking directory: ${{ matrix.extension }}/functions"
83
+ - run : cd ${{ matrix.extension }}/functions && npm install
84
+ - run : cd ${{ matrix.extension }}/functions && npm run build
85
+ - run : cd ${{ matrix.extension }}/functions && npm run test:local
0 commit comments