refactor: Migrate Identity API Client to TypeScript #2135
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This Github Workflow builds v2 of the mParticle Web SDK, lints with ESLint and Prettier to find errors, and runs all tests | |
# If the PR is from dependabot, it automatically gets merged if tests run properly. | |
name: Web SDK Build & Test | |
on: pull_request | |
jobs: | |
build-bundle: | |
name: Build Distribution Bundle | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: NPM install | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16.x | |
- name: Run NPM CI | |
run: npm ci | |
- name: Lint with ESLint | |
run: npm run lint | |
- name: Lint with Prettier | |
run: npm run prettier | |
- name: Run Build IIFE | |
run: npm run build:iife | |
- name: Display Bundle Diff, but Fancy! | |
run: git diff --unified=3 dist/mparticle.js | npx diff-so-fancy | |
- name: Archive Bundle | |
uses: actions/upload-artifact@v3 | |
with: | |
name: bundle-local | |
path: dist | |
- name: Archive npm failure logs | |
uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: npm-logs | |
path: ~/.npm/_logs | |
# Currently, we're only using Jest to test TypeScript modules | |
# and they do not require any built files | |
test-jest: | |
name: 'Test Jest' | |
runs-on: 'ubuntu-latest' | |
strategy: | |
matrix: | |
node-version: [16.x, 17.x, 18.x, 19.x, 20.x] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: NPM install | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Run NPM CI | |
run: npm ci | |
- name: Run Jest Tests | |
run: npm run test:jest | |
- name: Archive npm failure logs | |
uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: npm-logs | |
path: ~/.npm/_logs | |
# Only Core test requires bundle, but we want to make sure | |
# that tests only run when the bundle is successfully built | |
test-core: | |
name: Core Tests | |
uses: mParticle/mparticle-workflows/.github/workflows/web-run-test.yml@main | |
needs: | |
- test-jest | |
- build-bundle | |
with: | |
test_command_label: Core SDK Tests | |
test_command: npm run test | |
build_command: npm run build:iife | |
branch_name: ${{ vars.GITHUB_SHA }} | |
# Test Stub can be run independent of other tests | |
test-stub: | |
name: 'Test Stub' | |
runs-on: ubuntu-latest | |
needs: | |
- test-core | |
- test-jest | |
- build-bundle | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: NPM install | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16.x | |
- name: Run NPM CI | |
run: npm ci | |
- name: Install Firefox Latest | |
uses: browser-actions/setup-firefox@latest | |
- name: Log Firefox Version | |
run: firefox --version | |
- name: Run Stub Tests | |
run: npm run test:stub | |
- name: Archive npm failure logs | |
uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: npm-logs | |
path: ~/.npm/_logs | |
# Integration Tests run the same suite of tests against various build systems | |
# to make sure our SDK will run in different environments | |
test-integrations-require-js: | |
name: 'Integration Tests: Require JS' | |
uses: mParticle/mparticle-workflows/.github/workflows/web-run-test.yml@main | |
needs: | |
- test-core | |
- test-jest | |
- build-bundle | |
with: | |
test_command_label: Require JS Test | |
test_command: npm run test:requirejs | |
branch_name: ${{ vars.GITHUB_SHA }} | |
test-integrations-common-js-browserfy: | |
name: 'Integration Tests: Browserfy Common JS' | |
uses: mParticle/mparticle-workflows/.github/workflows/web-run-test.yml@main | |
needs: | |
- test-core | |
- test-jest | |
- build-bundle | |
with: | |
test_command_label: Browserfy CJS Test | |
test_command: npm run test:integrations:cjs:browserfy | |
branch_name: ${{ vars.GITHUB_SHA }} | |
build_command: npm run build:npm && npm run build:test-bundle | |
test-integrations-common-js-webpack: | |
name: 'Integration Tests: webpack Common JS' | |
uses: mParticle/mparticle-workflows/.github/workflows/web-run-test.yml@main | |
needs: | |
- test-core | |
- test-jest | |
- build-bundle | |
with: | |
test_command_label: webpack CJS Test | |
test_command: npm run test:integrations:cjs:webpack | |
branch_name: ${{ vars.GITHUB_SHA }} | |
build_command: npm run build:npm && npm run build:test-bundle | |
test-integrations-common-js-rollup: | |
name: 'Integration Tests: Rollup Common JS' | |
uses: mParticle/mparticle-workflows/.github/workflows/web-run-test.yml@main | |
needs: | |
- test-core | |
- test-jest | |
- build-bundle | |
with: | |
test_command_label: Rollup CJS Test | |
test_command: npm run test:integrations:cjs:rollup | |
branch_name: ${{ vars.GITHUB_SHA }} | |
build_command: npm run build:npm && npm run build:test-bundle | |
test-integrations-module-js-webpack: | |
name: 'Integration Tests: webpack Module JS' | |
uses: mParticle/mparticle-workflows/.github/workflows/web-run-test.yml@main | |
needs: | |
- test-core | |
- test-jest | |
- build-bundle | |
with: | |
test_command_label: webpack Module Test | |
test_command: npm run test:integrations:module:webpack | |
branch_name: ${{ vars.GITHUB_SHA }} | |
build_command: npm run build:esm && npm run build:test-bundle | |
test-integrations-module-js-rollup: | |
name: 'Integration Tests: Rollup Module JS' | |
uses: mParticle/mparticle-workflows/.github/workflows/web-run-test.yml@main | |
needs: | |
- test-core | |
- test-jest | |
- build-bundle | |
with: | |
test_command_label: Rollup Module Test | |
test_command: npm run test:integrations:module:rollup | |
branch_name: ${{ vars.GITHUB_SHA }} | |
build_command: npm run build:esm && npm run build:test-bundle | |
build-local: | |
name: Get Bundle Size from Current Branch | |
runs-on: ubuntu-latest | |
needs: build-bundle | |
outputs: | |
bundledLocal: ${{ steps.set-bundled-local.outputs.bundledLocal }} | |
bundledLocalHuman: ${{ steps.set-bundled-local.outputs.bundledLocalHuman }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: NPM install | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16.x | |
- name: Run NPM CI | |
run: npm ci | |
- name: Download Local Bundle | |
uses: actions/download-artifact@v3 | |
with: | |
name: bundle-local | |
- name: Compress Bundle | |
run: npm run bundle | |
- name: Report Bundle Size | |
run: | | |
BUNDLED_LOCAL=$(ls -l dist/mparticle.min.js.gz | awk '{print $5}') | |
echo "BUNDLED_LOCAL=$BUNDLED_LOCAL" >> $GITHUB_ENV | |
BUNDLED_LOCAL_HUMAN=$(ls -lh dist/mparticle.min.js.gz | awk '{print $5}') | |
echo "BUNDLED_LOCAL_HUMAN=$BUNDLED_LOCAL_HUMAN" >> $GITHUB_ENV | |
- name: Set Local Bundled Size | |
id: set-bundled-local | |
run: | | |
echo "::set-output name=bundledLocal::${{ env.BUNDLED_LOCAL }}" | |
echo "::set-output name=bundledLocalHuman::${{ env.BUNDLED_LOCAL_HUMAN }}" | |
- name: Archive npm failure logs | |
uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: npm-logs | |
path: ~/.npm/_logs | |
build-master: | |
name: Get Bundle Size from Master | |
runs-on: ubuntu-latest | |
needs: build-bundle | |
outputs: | |
bundledMaster: ${{ steps.set-bundled-master.outputs.bundledMaster }} | |
bundledMasterHuman: ${{ steps.set-bundled-master.outputs.bundledMasterHuman }} | |
steps: | |
- name: Checkout Master | |
uses: actions/checkout@v3 | |
with: | |
ref: master | |
- name: NPM install | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16.x | |
- name: Compress Bundle | |
run: npm run bundle | |
- name: Report Bundle Size | |
run: | | |
BUNDLED_MASTER=$(ls -l dist/mparticle.min.js.gz | awk '{print $5}') | |
echo "BUNDLED_MASTER=$BUNDLED_MASTER" >> $GITHUB_ENV | |
BUNDLED_MASTER_HUMAN=$(ls -lh dist/mparticle.min.js.gz | awk '{print $5}') | |
echo "BUNDLED_MASTER_HUMAN=$BUNDLED_MASTER_HUMAN" >> $GITHUB_ENV | |
- name: Set Master Bundled Size | |
id: set-bundled-master | |
run: | | |
echo "::set-output name=bundledMaster::${{ env.BUNDLED_MASTER }}" | |
echo "::set-output name=bundledMasterHuman::${{ env.BUNDLED_MASTER_HUMAN }}" | |
- name: Archive npm failure logs | |
uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: npm-logs | |
path: ~/.npm/_logs | |
calculate-bundled: | |
name: Calculate Bundled Diff | |
uses: ./.github/workflows/calculate-difference.yml | |
needs: | |
- build-master | |
- build-local | |
with: | |
initial_bundle_size: ${{ needs.build-master.outputs.bundledMaster }} | |
updated_bundle_size: ${{ needs.build-local.outputs.bundledLocal }} | |
generate-report: | |
name: Generate Report | |
runs-on: ubuntu-latest | |
needs: | |
- build-master | |
- build-local | |
- calculate-bundled | |
steps: | |
- name: Adding Markdown | |
run: | | |
echo '### Calculate Bundle Size Difference' >> $GITHUB_STEP_SUMMARY | |
echo "| | master | current | % changed |" >> $GITHUB_STEP_SUMMARY | |
echo "|--|--|--|--|" >> $GITHUB_STEP_SUMMARY | |
echo "| mparticle.min.js.gz | ${{ needs.build-master.outputs.bundledMasterHuman }} | ${{ needs.build-local.outputs.bundledLocalHuman }} | ${{ needs.calculate-bundled.outputs.diff_percent }} |" >> $GITHUB_STEP_SUMMARY | |
automerge-dependabot: | |
name: 'Save PR Number for Dependabot Automerge' | |
needs: | |
- test-core | |
- test-stub | |
- test-integrations-common-js-browserfy | |
- test-integrations-common-js-webpack | |
- test-integrations-common-js-rollup | |
- test-integrations-module-js-webpack | |
- test-integrations-module-js-rollup | |
- test-integrations-require-js | |
uses: mParticle/mparticle-workflows/.github/workflows/dependabot-save-pr-number.yml@main |