feat: holdouts, sendBeacon for JS #106
This file contains hidden or 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
| name: CI | |
| on: | |
| push: | |
| branches: [ master, github-action ] | |
| pull_request: | |
| branches: [ master ] | |
| jobs: | |
| build: | |
| if: "!contains(toJSON(github.event.commits.*.message), '[skip-ci]')" | |
| name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - ubuntu-latest | |
| # - macos-latest | |
| # - windows-latest | |
| node_version: [ 12.x, 13.x, 14.x, 15.x, 16.x, 18.x, 19.x, 20.x, 21.x, 22.x ] # [6.x, 8.x, 10.x, 12.x, 14.x, 15.x, 16.x, 17.x, 18.x, 19.x, 20.x, 21.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 }} | |
| - name: Restore packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| node_modules | |
| */*/node_modules | |
| key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} | |
| - name: Copy appropriate package.json | |
| run: | | |
| if [[ ${{ matrix.node_version }} == 12* ]]; then | |
| cp package-below-node-16.json package.json | |
| elif [[ ${{ matrix.node_version }} == 13* ]]; then | |
| cp package-below-node-16.json package.json | |
| elif [[ ${{ matrix.node_version }} == 14* ]]; then | |
| cp package-below-node-16.json package.json | |
| elif [[ ${{ matrix.node_version }} == 15* ]]; then | |
| cp package-below-node-16.json package.json | |
| elif [[ ${{ matrix.node_version }} == 16* ]]; then | |
| cp package-below-node-16.json package.json | |
| elif [[ ${{ matrix.node_version }} == 17* ]]; then | |
| cp package-below-node-16.json package.json | |
| elif [[ ${{ matrix.node_version }} == 19* ]]; then | |
| cp package-below-node-16.json package.json | |
| fi | |
| - name: yarn install, yarn test:coverage | |
| run: | | |
| yarn install | |
| yarn test:coverage | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4.0.1 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| flags: ${{ runner.os }} | |
| - name: Notification | |
| if: always() | |
| id: slack | |
| uses: wingify/slack-github-action@v1.15.1-wingify | |
| with: | |
| channel-id: 'vwo-fs-fme-sdk-job-status' # 'fs-review-team' | |
| slack-message: "<!here> Node.js/JavaScript FME SDK Test on *Node-${{ matrix.node_version }}* and *${{ matrix.os }}* got *${{job.status}}* ${{job.status == 'success' && ':heavy_check_mark:' || ':x:'}} \nCommit: `${{github.event.head_commit.message}}`. \nCheck the latest build: https://github.com/wingify/vwo-fme-node-sdk/actions" | |
| color: "${{job.status == 'success' && '#00FF00' || '#FF0000'}}" | |
| env: | |
| SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }} | |
| - name: Publish to npm | |
| if: startsWith(github.ref, 'refs/tags/') # check if the job is triggered by a tag | |
| run: | | |
| npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} | |
| npm publish --tag latest | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Get version from tag | |
| if: startsWith(github.ref, 'refs/tags/') # check if the job is triggered by a tag | |
| id: get_version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| - name: Extract Changelog Entry | |
| if: startsWith(github.ref, 'refs/tags/') # check if the job is triggered by a tag | |
| id: changelog | |
| run: | | |
| VERSION=${{ env.VERSION }} | |
| VERSION=${VERSION#refs/tags/} | |
| VERSION=${VERSION#v} | |
| # Use awk to extract all entries between version header and next version header | |
| CHANGELOG_ENTRY=$(awk -v version="$VERSION" ' | |
| BEGIN { found=0; buffer="" } | |
| $0 ~ "^## \\[" version "]" { found=1; next } | |
| found && $0 ~ "^## \\[" { exit } | |
| found && NF { | |
| # Remove leading whitespace and common prefixes | |
| gsub(/^[[:space:]]*[-*]?[[:space:]]*/, "") | |
| gsub(/^### (Added|Changed|Fixed|Removed|Deprecated)[[:space:]]*/, "") | |
| if (buffer == "") buffer = $0 | |
| else buffer = buffer " " $0 | |
| } | |
| END { print buffer } | |
| ' CHANGELOG.md) | |
| # If no entry is found, use fallback message | |
| if [ -z "$CHANGELOG_ENTRY" ]; then | |
| CHANGELOG="No changes in this release." | |
| else | |
| # Clean up the entry | |
| CHANGELOG="$CHANGELOG_ENTRY" | |
| fi | |
| echo "CHANGELOG=$CHANGELOG" >> $GITHUB_ENV | |
| - name: Create Release | |
| if: startsWith(github.ref, 'refs/tags/') # check if the job is triggered by a tag | |
| id: create_release | |
| uses: comnoco/create-release-action@v2.0.5 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.ref }} # Tag name is used as the version | |
| release_name: ${{ github.ref }} # Release name based on the tag | |
| body: | | |
| ## What's Changed: | |
| ${{ env.CHANGELOG }} | |
| draft: false | |
| prerelease: false |