fix: chagne pipeline to test #120
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
name: CI/CD Pipeline | |
on: | |
push: | |
branches: [fix(preview-middleware)-PREVIEW_URL.client.url] | |
pull_request: | |
branches: [fix(preview-middleware)-PREVIEW_URL.client.url] | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
node-version: [18.x] | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout code repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
run_install: true | |
- name: Cache pnpm modules | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-pnpm-modules | |
with: | |
path: ~/.pnpm-store | |
key: ${{ matrix.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ matrix.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}- | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install pnpm modules | |
run: pnpm install | |
- name: Run build | |
run: pnpm run build | |
- name: Run unit tests | |
run: pnpm run test | |
- name: Cache playwright browsers | |
id: cache-playwright-browsers | |
uses: actions/cache@v4 | |
with: | |
path: | | |
${{ runner.os == 'Windows' }}: | |
C:\Users\runneradmin\AppData\Local\ms-playwright | |
${{ runner.os != 'Windows' }}: | |
~/.cache/ms-playwright | |
key: playwright-browsers-os-${{ matrix.os }}-node-version-${{ matrix.node-version }} | |
- name: Install playwright browsers | |
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' | |
run: npx playwright install --with-deps | |
- name: Run integration tests | |
run: pnpm run test:integration | |
- name: Upload playwright reports | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: playwright-reports-os-${{ matrix.os }}-node-version-${{ matrix.node-version }} | |
path: | | |
packages/*/playwright-report | |
!packages/*/node_modules | |
retention-days: 15 | |
- name: Run SonarCloud scan | |
if: matrix.os == 'ubuntu-latest' && matrix.node-version == '18.x' | |
uses: sonarsource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.ACCESS_PAT }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
- name: Checkout code repository | |
uses: actions/checkout@v4 | |
- name: Setup pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
run_install: true | |
- name: Cache pnpm modules | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-pnpm-modules | |
with: | |
path: ~/.pnpm-store | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18.x | |
- name: Install pnpm modules | |
run: pnpm install | |
- name: Run build | |
run: pnpm run build | |
- name: Setup npmrc with npmjs.com token | |
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPMJS_TOKEN }}" > .npmrc | |
- name: 'Publish to npmjs' | |
id: changesetPublish | |
uses: changesets/[email protected] | |
with: | |
publish: pnpm ci:publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.ACCESS_PAT }} | |
- name: Prepare Slack notification message | |
if: steps.changesetPublish.outputs.published == 'true' | |
run: | | |
# Random delimiter required to support multi-line environment variable value | |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
echo "PUBLISHED_PACKAGES_MESSAGE<<$EOF" >> $GITHUB_ENV | |
# publishedPackages JSON format: '[{"name": "@sap-ux/axios-extension", "version": "1.0.2"}, {"name": "@sap-ux/fiori-freestyle-writer", "version": "0.15.12"}]' | |
echo "$(echo '${{ steps.changesetPublish.outputs.publishedPackages }}' | jq --raw-output 'map("*" + .name + "*" + " - " + "<https://www.npmjs.com/package/" + .name + "|" + .version + ">") | join("\\n")')" >> $GITHUB_ENV | |
echo "$EOF" >> $GITHUB_ENV | |