Skip to content

Test GitHub Workflows with Snyk and Unit Test Improvements #1

Test GitHub Workflows with Snyk and Unit Test Improvements

Test GitHub Workflows with Snyk and Unit Test Improvements #1

Workflow file for this run

name: Unit Tests
on:
pull_request:
paths:
- 'packages/auth0-acul-js/**'
- 'packages/ul-react-component/**'
- 'packages/ul-react/**'
push:
branches:
- master
paths:
- 'packages/auth0-acul-js/**'
- 'packages/ul-react-component/**'
- 'packages/ul-react/**'
permissions:
contents: read
pull-requests: read
concurrency:
group: “${{ github.workflow }}-${{ github.ref }}”
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
NODE_VERSION: 18
jobs:
determine-package:
name: Determine modified files
runs-on: ubuntu-latest
outputs:
ul-javascript-changed: ${{ steps.determine_package.outputs.ul-javascript-changed }}
ul-react-component-changed: ${{ steps.determine_package.outputs.ul-react-component-changed }}
ul-react-changed: ${{ steps.determine_package.outputs.ul-react-changed }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Determine affected packages
id: determine_package
shell: bash
run: |
curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"${{ github.event.pull_request.url }}/files" \
> files.json
cat files.json
jq -r '.[].filename' files.json > changed_files.txt
cat changed_files.txt
ul_javascript_changed=false
ul_react_component_changed=false
ul_react_changed=false
if grep -q "packages/auth0-acul-js/" changed_files.txt; then
ul_javascript_changed=true
fi
if grep -q "packages/ul-react-component/" changed_files.txt; then
ul_react_component_changed=true
fi
if grep -q "packages/ul-react/" changed_files.txt; then
ul_react_changed=true
fi
echo "ul-javascript-changed=$ul_javascript_changed" >> $GITHUB_OUTPUT
echo "ul-react-component-changed=$ul_react_component_changed" >> $GITHUB_OUTPUT
echo "ul-react-changed=$ul_react_changed" >> $GITHUB_OUTPUT
ul-javascript-build:
needs: determine-package
if: ${{ needs.determine-package.outputs.ul-javascript-changed == 'true' }}
name: Build and Test ul-javascript
runs-on: ubuntu-22.04-2cpu-8ram-75ssd
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
registry-url : "https://registry.npmjs.org"
- name: Install dependencies
shell: bash
working-directory: packages/auth0-acul-js
run: |
npm install --include=dev
continue-on-error: true
- name: Build package
shell: bash
working-directory: packages/auth0-acul-js
run: |
npm run build
- name: Run tests
shell: bash
working-directory: packages/auth0-acul-js
run: |
npm run test
ul-react-component-build:
needs: determine-package
if: ${{ needs.determine-package.outputs.ul-react-component-changed == 'true' }}
name: Build and Test ul-react-component
runs-on: ubuntu-22.04-2cpu-8ram-75ssd
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
registry-url : "https://registry.npmjs.org"
- name: Install dependencies
shell: bash
working-directory: packages/ul-react-component
run: |
npm install --include=dev
- name: Build package
shell: bash
working-directory: packages/ul-react-component
run: |
npm run build
- name: Run tests
shell: bash
working-directory: packages/ul-react-component
run: |
npm run test
ul-react-build:
needs: determine-package
if: ${{ needs.determine-package.outputs.ul-react-changed == 'true' }}
name: Build and Test ul-react
runs-on: ubuntu-22.04-2cpu-8ram-75ssd
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
registry-url : "https://registry.npmjs.org"
- name: Install dependencies
shell: bash
working-directory: packages/ul-react
run: |
npm install --include=dev
- name: Build package
shell: bash
working-directory: packages/ul-react
run: |
npm run build
- name: Run tests
shell: bash
working-directory: packages/ul-react
run: |
npm run test
notify:
needs:
- ul-javascript-build
- ul-react-component-build
- ul-react-build
runs-on: ubuntu-latest
if: always()
steps:
- name: Notify Status
run: echo "All relevant package tests completed."