Skip to content

Commit

Permalink
ci: add a build specific to token credential support
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurschreiber committed Jul 15, 2024
1 parent 3607abc commit 3856dc5
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,53 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}

token-credential-auth:
name: Azure SQL Server / Node.js 18.x
runs-on: ubuntu-latest
timeout-minutes: 20

# Only run these tests if we have access to the secrets
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}

steps:
- uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18

- name: Determine npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v3
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci

- name: Set up CI configuration
shell: bash
run: cp -f test/config.token-credential.ts test/config.ts

- name: run integration tests
env:
AZURE_SERVER: ${{ secrets.AZURE_SERVER }}
AZURE_AD_SP_CLIENT_ID: ${{ secrets.AZURE_AD_SP_CLIENT_ID }}
AZURE_AD_SP_TENANT_ID: ${{ secrets.AZURE_AD_SP_TENANT_ID }}
AZURE_AD_USERNAME: ${{ secrets.AZURE_AD_USERNAME }}
AZURE_AD_PASSWORD: ${{ secrets.AZURE_AD_PASSWORD }}
run: npx nyc --reporter=lcov npm run test-integration

- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}


azure-ad-service-principal-auth:
name: Azure SQL Server / Node.js 18.x
runs-on: ubuntu-latest
Expand Down
23 changes: 23 additions & 0 deletions test/config.token-credential.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { type ConnectionConfiguration } from '../src/connection';
import { UsernamePasswordCredential } from '@azure/identity';

const tokenCredential = new UsernamePasswordCredential(
process.env.AZURE_AD_SP_TENANT_ID as string,
process.env.AZURE_AD_SP_CLIENT_ID as string,
process.env.AZURE_AD_USERNAME as string,
process.env.AZURE_AD_PASSWORD as string
);

export default {
'server': process.env.AZURE_SERVER,
'authentication': {
'type': 'token-credential',
'options': {
'credential': tokenCredential
}
},
'options': {
'port': 1433,
'database': 'tedious'
}
} as ConnectionConfiguration;

0 comments on commit 3856dc5

Please sign in to comment.