Skip to content

Commit a9185b8

Browse files
committed
chore: Fix the coverage check github action.
1 parent adaa7ee commit a9185b8

File tree

10 files changed

+570
-607
lines changed

10 files changed

+570
-607
lines changed

.github/workflows/coverage.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959
run: |
6060
echo "BASE BRANCH CODE COVERAGE is ${{ env.CUR_COVER }}%"
6161
echo "PULL REQUEST CODE COVERAGE is ${{ env.PR_COVER }}%"
62-
if [ "${{ env.PR_COVER }}" -lt "$(( env.CUR_COVER - 2 ))" ]; then
62+
if (( PR_COVER - 2 > CUR_COVER )); then
63+
echo "Coverage check failed: PR reduces code coverage by more than 2%."
6364
exit 1;
6465
fi

build.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,41 +74,45 @@ function deps() {
7474
# write_e2e_env - Loads secrets from the gcloud project and writes
7575
# them to target/e2e.env to run e2e tests.
7676
function write_e2e_env(){
77-
# All secrets used by the e2e tests in the form <env_name>=<secret_name>
77+
# Set the default to .envrc file if no argument is passed
78+
# Format: <env-var-name>=<secret-name>
79+
outfile="${1:-.envrc}"
7880
secret_vars=(
7981
MYSQL_CONNECTION_NAME=MYSQL_CONNECTION_NAME
8082
MYSQL_USER=MYSQL_USER
81-
MYSQL_USER_IAM=MYSQL_USER_IAM_GO
8283
MYSQL_PASS=MYSQL_PASS
8384
MYSQL_DB=MYSQL_DB
8485
MYSQL_MCP_CONNECTION_NAME=MYSQL_MCP_CONNECTION_NAME
8586
MYSQL_MCP_PASS=MYSQL_MCP_PASS
8687
POSTGRES_CONNECTION_NAME=POSTGRES_CONNECTION_NAME
8788
POSTGRES_USER=POSTGRES_USER
88-
POSTGRES_USER_IAM=POSTGRES_USER_IAM_GO
8989
POSTGRES_PASS=POSTGRES_PASS
9090
POSTGRES_DB=POSTGRES_DB
9191
POSTGRES_CAS_CONNECTION_NAME=POSTGRES_CAS_CONNECTION_NAME
9292
POSTGRES_CAS_PASS=POSTGRES_CAS_PASS
9393
POSTGRES_CUSTOMER_CAS_CONNECTION_NAME=POSTGRES_CUSTOMER_CAS_CONNECTION_NAME
9494
POSTGRES_CUSTOMER_CAS_PASS=POSTGRES_CUSTOMER_CAS_PASS
95-
POSTGRES_CUSTOMER_CAS_DOMAIN_NAME=POSTGRES_CUSTOMER_CAS_DOMAIN_NAME
96-
POSTGRES_CUSTOMER_CAS_INVALID_DOMAIN_NAME=POSTGRES_CUSTOMER_CAS_INVALID_DOMAIN_NAME
95+
POSTGRES_CUSTOMER_CAS_DOMAIN_NAME=POSTGRES_CUSTOMER_CAS_PASS_VALID_DOMAIN_NAME
96+
POSTGRES_CUSTOMER_CAS_INVALID_DOMAIN_NAME=POSTGRES_CUSTOMER_CAS_PASS_INVALID_DOMAIN_NAME
9797
POSTGRES_MCP_CONNECTION_NAME=POSTGRES_MCP_CONNECTION_NAME
9898
POSTGRES_MCP_PASS=POSTGRES_MCP_PASS
9999
SQLSERVER_CONNECTION_NAME=SQLSERVER_CONNECTION_NAME
100100
SQLSERVER_USER=SQLSERVER_USER
101101
SQLSERVER_PASS=SQLSERVER_PASS
102102
SQLSERVER_DB=SQLSERVER_DB
103+
IMPERSONATED_USER=IMPERSONATED_USER
103104
QUOTA_PROJECT=QUOTA_PROJECT
104105
)
105106

106-
if [[ -z "$TEST_PROJECT" ]] ; then
107+
if [[ -z "${TEST_PROJECT:-}" ]] ; then
107108
echo "Set TEST_PROJECT environment variable to the project containing"
108109
echo "the e2e test suite secrets."
109110
exit 1
110111
fi
111112

113+
echo "Getting test secrets from $TEST_PROJECT into $outfile"
114+
local_user=$(gcloud auth list --format 'value(account)' | tr -d '\n')
115+
112116
echo "Getting test secrets from $TEST_PROJECT into $1"
113117
{
114118
for env_name in "${secret_vars[@]}" ; do
@@ -118,7 +122,10 @@ function write_e2e_env(){
118122
val=$(gcloud secrets versions access latest --project "$TEST_PROJECT" --secret="$secret_name")
119123
echo "export $env_var_name='$val'"
120124
done
121-
} > "$1"
125+
# Set IAM User env vars to the local gcloud user
126+
echo "export MYSQL_IAM_USER='${local_user%%@*}'"
127+
echo "export POSTGRES_IAM_USER='$local_user'"
128+
} > "$outfile"
122129

123130
}
124131

examples/prisma/mysql/test/connect.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const t = require('tap');
1919
function generatePrismaClient() {
2020
const schemaPath = resolve(__dirname, '../schema.prisma');
2121

22-
execSync(`npx prisma generate --schema=${schemaPath}`);
22+
execSync(`npm exec prisma -- generate --schema=${schemaPath}`);
2323
}
2424

2525
t.test('mysql prisma cjs', async t => {

examples/prisma/mysql/test/connect.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function generatePrismaClient() {
2222
const __dirname = dirname(p)
2323
const schemaPath = resolve(__dirname, '../schema.prisma');
2424

25-
execSync(`npx prisma generate --schema=${schemaPath}`);
25+
execSync(`npm exec prisma -- generate --schema=${schemaPath}`);
2626
}
2727

2828
t.test('mysql prisma mjs', async t => {

examples/prisma/mysql/test/connect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import t from 'tap';
1919
function generatePrismaClient() {
2020
const schemaPath = resolve(__dirname, '../schema.prisma');
2121

22-
execSync(`npx prisma generate --schema=${schemaPath}`);
22+
execSync(`npm exec prisma -- generate --schema=${schemaPath}`);
2323
}
2424

2525
t.test('mysql prisma ts', async t => {

examples/prisma/postgresql/test/connect.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const t = require('tap');
1919
function generatePrismaClient() {
2020
const schemaPath = resolve(__dirname, '../schema.prisma');
2121

22-
execSync(`npx prisma generate --schema=${schemaPath}`);
22+
execSync(`npm exec prisma -- generate --schema=${schemaPath}`);
2323
}
2424

2525
t.test('pg prisma cjs', async t => {

examples/prisma/postgresql/test/connect.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function generatePrismaClient() {
2222
const __dirname = dirname(p)
2323
const schemaPath = resolve(__dirname, '../schema.prisma');
2424

25-
execSync(`npx prisma generate --schema=${schemaPath}`);
25+
execSync(`npm exec prisma -- generate --schema=${schemaPath}`);
2626
}
2727

2828
t.test('pg prisma mjs', async t => {

examples/prisma/postgresql/test/connect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import t from 'tap';
1919
function generatePrismaClient() {
2020
const schemaPath = resolve(__dirname, '../schema.prisma');
2121

22-
execSync(`npx prisma generate --schema=${schemaPath}`);
22+
execSync(`npm exec prisma -- generate --schema=${schemaPath}`);
2323
}
2424

2525
t.test('pg prisma ts', async t => {

0 commit comments

Comments
 (0)