Skip to content

Tooling updates to repo #2650

Tooling updates to repo

Tooling updates to repo #2650

name: Build and test all the Kiota packages
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
permissions:
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
environment:
name: build_test
env:
TENANT_ID: ${{ secrets.TENANT_ID }}
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build
- run: npm run lint:eslint:loud
- run: npm run prettier:check
- name: Archive dist folders # archive dist folders to verify if they are transpiled correctly and available for publishing
uses: actions/upload-artifact@v4
with:
name: dist folders ${{ matrix.node-version }}
path: |
packages/abstractions/dist
packages/serialization/form/dist
packages/serialization/json/dist
packages/serialization/multipart/dist
packages/serialization/text/dist
packages/http/fetch/dist
packages/authentication/azure/dist
- run: npm run test:integrated
if: ${{env.TENANT_ID != '' }}
env:
TENANT_ID: ${{secrets.tenant_id}}
CLIENT_ID: ${{secrets.client_id}}
CLIENT_SECRET: ${{secrets.client_secret}}
USER_ID: ${{secrets.user_id}}
- run: npm run test
- run: npm run test:coverage
if: ${{ matrix.node-version == '22.x' }}
- name: Code Coverage Report
if: ${{ matrix.node-version == '22.x' }}
uses: irongut/[email protected]
with:
filename: "packages/**/coverage/cobertura-coverage.xml"
format: markdown
hide_branch_rate: false
output: both
badge: true
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
- name: Archive coverage files
uses: actions/upload-artifact@v4
with:
name: Coverage files ${{ matrix.node-version }}
path: |
packages/abstractions/coverage
packages/serialization/form/coverage
packages/serialization/json/coverage
packages/serialization/multipart/coverage
packages/serialization/text/coverage
packages/http/fetch/coverage
packages/authentication/azure/coverage
packages/authentication/spfx/coverage
publish-npm:
if: "${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, 'chore: release main') }}"
needs: [build, check-typescript-version-matrix]
environment:
name: production_feed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: |
git config --global user.name '${GITHUB_ACTOR}'
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_ACTOR: ${{ secrets.GIT_USERNAME }}
- run: npm ci
- run: npm run build
- run: npx lerna publish from-package --no-push --yes
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
# The check-typescript-version-matrix returns success if all matrix jobs in build are successful; otherwise, it returns a failure.
# Use this as a PR status check for GitHub Policy Service instead of individual matrix entry checks.
check-typescript-version-matrix:
runs-on: ubuntu-latest
needs: [build]
if: always()
steps:
- name: All build matrix options are successful
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: One or more build matrix options failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1