Skip to content

npm(deps): bump react-router-dom from 5.3.0 to 6.21.3 in /app #1187

npm(deps): bump react-router-dom from 5.3.0 to 6.21.3 in /app

npm(deps): bump react-router-dom from 5.3.0 to 6.21.3 in /app #1187

Workflow file for this run

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: [ master ]
paths-ignore:
# Can we use '**.md' ?
- 'README.md'
- 'SECURITY.md'
- 'CONTRIBUTING.md'
- 'CODE_OF_CONDUCT.md'
- 'app/README.md'
- 'LICENSE'
- '.gitignore'
pull_request:
branches: [ master ]
jobs:
check-secrets:
runs-on: ubuntu-latest
outputs:
github-token: ${{ steps.github-token.outputs.defined }}
deepsource-token: ${{ steps.github-token.outputs.defined }}
steps:
- id: github-token
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: "${{ env.GITHUB_TOKEN != '' }}"
run: echo "::set-output name=defined::true"
- id: deepsource-token
env:
DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }}
if: "${{ env.DEEPSOURCE_DSN != '' }}"
run: echo "::set-output name=defined::true"
pre_ci:
name: Prepare CI environment
runs-on: ubuntu-latest
outputs:
commit_message: ${{ steps.get_commit_message.outputs.commit_message }}
branch: ${{ steps.extract_branch.outputs.branch }}
steps:
- name: Checkout Project
uses: actions/checkout@v3
with:
# We need to fetch with a depth of 2 for pull_request so we can do HEAD^2
fetch-depth: 2
- name: "Get commit message"
id: get_commit_message
env:
COMMIT_PUSH: ${{ github.event.head_commit.message }}
run: |
COMMIT_MESSAGE="${COMMIT_PUSH:-$(git log --format=%B -n 1 HEAD^2)}"
echo "::set-output name=commit_message::${COMMIT_MESSAGE}"
- name: Extract branch name
id: extract_branch
run: |
TMP_PULL_HEAD_REF="${{ github.head_ref }}"
TMP_GITHUB_REF="${GITHUB_REF#refs/heads/}"
EXPORT_VALUE=""
if [ "${TMP_PULL_HEAD_REF}" != "" ]
then
EXPORT_VALUE="${TMP_PULL_HEAD_REF}"
else
EXPORT_VALUE="${TMP_GITHUB_REF}"
fi
echo "##[set-output name=branch;]${EXPORT_VALUE}"
pre-tests:
name: Install dependencies (if needed)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 12.x
uses: actions/setup-node@v3.6.0
with:
node-version: 12.x
- name: Manage cache
uses: actions/cache@v3
with:
path: |
app/node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('.github/workflows/*.yml') }}
restore-keys: |
${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
${{ runner.OS }}-build
- name: yarn install
working-directory: ./app
run: yarn --color --immutable
test-build:
needs: [pre-tests]
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.6.0
with:
node-version: ${{ matrix.node-version }}
- name: Manage cache
uses: actions/cache@v3
with:
path: |
app/node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('.github/workflows/*.yml') }}
restore-keys: |
${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
${{ runner.OS }}-build
- name: yarn build
working-directory: ./app
run: yarn build
- uses: actions/upload-artifact@v3
# Same condition as `publish`job
if: ${{ !contains(github.event.head_commit.message, '#no-publish') && (( github.event_name == 'pull_request' && github.event.pull_request.merged == true ) || github.ref == 'refs/heads/master' ) }}
with:
name: built-app
path: docs
if-no-files-found: error
retention-days: 5
test-code:
needs: [check-secrets, pre-tests]
name: Test code and generate test coverage value
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
# Map a step output to a job output
outputs:
coverage: ${{ steps.coverage.outputs.coverage }}
coverage-rounded-display: ${{ steps.coverage.outputs.coverage-rounded-display }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.6.0
with:
node-version: ${{ matrix.node-version }}
- name: Manage cache
uses: actions/cache@v3
with:
path: |
app/node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('.github/workflows/*.yml') }}
restore-keys: |
${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
${{ runner.OS }}-build
- name: yarn test
working-directory: ./app
run: yarn test:coverage:color
# Coverage badges will be updated on any branch
# and saved into a dedicated one
- name: Check test coverage
uses: johanvanhelden/gha-clover-test-coverage-check@v1
id: coverage
with:
percentage: 50
exit: 0
rounded-precision: 2
filename: "app/coverage/clover.xml"
test-lint:
needs: [pre-tests]
name: Lint
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.6.0
with:
node-version: ${{ matrix.node-version }}
- name: Manage cache
uses: actions/cache@v3
with:
path: |
app/node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('.github/workflows/*.yml') }}
restore-keys: |
${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
${{ runner.OS }}-build
- name: Get test coverage for DeepSource
working-directory: ./app
run: yarn lint
test-code-deepsource:
needs: [check-secrets, pre-tests]
if: ${{ needs.check-secrets.outputs.deepsource-token == 'true' }}
name: Get test coverage for DeepSource and report it
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.6.0
with:
node-version: ${{ matrix.node-version }}
- name: Manage cache
uses: actions/cache@v3
with:
path: |
app/node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('.github/workflows/*.yml') }}
restore-keys: |
${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}
${{ runner.OS }}-build
- name: Get test coverage for DeepSource
working-directory: ./app
run: yarn test:coverage:cobertura
- name: Report test coverage to DeepSource
uses: deepsourcelabs/test-coverage-action@master
with:
key: javascript
coverage-file: app/coverage/cobertura-coverage.xml
dsn: ${{ secrets.DEEPSOURCE_DSN }}
test:
name: Tests waiter
# No need to wait for deepsource test and report
needs: [test-code, test-build, test-lint]
runs-on: ubuntu-latest
outputs:
coverage: ${{ needs.test-code.outputs.coverage }}
coverage-rounded-display: ${{ needs.test-code.outputs.coverage-rounded-display }}
steps:
- name: Check test coverage
env:
COVERAGE: ${{ needs.test-code.outputs.coverage }}
COVERAGE_ROUNDED: ${{ needs.test-code.outputs.coverage-rounded-display }}
run: |
echo "Coverage: ${COVERAGE}"
echo "Coverage Rounded: ${COVERAGE_ROUNDED}"
comment_pr:
name: Comment on PR with test coverage value
needs: [test, pre_ci]
if: ${{ github.event_name == 'pull_request' && github.actor == github.repository_owner && !contains(needs.pre_ci.outputs.commit_message, '#comment-badge') }}
runs-on: ubuntu-latest
steps:
- name: Generate comment file with test coverage
env:
COVERAGE: ${{ needs.test.outputs.coverage-rounded-display }}
run: |
echo "**Test coverage: ${COVERAGE}**" > output.md
- name: Comment PR with test coverage
uses: machine-learning-apps/pr-comment@1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
path: output.md
badge:
# Only generate and publish if these conditions are met:
# - The test step ended successfully
# - One of these is met:
# - This is a pull request event and the pull actor is the same as the repo owner
# - This is a push event and the push event is on branch 'master'
name: Generate badge image with test coverage value
needs: [test, pre_ci]
if: ${{ ( github.event_name == 'pull_request' && github.actor == github.repository_owner ) || github.ref == 'refs/heads/master' }}
outputs:
url: ${{ steps.url.outputs.url }}
markdown: ${{ steps.url.outputs.markdown }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: badges
path: badges
# Use the output from the `coverage` step
- name: Generate the badge SVG image
uses: emibcn/badge-action@v2.0.2
id: badge
with:
label: 'Coverage'
status: ${{ needs.test.outputs.coverage-rounded-display }}
color: ${{
needs.test.outputs.coverage > 90 && 'green' ||
needs.test.outputs.coverage > 80 && 'yellow,green' ||
needs.test.outputs.coverage > 70 && 'yellow' ||
needs.test.outputs.coverage > 60 && 'orange,yellow' ||
needs.test.outputs.coverage > 50 && 'orange' ||
needs.test.outputs.coverage > 40 && 'red,orange' ||
needs.test.outputs.coverage > 30 && 'red,red,orange' ||
needs.test.outputs.coverage > 20 && 'red,red,red,orange' ||
'red' }}
path: badges/test-coverage.svg
- name: Commit badge
env:
BRANCH: ${{ needs.pre_ci.outputs.branch }}
FILE: 'test-coverage.svg'
working-directory: ./badges
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
mkdir -p "${BRANCH}"
mv "${FILE}" "${BRANCH}"
git add "${BRANCH}/${FILE}"
# Will give error if badge did not changed
git commit -m "Add/Update badge" || true
- name: Push badge commit
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: badges
directory: badges
- name: Badge image URL
id: url
env:
BRANCH: ${{ needs.pre_ci.outputs.branch }}
FILE: 'test-coverage.svg'
COVERAGE: ${{ needs.test.outputs.coverage-rounded-display }}
run: |
URL="https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/badges/${BRANCH}/${FILE}"
MARKDOWN="![Coverage ${COVERAGE}](${URL})"
echo "Badge URL: ${URL}"
echo "Badge image for Markdown: ${MARKDOWN}"
echo "##[set-output name=url;]${URL}"
echo "##[set-output name=markdown;]${MARKDOWN}"
comment_pr_badge:
name: Comment on PR with generated badge
needs: [pre_ci, badge]
if: ${{ github.event_name == 'pull_request' && github.actor == github.repository_owner && contains(needs.pre_ci.outputs.commit_message, '#comment-badge') }}
runs-on: ubuntu-latest
steps:
- name: Generate comment file with test coverage badge
env:
BADGE: ${{ needs.badge.outputs.markdown }}
run: |
echo "Badge: ${BADGE}"
echo "${BADGE}" > output.md
- name: Comment PR with test coverage badge
uses: machine-learning-apps/pr-comment@1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
path: output.md
publish:
# Only generate and publish if these conditions are met:
# - Commit message does not contains #no-publish
# - The test step ended successfully
# - One of these is met:
# - This is a pull request event and the pull has been merged
# - This is a push event and the push event is on branch 'master'
name: Publish code to GitHub Pages
needs: [pre_ci, test]
if: ${{ !contains(github.event.head_commit.message, '#no-publish') && (( github.event_name == 'pull_request' && github.event.pull_request.merged == true ) || github.ref == 'refs/heads/master' ) }}
runs-on: ubuntu-latest
steps:
- name: Download built app from artifact
uses: actions/download-artifact@v3
with:
name: built-app
path: docs
- name: Deploy to GitHub Pages
uses: crazy-max/ghaction-github-pages@v3
with:
target_branch: gh-pages
build_dir: docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Delete the built app artifact: it's no needed anymore
- uses: geekyeggo/delete-artifact@v2
with:
name: built-app