-
Notifications
You must be signed in to change notification settings - Fork 5
125 lines (105 loc) · 3.38 KB
/
ci.yml
File metadata and controls
125 lines (105 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: CI - Build, Test, and Publish SDKs
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
changed-sdks:
name: Determine Changed SDKs
permissions:
contents: read
runs-on: ubuntu-latest
outputs:
nodejs-sdk: ${{ steps.check_nodejs_sdk.outputs.changed }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- id: git_refs
name: Set Git refs for diff
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "base=${{ github.event.pull_request.base.sha }}" >> "$GITHUB_OUTPUT"
echo "head=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT"
else
echo "base=${{ github.event.before }}" >> "$GITHUB_OUTPUT"
echo "head=${{ github.sha }}" >> "$GITHUB_OUTPUT"
fi
- id: check_nodejs_sdk
name: Check Node.js SDK changes
run: |
if git diff --name-only "${{ steps.git_refs.outputs.base }}" "${{ steps.git_refs.outputs.head }}" -- '/**' | grep -q .; then
echo "Node.js SDK changes detected"
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "No Node.js SDK changes detected"
echo "changed=false" >> $GITHUB_OUTPUT
fi
nodejs-sdk:
name: Node.js SDK
needs: [changed-sdks]
runs-on: ubuntu-latest
permissions:
contents: read
defaults:
run:
working-directory: ./
strategy:
matrix:
node-version: ['18', '20']
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 10.20.0
- name: Install dependencies
run: pnpm i
- name: Lint code
run: npm run lint
- name: Set version with Nerdbank.GitVersioning
run: node setVersion.js
- name: Build package
run: npm run build
- name: Run tests
run: npm test
- name: Run integration tests
env:
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
AZURE_OPENAI_ENDPOINT: ${{ vars.AZURE_OPENAI_ENDPOINT }}
AZURE_OPENAI_DEPLOYMENT: ${{ vars.AZURE_OPENAI_DEPLOYMENT }}
AZURE_OPENAI_API_VERSION: ${{ vars.AZURE_OPENAI_API_VERSION }}
ENABLE_OBSERVABILITY: ${{ vars.ENABLE_OBSERVABILITY }}
run: |
npm run test:integration
- name: Pack packages
run: npm run pack
# Copy packages to drop folder
- name: Copy packages to drop folder
run: |
mkdir -p ~/drop/nodejs-${{ matrix.node-version }} && cp -v packages/*.tgz $_
- name: Upload NPM packages as artifacts
uses: actions/upload-artifact@v4
with:
name: nodejs-${{ matrix.node-version }}
path: ~/drop/nodejs-${{ matrix.node-version }}/*.tgz
# - name: Publish to NPM (commented for now)
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# run: npm publish
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}