Skip to content

Commit f84cbc9

Browse files
committed
test(*): test change
1 parent 924ddd2 commit f84cbc9

File tree

3 files changed

+47
-28
lines changed

3 files changed

+47
-28
lines changed

.github/workflows/conditional-test.yml

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,51 +12,74 @@ jobs:
1212
steps:
1313
- name: Checkout code
1414
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
1518
- name: Get changed directories
1619
id: set_changed
1720
run: |
1821
echo "::group::Determining Changed Directories"
19-
# List specific directories you want to check
2022
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"
2123
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="["
2430
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
2638
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\""
2946
fi
3047
done
3148
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"
3554
echo "::endgroup::"
36-
echo "::set-output name=changed_extensions::$CHANGED_EXTENSIONS"
3755
3856
test_extensions:
3957
needs: check_changes
4058
runs-on: ubuntu-latest
4159
strategy:
60+
fail-fast: false
4261
matrix:
4362
extension:
4463
${{ fromJson(needs.check_changes.outputs.changed_extensions) }}
45-
defaults:
46-
run:
47-
working-directory: extensions/${{ matrix.extension }}/functions
4864
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
5367
with:
5468
node-version: "18"
5569
cache: "npm"
5670
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

_emulator/firebase.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{
22
"extensions": {
33
"firestore-send-email": "../firestore-send-email",
4-
"delete-user-data": "../delete-user-data",
5-
"storage-resize-images": "../storage-resize-images",
6-
"firestore-counter": "../firestore-counter",
7-
"firestore-bigquery-export": "../firestore-bigquery-export",
84
"firestore-send-email-sendgrid": "../firestore-send-email"
95
},
106
"storage": {

firestore-send-email/functions/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { parseTlsOptions, setSmtpCredentials } from "./helpers";
2727
import * as events from "./events";
2828

2929
logs.init();
30-
30+
console.log("");
3131
let db: admin.firestore.Firestore;
3232
let transport: nodemailer.Transporter;
3333
let templates: Templates;

0 commit comments

Comments
 (0)